Page 1 of 1

realmode - ram - a20

Posted: Sat Jun 29, 2002 11:00 pm
by asdf
currently i am developing an multi-step boot loader.
i want to mov a kernel above 1MB physical memory.
i think i have successfully done the a20 sh**, cuz moving data to FFFFh:0 does NOT accur at 0:0 anymore...
but when i want to write data in realmode above 1MB my bootloader hangs.
how much mem can i access in realmode after enabling a20??? 4 gig? or 4gig only after pmode switch??
any ideas?

RE:realmode - ram - a20

Posted: Sat Jun 29, 2002 11:00 pm
by carbonBased
Real mode uses a 16-bit segment, and a 16-bit offset.  Essentially that's a 32-bit address... but... the segments occur every 16 bytes.  If they occured every 64k, _then_ you could access the full 4GB.

Unfortunately, because of that 16 byte limitation, real mode addresses are, effectively, only 20 bits long, which makes the topmost address you can access _exactly_ 1MB.

In other words, you can't access above 1MB in real mode, even with a20 enabled.  You'll have to enter pmode or unreal mode (probably easier, if you're using bios calls).

Jeff

RE:realmode - ram - a20

Posted: Sat Jun 29, 2002 11:00 pm
by geezer
In true real mode, GPF will occur if the offset part of the address is > 0FFFFh, e.g. because of code like this:

mov ax,0
mov es,ax
mov byte [es:dword 0B8000h],21h

Switch the processor to unreal mode if you really want to do this.

DOS 7 will silently and automatically load HIMEM.SYS, then load itself into the high memory area (the first 64K of XMS). HIMEM.SYS will also use an additional 4K of XMS for itself.

If HIMEM.SYS is loaded, use it's XMS services to copy stuff to extended memory. Otherwise, use INT 15h AH=87h. Use a "raw" method such as unreal mode only as a last resort.