Bootloader instructions help
Moderator:Moderators
-
- Posts:18
- Joined:Tue Feb 01, 2011 6:25 pm
Hello i don't understand why we need to disable interrupts(with cli), i thought using hlt(to halt the cpu would be enough). In addition why do we need to null ds and es?
-
- Posts:92
- Joined:Thu May 27, 2010 8:54 pm
- Location:Netherlands
Re: Bootloader instructions help
hlt halts the processor until the next interruptafdgdhfrtewdszs wrote:Hello i don't understand why we need to disable interrupts(with cli), i thought using hlt(to halt the cpu would be enough). In addition why do we need to null ds and es?
See why we need to disable interrupts? If we wouldn't use cli, then the cpu would continue running after the next interrupt, which could be anything.
On the question of nulling ds and es, could you post the relevent code where this happens? It's a little hard to explain various cases without the proper context.
-
- Posts:18
- Joined:Tue Feb 01, 2011 6:25 pm
Re: Bootloader instructions help
Thanks for your help, here is the code:
xor ax, ax
mov ds, ax
mov es, ax
xor ax, ax
mov ds, ax
mov es, ax
Re: Bootloader instructions help
ds and es are used implicitly by several common operations which we would want to perform during boot.In addition why do we need to null ds and es?
In the example given, we are getting our running system into a consistant state. Depending on your nasm settings (the ORG statement), the chances are that your variables will be expecting ds set to 0, and having it non-0 would mean that any data reference you tried to use would be referenced other memory, rather than memory in the 512 bytes loaded by the BIOS.
~Andrew
