R32V2020 PS/2 Keyboard
Revision as of 12:31, 10 April 2022 by Blwikiadmin (talk | contribs) (Created page with "== PS/2 Keyboard == === Two interfaces === * x0800-x0FFF (2KB) - PS/2 Keyboard Data * x1000-x17FF (2KB) - PS/2 Keyboard Status === Keyboard Status === * x01 - Keyboard dat...")
Contents
PS/2 Keyboard
Two interfaces
- x0800-x0FFF (2KB) - PS/2 Keyboard Data
- x1000-x17FF (2KB) - PS/2 Keyboard Status
Keyboard Status
- x01 - Keyboard data present
- x00 - Keyboard data not present
Keyboard Data
- d31..d7 = 0
- d6..d0 - Data from keyboard
Sample Code
Wait for a character from the PS/2 keyboard
; ; waitGetPS2Char ; blocking function - wait for character before returning ; returns character received in r8 ; waitGetPS2Char: push r9 push PAR lix PAR,0x1000 ; PS/2 Status waitPS2RxStat: lpl r9 ; Read Status into r9 and r9,r9,ONE bez waitPS2RxStat getCharFromPS2: lix PAR,0x0800 ; PS/2 keyboard data lpl r8 pull PAR pull r9 pull PC
Get a character from the PS/2 keyboard
; ; getPS2StatusChar - Check the PS/2 receive data ready status bit ; Non-blocking ; return in r8 - MINUS1 means character not present ; Value other than MINUS1 is the character that was received ; getPS2StatusChar: push r9 push PAR lix PAR,0x1000 ; PS/2 Status waitPS2RxStat: lpl r9 ; Read Status into r9 and r9,r9,ONE bez PS2NotReady getCharFromPS2: ; character is present lix PAR,0x0800 ; PS/2 keyboard data lpl r8 bra PS2CharWasPresent ; skip return of MINUS1 PS2NotReady: lix r8,0xffff PS2CharWasPresent: pull PAR pull r9 pull PC