TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: TIM HUTZLER
from: BALOG PAL
date: 1997-04-18 23:20:00
subject: Above 1M (w:FS and GS registers)

                              Hi, Tim Hutzler!
On 15 Apr 97  08:27:00 you wrote to Balog Pal
 TH> So, how are segments above 1-meg addressed?
Just like any other segment: load its selector to a segreg, and use. :)
You probably want to ask how to access memory above 1M?
Well, you have 2 options: go to protected mode (the preferred option) or
extend the segment limits remaining in real mode (AKA unreal mode).
In protected mode the proc uses its native addressing mode, not the 8086
compatible stuff. You use descriptor tables where your segments are
specified. A descriptor is a data structure with fielsd like the segment base
address (in linear space), segment length (may be several gigabytes),
read/write/execute permission, level of access, default register size (16/32
bits), and some other specials. Eg you set up e descriptor that 's base is at
1M and limit is another 1M. Or set up other to start at 0 and be 4 gigs long.
Then to use it, you load secector to the segment register. The selector is a
pointer to the descriptor table. (The descriptor tables' base address is
loaded into GDT, LDT, IDT registers beforehand.)  Then the proc loads the
descriptor data into (hidden) segment descriptor cache registers, and you can
use it. Certainly upon the load a plenty of checks are made to determne
you're allowed to use that selector or not.  If you could load the selector
upon accessing memory other checks come to see you're in-limits, and and do
the allowed operation, ie do not write to a read-only seg or so.
Certainly switching to protmode will render your regular dos and bios
unusable, including all the software and hardware interrupts. So you must
write or the handles youself, or use a PM host to provide that functionality.
Such a host is Windows, for example (way good to practice with PM), but
there're simpler ones, like dos4gw, borland's tkernel, and even good packages
availagle in source like code32, pmode.
Unreal mode uses the undocumented, but existing behavior of the sd cache
registers. A little proggy switches to protmode for a short moment, loads all
the segregs with descriptors set to maximum limits (default limit is 64k) and
instantly switch back to real mode.   After that you can address the whole
memory space from real mode. As you probably know, you can do a
mov ax, DS:[EBX]
regularly, but you got an exception if the value in EBX exceed 64k. After the
above trick the limit is widened, so you can use any value.
The drawback is, that switching to/from PM can be made only in real real
mode. But 99+ % of systems today use memory managers (emm386, qemm386, etc,
or win, win95, os/2, etc. There your dos promt runs not in real but in
virtual mode, and you can't use the instructions needed for the operation.
(And even if you could do it, it would crash the memory manager. :)  So
you'll probably not release anything using unreal mode to public. But it can
come handy for some things you want to do on your own machine.
Paul
... Do NOT look into laser with remaining eyeball
--- OS/2 Warp
---------------
* Origin: The FlintStones' Cave in BedRock (2:371/20)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.