Bare Bones - hlt instruction inside or outside the for loop

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
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Bare Bones - hlt instruction inside or outside the for loop

Post 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?
User avatar
trinopoty
Member
Member
Posts: 87
Joined: Wed Feb 09, 2011 2:21 am
Location: Raipur, India

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

Post by trinopoty »

The hlt is in the loop just in case the hlt fails to execute for some unknown reason.
Always give a difficult task to a lazy person. He will find an easy way to do it.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

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

Post by AJ »

And ic case of a NMI.

Cheers,
Adam
Post Reply