Real Mode Memory Addressing

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
jtokarchuk
Member
Member
Posts: 26
Joined: Fri Oct 14, 2011 4:32 pm

Real Mode Memory Addressing

Post by jtokarchuk »

Hello there. I have what hopes to be a somewhat simple question.

In real mode, the Kernel is limited to 64k, correct? That beig said, if I write a memory manager, am I able to use multiple segments for one program? Say 256k, or am I limited to 64k in a program as well.

I am not wanting to be spoonfed, I have done a lot of googling and haven't come up with much. point in the right direction is all I ask.

Thanks.
rdos
Member
Member
Posts: 3308
Joined: Wed Oct 01, 2008 1:55 pm

Re: Real Mode Memory Addressing

Post by rdos »

No single segment can be larger than 64k in real-mode, but it doesn't mean that kernels or programs are confined to 64k. There are various memory models that deals with this problem: compact (single code, many data), medium (single data, many code) and large (many code, many data).
jtokarchuk
Member
Member
Posts: 26
Joined: Fri Oct 14, 2011 4:32 pm

Re: Real Mode Memory Addressing

Post by jtokarchuk »

Thank you for the reply. I have somewhere to look now!
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: Real Mode Memory Addressing

Post by Combuster »

No single segment can be larger than 64k in real-mode
Lies!
"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 ]
rdos
Member
Member
Posts: 3308
Joined: Wed Oct 01, 2008 1:55 pm

Re: Real Mode Memory Addressing

Post by rdos »

Combuster wrote:
No single segment can be larger than 64k in real-mode
Lies!
That's unreal mode. :mrgreen:

But you are right. If you switch to protected mode and back to real mode, you could enable larger segments (with 32-bit addressing!). However, without that, it is not possible.
jtokarchuk
Member
Member
Posts: 26
Joined: Fri Oct 14, 2011 4:32 pm

Re: Real Mode Memory Addressing

Post by jtokarchuk »

I was considering this. In my research, I see that the "code" segment is limited to 64k, can someone expand on this? Does this mean that the kernel is limited to 64k unless you use your own memory model?
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: Real Mode Memory Addressing

Post by Combuster »

Define "your own"

You can do all program calls by default as near calls, or you can do them by default as far calls. Using the first method exclusively gives you a 64k code max. The second form gives you a code size limited to 1MB, but is slower. The same goes for data references which can be 16-bit with a fixed segment register value, or 32-bit seg:off pointers.

If the compiler supports memory models, you can tell it which choices to make on these matters. There's nothing new here.
"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 ]
jtokarchuk
Member
Member
Posts: 26
Joined: Fri Oct 14, 2011 4:32 pm

Re: Real Mode Memory Addressing

Post by jtokarchuk »

Excellent. Thanks for the quick responses, it is appreciated.
Post Reply