Hey guys. I am trying to print different messages in dependency of what char you press. In my case i use, F1,F2,F3, escape.
The problem is that the first message is printed again after a char input is read, which it shouldn't!
This is my code, please tell me where i'm wrong:
TITLE ep2_5
.MODEL SMALL
.STACK 10h
.DATA
msg DB 'Apasati o tasta F*:'
msg_l equ $-msg
f1 DB 'Ati apasat tasta F1',13,10
f1_l equ $-f1
f2 DB 'Ati apasat tasta F2',13,10
f2_l equ $-f2
f3 DB 'Ati apasat tasta F3',13,10
f3_l equ $-f3
error DB 'Nu ati apasat o tasta valida! Incercati din nou',13,10
error_l equ $-error
.CODE
begin: mov ax,@DATA
mov ds,ax
loop1: ;Print msg
mov bx, 1
mov cx, msg_l
mov dx, offset msg
mov ah, 40h
int 21h
;looping to get caracters
waitk: ;getChar
mov ah, 06h ;
mov dx, 0ffh
int 21h ;
jz waitk
cmp al,59
je _f1
cmp al,60
je _f2
cmp al,61
je _f3
cmp al, 27
je bail
jmp loop1
_f1: ;Print f1
mov bx, 1
mov cx, f1_l
mov dx, offset f1
mov ah, 40h
int 21h
jmp loop1
_f2: ;Print f2
mov bx, 1
mov cx, f2_l
mov dx, offset f2
mov ah, 40h
int 21h
jmp loop1
_f3: ;Print f3
mov bx, 1
mov cx, f3_l
mov dx, offset f3
mov ah, 40h
int 21h
jmp loop1
bail: ;bail out
mov ax,4c00h
int 21h
END begin
I'm using tasm. Screenshot included.