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.
In the OSDev Wiki Page for the PIT, the code for the "TimerIRQ" part appears to be invalid. When I tried compiling it in nasm (to see it in the more familiar GAS syntax), it gives an error about the line:
There are other problems besides typos. The sleep function doesn't need to disable interrupts, and should use HLT or yield for other tasks to run instead of that incredibly wasteful NOP loop. (I'd argue it shouldn't be written in assembly in the first place - using assembly makes it more difficult to understand what the code is doing.)
Octocontrabass wrote:It's a typo. It's supposed to be "or eax, eax".
There are other problems besides typos. The sleep function doesn't need to disable interrupts, and should use HLT or yield for other tasks to run instead of that incredibly wasteful NOP loop. (I'd argue it shouldn't be written in assembly in the first place - using assembly makes it more difficult to understand what the code is doing.)
Alright, I'll see if it works.
I agree, however it being written in assembly does make it fast. Also I replaced the nops with the io wait assembly example (basically just send a 0 to io port 0x80 to waste a few microseconds)