I am writing new code in assembly right now, and I need your help! I used the 16h interrupt, and I want to check if keystroke is available or not, so I want to check want the Zero Flag have right now. - how can I do it?
Thanks! :)
I am writing new code in assembly right now, and I need your help! I used the 16h interrupt, and I want to check if keystroke is available or not, so I want to check want the Zero Flag have right now. - how can I do it?
Thanks! :)
As you can see here, ZF=1 when there is no keystroke available, and ZF=0 when there is a keystroke available. You can use the J(N)Z instructions to branch accordingly
Using JZ:
mov ax, 0100h
int 16h
jz no_key
; Handle case if there is a key press here
; AH will contain the scan code; AL will contain the ASCII code
no_key:
; Handle case if there is no key press here
Using JNZ:
mov ax, 0100h
int 16h
jnz key_pressed
; Handle case if there is no key press here
key_pressed:
; Handle case if there is a key pressed here
; AH contains the scan code; AL contains the ASCII code