First of all, I'm new to the forum so hi all!
I'm currently trying to develop a very simple, real mode os (monotasking, like dos). My problem is that I only find tutors for pmode and nothing for real mode. Here's my question: I've found a very simple bootloader that loads my kernel in 1000:0000 How can i set-up my code,data and stack segments?
(Should i load the base addresses in cs,ds,ss?)
thanks
Need help with real mode segmentation
Need help with real mode segmentation
I need someone to show me the things in life that I cant find
I cant see the things that make true happiness, I must be blind
I cant see the things that make true happiness, I must be blind
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
You should do a search for some information on real mode system architecture (the intel manuals are good for this)... this information does exist, and can be used to differentiate a lot of this pmode discussion from what you want.
I say this, because you seem to be implying that there is some setup involved in defining segments. While this is true in pmode, real mode segments are simply a portion of the full address space, such that:
linear_address = (segment * 16) + segment_offset
Each segment is also fixed at 64k (limited by a 16-bit offset value).
Hopefully that helps,
Jeff
PS: I think anybody that feels the urge to chime in about the realmode idt being a subset of the pmode idt should ignore this urge, as it would just muddy the water, and confuse the issue (IMO, at least...)
I say this, because you seem to be implying that there is some setup involved in defining segments. While this is true in pmode, real mode segments are simply a portion of the full address space, such that:
linear_address = (segment * 16) + segment_offset
Each segment is also fixed at 64k (limited by a 16-bit offset value).
Hopefully that helps,
Jeff
PS: I think anybody that feels the urge to chime in about the realmode idt being a subset of the pmode idt should ignore this urge, as it would just muddy the water, and confuse the issue (IMO, at least...)
I've been examining the source code of some real mode oses (like MiniDos by Dex), and there is extensive usage of all three segment registers. Eg, every time a function is called, there's a pusha. But to use pusha there also must be a stack segment. So, if I want a 64k stack at 0300:0000 then what must i do, just
mov ss, 0x12C0 ? (seg*16+offset, if i've understood correctly the formula)
is that enough?
Thanks again
mov ss, 0x12C0 ? (seg*16+offset, if i've understood correctly the formula)
is that enough?
Thanks again
I need someone to show me the things in life that I cant find
I cant see the things that make true happiness, I must be blind
I cant see the things that make true happiness, I must be blind
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Generally speaking, without a stack, you cannot call functions... this is a programming fundamental which osdevers should know and understand.
In order to setup a stack in real mode, yes, all you need to do is load the ss register.
The equation is for converting linear addresses (which you would see in a non-segmented platform) to segmented addresses (and back again). You syntax of 0300:0000 *is* segmented (this syntax generally means segment:offset). As such, you'd simply load ss with 300.
The equation is there so that one understands that 0300:0000 is actually referencing the linear address 300*16+0 = 3000 (I'm assuming 0300 is hex).
--Jeff
In order to setup a stack in real mode, yes, all you need to do is load the ss register.
The equation is for converting linear addresses (which you would see in a non-segmented platform) to segmented addresses (and back again). You syntax of 0300:0000 *is* segmented (this syntax generally means segment:offset). As such, you'd simply load ss with 300.
The equation is there so that one understands that 0300:0000 is actually referencing the linear address 300*16+0 = 3000 (I'm assuming 0300 is hex).
--Jeff