So I'm learning how to make an OS. The problem is that every website says to scan the keyboard to obtain the scancodes in order to detect input. How do I 'scan' the keyboard? I know this question seems very ridiculous, but I really don't know how to do that, and I need help. I also have to mention that I googled it a lot.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Example for polling the keyboard port without using an ISR (x86-CPU):
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)
Within an ISR simple use "in al, 60h" for to get the scancode.