Reputation: 13636
I learn assembly 8086.
I have this code:
.model small
.stack 100h
.data
num db 10111111b
itr db 7 ;iterations
.code
mov ax, @data
mov ds, ax
mov cl,0 ;rolls counter
mov ch,0 ;zero counter
next:
rol num, 1
jnc isZero
inc cl
cmp cl, itr
je stop
jmp next
isZero:
inc ch
jmp next
stop:
mov cl,0
add cx, 48
mov ah, 9
mov dx, cx
int 21h
.exit
end
The code above counts zero digits in num variable ,when zero is detected ch
register increased by one. The code works fine.
I have a problem when I try to print the result on the screen.
On this row:
int 21h
I get this error:
INT 21h, AH=09h -
address: 07330
byte 24h not found after 2000 bytes.
; correct example of INT 21h/9h:
mov dx, offset msg
mov ah, 9
int 21h
ret
msg db "Hello$"
Any idea why I get the above error? And how to fix it?
Upvotes: 2
Views: 335
Reputation: 39676
You've stored the result in CH
, and because the test data is a mere byte the count of zero bits will vary from 0 to 8. Displaying then is easy if you use another DOS output function.
add ch, 48
mov dl, ch
mov ah, 02h
int 21h
Alternatively define Result db " $"
and use:
add ch, 48
mov Result, ch
mov ah, 09h
mov dx, offset Result
int 21h
Upvotes: 2