Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 100h
- .data
- s db 'Hello, wo r ld!',0 ; null-terminated z-string
- len equ $ - s ; need for buffer allocation
- buf db len dup(0)
- buflen db len
- char db ' ' ; remove whitespaces
- .code
- start:
- mov ax, @data
- mov ds, ax
- mov es, ax
- lea di, s
- mov al, char
- mov ah, 0
- xor dx, dx
- xor bx, bx
- cycle:
- check_end_of_string:
- cmp [di], 0
- je end_cycle
- check_char:
- cmp al, [di]
- jne copy
- check_first:
- cmp ah, 0 ; if ah == 0, then it's first occure-in-a-row of symbol
- mov ah, 0
- jne cycle_increment
- copy:
- mov ah, 1
- mov dl, [di]
- push dx
- inc bx
- cycle_increment:
- inc di
- loop cycle
- end_cycle:
- mov buflen, bl
- lea di, buf
- mov cx, bx
- std
- make_str:
- pop ax
- stosb
- loop make_str
- output_str:
- mov ah, 40h
- mov bx, 1
- mov dx, di
- mov cl, buflen
- int 21h
- exit:
- mov ax, 4C00h
- int 21h
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement