Page 1 of 1
port 60
Posted: Sun Sep 30, 2007 6:33 am
by matias_beretta
hello, i am writing a real mode os and my objective is to stop using bios. Currently I'm writing a ReadKey function:
Questions
-----------
1) How can I see if there are no keys pressed ??
2) How can I make a sleep procedure (maybe be with a for??)?, because when I press a key lots of chars appear on screen...
thanks
Posted: Sun Sep 30, 2007 7:01 am
by bluecode
The 0th bit of port 0x64 tells you whether there is a byte from the keyboard (then bit0 is set to 1) or there is none (bit0 is 0).
edit: But normally you would use interrupts (irq1 in this case).
Posted: Sun Sep 30, 2007 7:04 am
by matias_beretta
can you explain me how to setup an IRQ in real mode??
Posted: Sun Sep 30, 2007 7:08 am
by quartsize
You'll want to make a modification to the Interrupt Vector Table, pointing it to your IRQ handler.
Note that IRQs don't correspond directly to interrupts, so you'll need to note where they are mapped by the PICs (whether you go with the default or remap them yourself).
so...
Posted: Sun Sep 30, 2007 7:19 am
by matias_beretta
I heard that the keyboard interrupts is 9h so
;;;;;;;
push 0
pop es
mov word [es:36], handler
mov [es:38], cs
jmp $
handler:
in al, 96
iret
;;;;;;;
so each time i press any key, the scan code will be in AL?????
Posted: Sun Sep 30, 2007 1:09 pm
by Dex
try in al,60h and do not forget to signal end of IRQ, unless you save old vector address and call it inside the "handler" function.
Posted: Sun Sep 30, 2007 3:03 pm
by 1234
[post deleted]
Posted: Sun Sep 30, 2007 3:31 pm
by Brynet-Inc
You do know that your shameless self-promotion is getting rather annoying right?
Re: port 60
Posted: Sun Sep 30, 2007 3:42 pm
by Combuster
@mikegonta:
mikegonta wrote:matias_beretta wrote:hello, i am writing a real mode os and my objective is to stop using bios.
Then stop using real mode.
Bulls**t. You can theoretically use any style of device accesses with any operating mode.
mikegonta wrote:matias_beretta wrote:How can I see if there are no keys pressed ??
Here is a simple example of "hooking" the keyboard int.
(...)
the following assembled binary requires aeBIOS
That's advertising and not at all helpful for solving the problem.
@matias_beretta: if you would please refrain from asking the same question
twice in
different threads, we do not get the impression that you are elegible to an answer, which truthfully, you aren't.
Back to the original questions:
1) Keep track of all presses and releases, and you should be able to tell when there's no key left pressed.
2) use the keyboard's IRQ to tell when a key event has actually happened instead of reporting the same event over and over. If you want to build a sleep timer, consider using the PIT.