Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- jmp start
- mess1 db 'String with replaced elements: $'
- strClose db 'Press any key to exit$'
- nextLine db '', 13, 10, '$'
- spaceLine db ' ', '$'
- string db '1 2 3 4 5 6 2 7 8 2'
- replaceNum db '2'
- size = $ - string ; ðàçìåð ìàññèâà
- start:
- mov ah, 9
- mov dx, mess1
- int 21h
- mov di, string ; DI = óêàçàòåëü íà ìàññèâ
- mov cx, size ; CX = äëèíà ìàññèâà/öèêëà
- dec cx
- xor ax, ax ; î÷èùàåì ÀÕ (ñþäà áóäåì ÷èòàòü)
- xor bx, bx ; î÷èùàåì ÂÕ (çäåñü áóäåò ñóììà)
- mov al, [replaceNum]
- cycle:
- scasb ; ñðàâíèâàåì ñ AL î÷åðåäíîé áàéò èç DI
- push ax
- jz found
- mov bx, [di-1]
- continue:
- mov ah, 02h
- mov dl, bl
- int 21h
- ; mov ah, $09
- ; mov dx, spaceLine
- ; int 21h
- pop ax
- loop cycle
- prep:
- mov ah, $09
- mov dx, nextLine
- int 21h
- jmp exit
- found:
- mov bx, '0'
- jmp continue
- exit:
- mov ah, $09
- mov dx, nextLine
- int 21h
- mov ah, $09
- mov dx, strClose
- int 21h
- mov ah, $08
- int 21h
- ret ; íà âûõîä!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement