Hardware Interrupts and TSR programs
The keyboard buffer
Keyboard Buffer
• Keyboard Buffer is located in BIOS Data Area.
• Starts at 40: IEH
• Ends at 40 : 3DH
• Has 32 byes of memory 2 bytes for each
character.
• Head pointer is located at address 40 : 1A to
40:IBH
• Tail pointer located at address 40 : IC to 40:IDH
The keyboard buffer is a memory area reserved in the BIOS data area. This area stores the
ASCII or special key codes pressed from the keyboard. It works as a circular buffer and
two bytes are reserved for each character, moreover 2 bytes are used to store a single
character. The first character stores the ASCII code and the second byte stores 0 in case
an ASCII key is pressed. In case a extended key like F1- F12 or arrow key is pressed the
first byte stores a 0 indicating a extended key and the second byte stores its extended key
code.
Circular buffer
40:1AH
40:1CH
40:1EH
Head Tail
40:3DH
The circular keyboard buffer starts at the address 40:1EH and contains 32 bytes. The
address 40:1AH stores the head of this circular buffer while the address 40:1CH stores the
tail of this buffer. If the buffer is empty the head and tail points at the same location as
shown in the diagram above.
Storing characters in the keyboard buffer
83
0
0
‘B’
0’
‘A’
0x20
0x21
0x22
0x23
Head = 0x24
0x1E
Tail
The above slide shows how characters are stored in the buffer. If ‘A; is to be stored then
the first byte in the buffer will store its ASCII code and the second will store 0, and if
extended key like DEL is to be stored the first byte will store 0 and the second byte will
store its scan code i.e. 83. The diagram also shows that head points to the next byte where
the next input character can be stored. Also notice that head contain the offset from the
address 40:00H and not from address 40:1EH. i.e. it contain 0x24 which is the address of
the next byte to be stored relative to the start of BIOS data area and not the keyboard
buffer.
No comments:
Post a Comment