Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- jmp EnterPoint
- Message_1:
- db 'New Array: $'
- Message_2:
- db 10, 'Number of negative numbers: $'
- TaskInfo:
- db "This program receives sequence of numbers and then replaces negatives ones with zeros. Also it counts how many times elements where replaced.", 10, 'Array:-1,-2,3,-4,5,6,-7,8,-9 ', 10, '$'
- Array db 9, -1,-2,3,-4,5,6,-7,8,-9
- Counter db 0
- EnterPoint:
- mov ah, $09
- mov dx, TaskInfo
- int 21h
- mov ah, $09
- mov dx, Message_1
- int 21h
- mov bl, [Array]
- call CycleStart
- mov bl, [Array]
- call PrintArray
- mov ah, $09
- mov dx, Message_2
- int 21h
- call PrintCounter
- mov ax, 0C01h
- int 21h
- ret
- CycleStart:
- mov cl, bl
- mov si, Array + 1
- ChangeLoop:
- mov dl, [si]
- cmp dl, 0
- jl Change
- inc si
- loop ChangeLoop
- jmp CheckCounter
- Change:
- mov byte [si], 0
- inc si
- inc [Counter]
- loop ChangeLoop
- CheckCounter:
- dec bl
- jnz CycleStart
- ret
- PrintArray:
- mov cl, bl
- mov si, Array + 1
- LoopPrintArray:
- mov dx, [si]
- and dx, 00FFh
- add dl, '0'
- mov ah, 02h
- int 21h
- mov dl, ' '
- mov ah, 02h
- int 21h
- inc si
- loop LoopPrintArray
- ret
- PrintCounter:
- mov dx, word[Counter]
- and dx, 00FFh
- add dl, '0'
- mov ah, 02h
- int 21h
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement