tags:

views:

112

answers:

7

Hi,

This is a low level question. For a little bit of context, I'm working on a boot loader on an x86 machine.

When the BIOS copies the contents of the MBR to 0x7c00 and jumps to that address, is there a standard meaning to the contents of the registers? Do the registers have standard values?

I know that the segment registers are typically set to 0, but will sometimes be 0x7c0. What about the other hardware registers?

Thanks,

Terry

+1  A: 

Best option would be to assume nothing. If they have meaning, you will find that from the other side when you need the information they provide.

BCS
+1  A: 

Undefined, I believe? I think it depends on the mainboard and CPU, and should be treated as random for your own good.

wvdschel
+7  A: 

This early execution environment is highly implementation defined, meaning the implementation of your particular BIOS. Never make any assumptions on the contents of registers. They might be initialized to 0, but they might contain a random value just as well.

from the OS dev Wiki, which is where I get information when I'm playing with my toy OS's

sparkes
+1  A: 

You can always initialize them yourself to start with a known state.

MSN

Mat Noguchi
+1  A: 

Safest bet is to assume undefined.

Bernard
+1  A: 

The only thing that I know to be well defined is the processor state immediately after reset.

For the record you can find that in Intel's Software Developer's Manual Vol 3 chapter 8: "PROCESSOR MANAGEMENT AND INITIALIZATION" in the table titled " IA-32 Processor States Following Power-up, Reset, or INIT"

Nathan Fellman
+1  A: 

Always assume undefined, otherwise you'll hit bad problems if you ever try to port architectures.

There is nothing quite like the pain of porting code that assumes everything uninitialized will be set to zero.

engtech