Segment registers (including CS) have both a visible and a hidden part. The visible part is what you write to/read from. The hidden part contains the base address of the segment, its limit and privilege levels. In real mode when you write to the visible part, it fills the hidden part with base = value * 0x10, limit = 0xffff. In protected mode, it gets these values from the GDT/LDT. This has the side effect of meaning the hidden parts are not updated if you change the GDT without also reloading the segment register.
When a (>= 80386) cpu starts, it sets the various parts of CS specially - the visible part reads 0xf000, but the base address in the hidden part is 0xffff0000. This is not something you can do programmatically from within real mode, and the next time CS is loaded then it will use the normal real mode rules. If you dump the value of CS from within bochs however, you will get the visible part, which is 0xf0000.
Regards,
John.
OS program execution in depth.
- BASICFreak
- Member
- Posts: 284
- Joined: Fri Jan 16, 2009 8:34 pm
- Location: Louisiana, USA
Re: OS program execution in depth.
Ok, that makes sense - guess I should read the manual more (way too long to read it all, I only read the parts I need when I need them...)jnc100 wrote:Segment registers (including CS) have both a visible and a hidden part. The visible part is what you write to/read from. The hidden part contains the base address of the segment, its limit and privilege levels. In real mode when you write to the visible part, it fills the hidden part with base = value * 0x10, limit = 0xffff. In protected mode, it gets these values from the GDT/LDT. This has the side effect of meaning the hidden parts are not updated if you change the GDT without also reloading the segment register.
When a (>= 80386) cpu starts, it sets the various parts of CS specially - the visible part reads 0xf000, but the base address in the hidden part is 0xffff0000. This is not something you can do programmatically from within real mode, and the next time CS is loaded then it will use the normal real mode rules. If you dump the value of CS from within bochs however, you will get the visible part, which is 0xf0000.
Regards,
John.
Thanks for the detailed explanation.
@OP: sorry to derail your topic, I couldn't help myself (but just maybe it was on topic just enough to be helpful to you and others )
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
BOS Expanded Commentary
Both under active development!
Sortie wrote:
- Don't play the role of an operating systems developer, be one.
- Be truly afraid of undefined [behavior].
- Your operating system should be itself, not fight what it is.