Page 1 of 1

keyboard buffer

Posted: Wed Aug 21, 2002 1:35 am
by drizzt
Anybody know how to empty the keyboard buffer and where is located? Thanx in advance...

Re:keyboard buffer

Posted: Wed Aug 21, 2002 1:40 am
by Pype.Clicker
it's somewhere in the BIOS variables area (some 0x40:????, if i remember well) and has 2 "pointers" to the 'next place to write' and the 'next char to read' (that's what we use to call a circular buffer).

In order to empty it, just move both pointer to the same location ;)

Re:keyboard buffer

Posted: Wed Aug 21, 2002 11:21 am
by drizzt
Thanx pype, I think it's 0040h:0071h ??? if i'm not wrong, but what I must write here exactly?!

PS
...if there's an interrupt that clear directly the keybord buffer I resolve all my problems...

Re:keyboard buffer

Posted: Wed Aug 21, 2002 2:57 pm
by Pype.Clicker
do not know any interrupt to flush the keyboard except

while ({mov ah,1 ; int 16 ; zf==1} ) {
mov ah,0 ; int 16
}

the pointers i was talkin' about were at 040:1a and 040:1c, both are words that holds offset in the buffer (ranging from 0040:001e - 0040:003d ... some spying might be necessary to know if first location is referred as 0 or 1e by the bios)

in order to flush the buffer, just do

mov es, 0040
mov ax,[es:001c] ; read the offset of the last received char
mov [es:001a],ax ; overwrite the offset of the next-char-to-read

; the buffer is now empty

Re:keyboard buffer

Posted: Thu Aug 22, 2002 1:52 am
by drizzt
Re-thanks! Your explanation is very good. It works perfectly... ;D