Advertisement
Guest User

removespaces

a guest
Jun 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .model small    
  2. .stack 100h    
  3. .data          
  4. s   db  'Hello,     wo r  ld!',0 ; null-terminated z-string
  5. len equ $ - s ; need for buffer allocation
  6. buf db len dup(0)
  7. buflen db len
  8. char db ' ' ; remove whitespaces
  9.  
  10. .code
  11. start:          
  12.     mov ax, @data
  13.     mov ds, ax      
  14.     mov es, ax
  15.    
  16.     lea di, s
  17.     mov al, char
  18.     mov ah, 0
  19.     xor dx, dx
  20.     xor bx, bx
  21.    
  22.    
  23. cycle:
  24. check_end_of_string:
  25.     cmp [di], 0
  26.     je end_cycle
  27. check_char:
  28.     cmp al, [di]
  29.     jne copy
  30. check_first:
  31.     cmp ah, 0 ; if ah == 0, then it's first occure-in-a-row of symbol
  32.     mov ah, 0
  33.     jne cycle_increment
  34.    
  35. copy:
  36.     mov ah, 1    
  37.     mov dl, [di]
  38.     push dx
  39.     inc bx
  40. cycle_increment:
  41.     inc di
  42.     loop cycle
  43.    
  44.  
  45.  end_cycle:  
  46.    
  47.    
  48.     mov buflen, bl
  49.    
  50.     lea di, buf
  51.     mov cx, bx
  52.     std
  53.    
  54. make_str:
  55.     pop ax
  56.     stosb
  57.     loop make_str
  58.    
  59. output_str:
  60.     mov ah, 40h
  61.     mov bx, 1
  62.     mov dx, di
  63.     mov cl, buflen
  64.     int 21h
  65. exit:
  66.    
  67.     mov ax, 4C00h    
  68.     int 21h    
  69.  
  70. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement