所以我在学习如何制作操作系统。问题是,每个网站都说要扫描键盘以获取扫描代码,以便检测输入。我怎么‘扫描’键盘?我知道这个问题看起来很荒谬,但我真的不知道怎么做,我需要帮助。我还必须提到,我在谷歌上搜索了很多次。
发布于 2014-07-28 08:06:24
在不使用ISR (X86CPU)的情况下轮询键盘端口的示例:
cli
mov al, 2 ; dissable IRQ 1
out 21h, al
sti
;---------------------------------------------
AGAIN:
in al, 64h ; get status byte
test al, 1 ; check outputbuffer
jz short NOKEY
test al, 20h ; PS2-Mouse byte?
jnz short NOKEY
in al, 60h ; get scancode (makecode or breakcode)
; place your code here for comparing.....
NOKEY:
jmp AGAIN
;---------------------------------------------
QUIT:
cli
xor al, al ; enable IRQ 1
out 21h, al
sti
;---------------------------------------------
; DATA
TASTTAB DB 02h,03h,04h,05h,06h,07h,08h,09h,0Ah,0Bh,0Ch,0Dh
DB 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Eh,1Fh
DB 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,2Bh,2Ch,2Dh,2Eh,2Fh
DB 30h,31h,32h,33h,34h,35h,39h
DB 56h
tablen = ($-TASTTAB)
TEXTTAB DB "1234567890ß'" ; (using german letters)
DB "qwertzuiopü+as"
DB "dfghjklöä^#yxcv"
DB "bnm,.- "
DB "<"
textablen = ($-TEXTTAB)在ISR中简单地使用"in al,60h“来获取扫描代码。
https://stackoverflow.com/questions/24988886
复制相似问题