BIOS Int 16h function 11h (or 01h) is supposed to set the ZF flag to 1 if no key has been pressed. It doesn't do this, at least on 64 bit Win 7. A work-around is to add the PROC below to your program, and then replace these two lines:
MOV AH, 11h ; or 01h
INT 16h
with a call to the PROC:
CALL fake_Int16h_Function11h
fake_Int16h_Function11h PROC
; On entry, nothing.
; On exit, ZF = 1 if and only if the buffer is empty.
; No registers are changed.
push es ax bx ; Save registers.
mov ax, 40h ; BIOS Data Segment
mov es, ax
mov ax, es:[1Ah] ; Keyboard buffer head
mov bx, es:[1Ch] ; Keyboard buffer tail
sub ax, bx ; Subtract tail from head. If head == tail, then
; the result is zero, so the ZF flag will be set.
; If head == tail, the buffer is empty, ZF == 1,
; and JZ will jump.
pop bx ax es ; Restore registers. The POP instruction doesn't change
; the flags, so ZF will retain its value.
ret
----------------------
The functions set the Z flag accordingly for me; otherwise a great many DOS programs would not work properly.
So, I suggest you go back and check your results, and make sure you're not running any kind of TSR program in DOSBox that might be interfering. Also, what release version or SVN build of DOSBox are you using?