I was tasked to do a code that would output the equal amount of 'Text Here' depending on the user input. However, I seem to get bewildered by my cmp function.
;Get keyboard input
mov ah, 01h
int 21h
;Save to bl for later use
mov bl, al
jmp isa
isa:
mov ah, 09h
mov dx, offset text
int 21h
cmp bl, bl
jne isa
je exit
What I get with this code is only one output of 'Text' no matter what number I input.
EDIT: I tried this but now my output is infinite :(
isa:
inc bl
mov ah, 09h
mov dx, offset ulit
int 21h
cmp bl, 30h
jne isa
je exit
First of all, make sure that you initialize the BX register to zero before you start your loop:
...
xor bx,bx
isa:
...
To avoid the DOS interrupt to overwrite the contents of your (used) BX register, secure it on the stack (not sure about the calling conventions of DOS interrupts, was too long ago for me):
...
push bx
int 21h
pop bx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.