Clearing the keyboard buffer principle

Publisher:浊酒Latest update time:2012-04-16 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Sometimes a user's keystroke response may cause data to be lost or corrupted beyond repair. In this case, clearing the buffer can eliminate inappropriate or accidental keystrokes that may be waiting in the buffer for processing or may issue an incorrect response. In other cases, clearing the buffer is not a good idea because it will damage the lookahead feature. Keyboard macros can no longer be used. The buffer can store 15 keystroke codes, providing two bytes in the memory for each keystroke code. Including conversion codes, single-byte ASCII codes, and double-byte extended codes.
For single-byte codes, the first byte stores the ASCII code and the second byte stores the scan code; for extended codes, the first byte stores ASCII 0, and the second byte usually stores the scan code of the extended code. But this is not absolute because the function key and the shift key can generate an extended code when combined.
The keyboard buffer is designed as a circular queue, called a first-in-first-out (FIFO) algorithm buffer. In fact, two pointer tracking counters record the "head" and "tail" of the code string currently in the buffer.
The keyboard buffer is located in the BIOS data area, and the starting address of the BIOS data area is: 0040:2000.
32-byte buffer: 0040:001E start
Head pointer: 0040:001A
Tail pointer: 0040:001C
Interrupt 21h Function 6 sub-function FFh returns the key-in code. If there is no valid code, it will not wait. When there is no key-in code, set the 0 flag. Keep calling interrupts until no key-in code is returned.
P223 Example 8-1 Clear the keyboard buffer
KEY-FOUND:
MOV AH, 6h
MOV DL, 0FFh
INT 21h
JNZ KEY-FOUND
Reference address:Clearing the keyboard buffer principle

Previous article:Keyboard application design
Next article:Classification and working principle of printers

Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号