Search code examples
assemblydosemu8086

emu8086 assembly Int 16 ah=01h, how to empty buffer?


Im coding a little game with keyboard strokes 'a' and 's', i dont wanna have a wait in my loop, so i tried int 16h, ah=01h. when i press key 'a' it acts as if key was stuck, how to empty/flush buffer after key is pressed ?

mov ah,01h
int 16h

Thanks for help


Solution

  • When you know there's a keypress waiting to be read with int16 function 1, just get the key using function 0:

    mov ah, 1   ; peek
    int 16h
    jz  NoKey
    mov ah, 0   ; get
    int 16h