V22.0201, Machine Organization I, Yap: Notes on Keyboard

####
V22.0201.002, Machine Organization I
Fall 1997

###
NOTES ON KEYBOARD

This supplements the notes in chap.12 of textbook.

### INTRODUCTION

- INT 16h is used for keyboard interrupts.
- Read up about the keyboard buffer in text book.
- Addresses of the keyboard buffer (from Abel, p.198)

      	ADDRESS		EXPLANATION
      	41Ah		Address of the current head of the buffer
      			(the next position for INT 16h to read a char)
      	41Ch		Address of the current tail of buffer
      			(the next position for INT 16h to store a char)
      	41Eh		Address of the beginning of the keyboard buffer.
      			The buffer contains 16 words (32 bytes), but
      			can be longer.

  The buffer is empty when the head and tail of buffer coincide. Note we have 16 words in the buffer, but only 15 type ahead characters are allowed. This is because if we have 16 words, then we cannot distinguish between buffer full and buffer empty!

### KEYBOARD INTERRUPT FUNCTIONS

SUMMARY OF INT 16h FUNCTIONS
Function Number (in reg AH) | Actions
--- | ---
fcn=00h: wait for keypress and read char | OUTPUT: AH=scan code, AL=ascii character or 0 in non-ascii. Program is halted until a key with scancode is pressed.
fcn=01h: get keyboard status | OUTPUT: ZF=0 if a key is pressed, even CTRL-BREAK AX=0 if no scan code available AH:AL=scan code:ascii char (as in fcn=00) NOTE: data is not removed from buffer. CTRL-BREAK places a zero word in the keyboard buffer and registers a keypress.
fcn=02h: read keyboard flags | OUTPUT: AL=BIOS keyboard flags (in BIOS area 40:17) AL[7]=insert is active AL[6]=caps-lock is active AL[5]=num-lock is active AL[4]=scroll-lock is active AL[3]=ALT key is pressed AL[2]=CTRL key is pressed AL[1]=left shift key is pressed AL[0]=right shift key is pressed
fcn=03h: set keyboard typematic rate | INPUT: AL=set rate, BH=repeat delay, BL=typematic rate. OUTPUT: none. See helppc for details.
fcn=05: keyboard buffer write | Available on AT, PS/2 with extended keyboard support.

GO TO THE TOP