Page 1 of 1

Bare Bones - hlt instruction inside or outside the for loop

Posted: Sun Jan 20, 2013 12:12 am
by gsingh2011
In the bare bones tutorial, this code executes if the kernel returns

Code: Select all

    cli
.hang:
    hlt                                 ; halt machine should kernel return
    jmp  .hang
If I understand correctly, the only way for the CPU to get out of the halt state is if there is an interrupt. But since we've disabled interrupts that can't happen. So is the above code the same as moving the hlt outside the loop?

Re: Bare Bones - hlt instruction inside or outside the for l

Posted: Sun Jan 20, 2013 12:44 am
by trinopoty
The hlt is in the loop just in case the hlt fails to execute for some unknown reason.

Re: Bare Bones - hlt instruction inside or outside the for l

Posted: Sun Jan 20, 2013 1:14 am
by AJ
And ic case of a NMI.

Cheers,
Adam