Reputation: 350
I have the following asm code (x86).
.input:
mov ah, 00h ; get key from keyboard buffer
int 16h ; interrupt 16h
mov dl, al ; move ASCII code into dl
mov ah, 02h ; function 02
int 21h ; interrupt 21h
mov ah, 0Eh ; tell the BIOS to print the character in the AL register
mov al, dl ; copy dl into al
int 10h ; print al
sub al,0Dh ; check if it's carriage return
jz 01h ; jump relative 1 (to skip newLine)
call newLine ; add CR LF
jmp .input ; loop
However, the jump if zero instruction is not working as expected (hoped) i.e. jz 01h.
I would like to jump relative 1 instruction (or add one to the IP), to jump over the call newLine subroutine.
Currently when I press the enter key and the jz instruction is called, I believe the program is jumping absolute as a piece of code early on in the program is run.
Any ideas?
Thanks, Steve
Upvotes: 0
Views: 984
Reputation: 9278
What about
jz _no_newLine ; jump
call newLine ; add CR LF
_no_newLine:
jmp .input ; loop
Upvotes: 1
Reputation: 1143
Jump 01h will not actually skip past the call, because it counts bytes, not instructions. The call instruction consists of multiple bytes. Why not add another label after the call that you can jump to, like jz .afterCall?
Upvotes: 4