I converted to 32bit using the tutorial, (copied
exactly, then I wanted to do something on my own, so I decided to make the OS print whatever was typed in the keyboard. This is the code that I used:
keyPress:
WaitLoop: in al, 64h
and al, 10b
jz WaitLoop
in al, 60h
mov bl,al
call Putch32
jmp keyPress
(Even part of this code is copied), I am using Bochs emulator, and it does nothing when I press the keys. (I included stdio.inc)
Keyboard problem
Moderator:Moderators
Help Me!!
SOS!!
SOS!!
For the most part you got it right. A problem is this:
You are masking bit 1 (input buffer full) rather then bit 0 (output buffer full) of the status register. You want to test the output buffer.
Try this:
You should also take note that this will not return a character but rather a scan code. For every character pressed, you will receive two scan codes: one for pressing the key, and one for releasing it.
To get the ASCII character, you would need to convert these scan codes. This is useually done with a lookup table.
This contains the scan codes. So, if the return value is 0x1e, it is ascii 'a'. If its 0x30, the ascii character is 'b', and so on...
---
Also, just to add, most keyboard drivers work by hooking an interrupt handler to ISR 1. This is usually a nicer method then polling the keyboard controller but requires the IDT and PIC properly set up.
Code: Select all
WaitLoop: in al, 64h
and al, 10b
jz WaitLoop
Try this:
Code: Select all
keyPress:
WaitLoop: in al, 64h
and al, 1
jz WaitLoop
in al, 60h
mov bl,al
call Putch32
jmp keyPress
To get the ASCII character, you would need to convert these scan codes. This is useually done with a lookup table.
This contains the scan codes. So, if the return value is 0x1e, it is ascii 'a'. If its 0x30, the ascii character is 'b', and so on...
---
Also, just to add, most keyboard drivers work by hooking an interrupt handler to ISR 1. This is usually a nicer method then polling the keyboard controller but requires the IDT and PIC properly set up.