Article View: alt.msdos.programmer
Article #690Re: How to get keys from keyboard without removing them
From: Jerzy Tarasiuk
Date: Mon, 05 Oct 1992 17:35
Date: Mon, 05 Oct 1992 17:35
22 lines
2012 bytes
2012 bytes
>>>>> On Thu, 1 Oct 1992 01:50:23 GMT, FREE1178@vmd.cso.uiuc.edu said: F> I need to check the keyboard buffer and store keypresses in a buffer F> to be stored in a file. I want to do this as an ISR. I was planning F> on writing it in C and then porting it to Assembler. The question F> is how to check the keys in the keyboard buffer without removing them. If you mean the keyboard buffer where BIOS puts keystrokes (on AT computer there is also keyboard buffer in keyboard itself) it is easy: if you want be sure to catch all keystrokes write ISR for int 9 which calls previous ISR and then examines keyboard buffer input pointer, if it was changed then data pointed by it before servicing interrupt is the keystroke, otherwise no new data was entered (shift key or key was released or key which is ignored was pressed). Exception is break (Ctrl-ScrollLock) which clears all from keyboard buffer. If it is enough to catch keypresses read by int 16, write ISR connected to this int. Example ISR for int 9: mov cs:ds_save,ds / mov cs:bx_save,bx / mov bx,cs / mov ds,bx pop ds:ip_save / pop ds:cs_save / pop ds:f_save / mov bx,40h / mov ds,bx mov bx,ds:[1Ch] / pushf / call previous_ISR / cmp bx,ds:[1Ch] jz nothing_new / push ax / mov ax,ds:[bx] / ... / pop ax nothing_new: mov bx,cs / mov ds,bx / push ds:f_save / push ds:cs_save push ds:ip_save / mov bx,ds:bx_save / mov ds,ds:ds_save / iret (it doesn't include check for the break - need write ISR for int 1B).
Technical Details
Message-ID:
<JT.92Oct5183556@fizyk1.fuw.edu.pl>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!fuw.edu.pl!cocos!jtReferences:
<168721250F.FREE1178@vmd.cso.uiuc.edu>Show Full Headers
Complete Article Headers
Newsgroups: alt.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!fuw.edu.pl!cocos!jt From: jt@fuw.edu.pl (Jerzy Tarasiuk) Subject: Re: How to get keys from keyboard without removing them In-Reply-To: FREE1178@vmd.cso.uiuc.edu's message of Thu, 1 Oct 1992 01:50:23 GMT Message-ID: <JT.92Oct5183556@fizyk1.fuw.edu.pl> Sender: news@fuw.edu.pl Nntp-Posting-Host: fizyk1 Organization: Warsaw University Physics Dept. References: <168721250F.FREE1178@vmd.cso.uiuc.edu> Date: Mon, 5 Oct 1992 17:35:56 GMT Lines: 22