Page 1 of 1

Sleeping in real-mode

Posted: Sun Jul 01, 2012 3:12 pm
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

Re: Sleeping in real-mode

Posted: Sun Jul 01, 2012 10:14 pm
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".

Re: Sleeping in real-mode

Posted: Mon Jul 02, 2012 8:51 am
by evoex
Perfect, thank you!

Re: Sleeping in real-mode

Posted: Mon Jul 02, 2012 11:04 am
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

Re: Sleeping in real-mode

Posted: Mon Jul 02, 2012 3:27 pm
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!