port 60

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

port 60

Post 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
Matías Beretta
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post 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).
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

Post by matias_beretta »

can you explain me how to setup an IRQ in real mode??
Matías Beretta
quartsize
Posts: 8
Joined: Mon Sep 24, 2007 1:23 pm

Post 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).
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

so...

Post 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?????
Matías Beretta
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post 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.
1234
Posts: 24
Joined: Sat May 26, 2007 7:58 pm

Post by 1234 »

[post deleted]
Last edited by 1234 on Tue Jan 27, 2009 3:23 pm, edited 2 times in total.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

You do know that your shameless self-promotion is getting rather annoying right? ;)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: port 60

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply