i got one question more.
let say i already wrote my small OS
after the BIOS read my 512 bytes file at 7c00h
i want it to DO NOTHING. just stop that
if i write
loopagain:
jmp loopagain
it will use 100% CPU Usage....
any idea just make the computer to stay there and don't move after it print my welcome message "Welcome to Hello World! Operating System" any without using any CPU resource (coz it does nothing after printed out the welcome text).
any INTERRUPT that will just make the CPU HALTED or IDLE(DO NOTHING).
any idea to know the CPU state, eg if it is IDLE?, BUSY?, WAITING? or whatsoever?
How to ask my OS to "DO NOTHING"
Re:How to ask my OS to "DO NOTHING"
Try adding a halt instruction into the do-nothing loop:
The HLT (halt) instruction forces the CPU to idle until the next interrupt occurs; by looping on that, it ensures that it will continue to pause even after any interrupts. This is also how most null processes work.
BTW, the SHORT specifier isn't really necessary here, as NASM defaults to short jumps if the target is within 127 addresses, but I prefer to state it explicitly.
Code: Select all
spin: hlt
jmp short spin
BTW, the SHORT specifier isn't really necessary here, as NASM defaults to short jumps if the target is within 127 addresses, but I prefer to state it explicitly.