1

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

4

2 回答 2

4

当您知道有一个按键等待使用 int16 函数 1 读取时,只需使用函数 0 获取密钥:

mov ah, 1   ; peek
int 16h
jz  NoKey
mov ah, 0   ; get
int 16h    
于 2015-11-07T20:08:56.007 回答
1

如果你仍然想清除缓冲区,你可以使用这个:

proc ClearBuffKB
      push ax
@@CheckBuffer:
      mov ah ,1
      int 16h
      jz @@return 
      mov ah ,0
      int 16h
      jmp @@CheckBuffer
@@return:
      pop ax
      ret
endp ClearBuffKB
于 2019-05-01T15:32:16.130 回答