Default x86 register values

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
watermirror
Member
Member
Posts: 25
Joined: Tue Nov 05, 2013 4:06 am

Default x86 register values

Post by watermirror »

hi, how could i know the default value of all the registers's default value on power on of intel's x86 cpu?
i can only find the idtr, gdtr on the manaual.
i aslo want to know cs,ds...
embryo

Re: the default value of intel x86 register.

Post by embryo »

watermirror wrote:hi, how could i know the default value of all the registers's default value on power on of intel's x86 cpu?
i can only find the idtr, gdtr on the manaual.
i aslo want to know cs,ds...
You should read CHAPTER 9 PROCESSOR MANAGEMENT AND INITIALIZATION from Intel® 64 and IA-32 Architectures
Software Developer’s Manual Volume 3.
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Default x86 register values

Post by sortie »

You don't care what the default x86 values are - just after boot - because you are not the firmware. I suspect all the registers will be zeroed or something, at best, or perhaps just be trash. What you actually want do know is whether the registers are initialized when you get control. If you write a MBR boot sector, you'll want to know what the BIOS does (it does use some of the registers for particular purposes). If you are writing a multiboot kernel you'll want to read the multiboot specification.

My point is that you should look at the specification or documentation for whatever boots you. What boots your code?
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Default x86 register values

Post by Gigasoft »

sortie wrote:You don't care what the default x86 values are - just after boot - because you are not the firmware. I suspect all the registers will be zeroed or something, at best, or perhaps just be trash. What you actually want do know is whether the registers are initialized when you get control. If you write a MBR boot sector, you'll want to know what the BIOS does (it does use some of the registers for particular purposes).
Now you are assuming a whole bunch of things that the OP didn't state. Assuming facts that directly contradict the very question that was asked seldom produces a meaningful conclusion. One would have to suppose that if someone didn't care about something, they wouldn't be asking about it.

And yes, most registers have well defined values on reset. EDX will identify the processor model, EAX will be zero if the BIST succeeded, and most other registers are zeroed. CS is F000h with a base of FFFF0000h, all other segment register values and bases are 0, all limits are FFFFh, all segment flags are present, r/w, accessed.
dlarudgus20
Member
Member
Posts: 36
Joined: Sat Oct 26, 2013 4:14 am

Re: Default x86 register values

Post by dlarudgus20 »

Just one - why do you want to know? Is there any case which requires this knowledge, or just curiosity?
Last edited by dlarudgus20 on Tue Jun 10, 2014 4:40 am, edited 1 time in total.
dlarudgus20
Member
Member
Posts: 36
Joined: Sat Oct 26, 2013 4:14 am

Re: Default x86 register values

Post by dlarudgus20 »

Gigasoft wrote: And yes, most registers have well defined values on reset. EDX will identify the processor model, EAX will be zero if the BIST succeeded, and most other registers are zeroed. CS is F000h with a base of FFFF0000h, all other segment register values and bases are 0, all limits are FFFFh, all segment flags are present, r/w, accessed.
Wow, it's surprising...

Btw, "segment flags"? Is there anything like that in real mode, in which processor starts up?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Default x86 register values

Post by Combuster »

dlarudgus20 wrote:Btw, "segment flags"? Is there anything like that in real mode
Certainly. See the Descriptor Cache
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
dlarudgus20
Member
Member
Posts: 36
Joined: Sat Oct 26, 2013 4:14 am

Re: Default x86 register values

Post by dlarudgus20 »

Combuster wrote:
dlarudgus20 wrote:Btw, "segment flags"? Is there anything like that in real mode
Certainly. See the Descriptor Cache
Wow..
Post Reply