Sleeping in real-mode

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
evoex
Member
Member
Posts: 103
Joined: Tue Dec 13, 2011 4:11 pm

Sleeping in real-mode

Post by evoex »

Hello everybody,

I'm working on a boot sector, related to the "512 byte challenge" as posted here: http://forum.osdev.org/viewtopic.php?f=1&t=25492

For that I wondered if I could code snake in 512 bytes, so I went ahead to work on that. But now I need to sleep for some interval. I found an interrupt providing a timer that ticks at approximately 18.2 Hz, but I need something more accurate. Is there any way provided by the BIOS to sleep, or to retrieve the approximate time in milliseconds?
Worst case I'll run the same instruction(s) for a larger number of times, but I'd rather have a better solution.

Any ideas?


Thanks in advance
linguofreak
Member
Member
Posts: 510
Joined: Wed Mar 09, 2011 3:55 am

Re: Sleeping in real-mode

Post by linguofreak »

The PIT can be reprogrammed to generate interrupts at higher frequencies than 18 Hz (in fact, 18 Hz is its lowest frequency).

You can find more information on this by searching the Wiki for "PIT".
evoex
Member
Member
Posts: 103
Joined: Tue Dec 13, 2011 4:11 pm

Re: Sleeping in real-mode

Post by evoex »

Perfect, thank you!
User avatar
XanClic
Member
Member
Posts: 138
Joined: Wed Feb 13, 2008 9:38 am

Re: Sleeping in real-mode

Post by XanClic »

Since you are most probably looking for something consuming as little space as possible, I guess you might be interested in the BIOS wait call (theoretically providing microsecond resolution): http://www.ctyme.com/intr/rb-1525.htm
evoex
Member
Member
Posts: 103
Joined: Tue Dec 13, 2011 4:11 pm

Re: Sleeping in real-mode

Post by evoex »

XanClic wrote:Since you are most probably looking for something consuming as little space as possible, I guess you might be interested in the BIOS wait call (theoretically providing microsecond resolution): http://www.ctyme.com/intr/rb-1525.htm
Even easier! Thank you, both!
Post Reply