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
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
Previous article:Keyboard application design
Next article:Classification and working principle of printers
- Popular Resources
- Popular amplifiers
Latest Analog Electronics Articles
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Zigbee protocol stack learning serial port transparent transmission experiment (SerialApp) process analysis
- STM32 boot mode configuration and application
- Ethernet PHY chip LAN8720 usage issues
- The number series problem from "Bible Code" and the python solution
- Live broadcast at 10:30 this morning [Microchip Security Solutions | Wi-Fi Security for Enterprises]
- TI's board has arrived
- Motor stroboscope test
- Tektronix benefits are coming: no more helpless in testing expensive power supplies!
- EEWORLD University Hall----Intel FPGA 2019 Engineer Application Video
- Which is better, UHF wireless microphone or 2.4g wireless microphone?