Is it possible to using 4GB ram in real mode through enabling A20, without switching to protect mode, and without loosing BIOS interrupts?
Asked
Active
Viewed 1,011 times
3
-
1See [unreal mode](https://en.wikipedia.org/wiki/Unreal_mode) – Jester Sep 27 '15 at 11:00
-
Loosing (losing?) BIOS interrupts? – Ross Ridge Sep 28 '15 at 02:45
-
I think "... without loosing the possibility to call BIOS functions ..." was meant. – Martin Rosenau Sep 28 '15 at 15:18
1 Answers
7
You can do this by using Unreal Mode. This mode loads one or more of the segment registers with a selector that has a limit of 4 GB. There are two forms of this mode, Big Unreal Mode and Huge Unreal Mode. The former allows accessing data above 1 MB, and the latter allows code and data above 1 MB. Huge Unreal Mode is difficult to set up, though, because real mode interrupts only preserve the low 16 bits of EIP
. See this page for more information.
You also may want to get a memory map from the BIOS if possible, since some memory is memory mapped to certain hardware, and cannot be used as normal memory. See this page for more information.

owacoder
- 4,815
- 20
- 47
-
Thanks for explanation, and for link. I have one more question. Is it recommend to use unreal mode, or would it better to try set up Protected Mode with own interrupts etc. – vakus Sep 27 '15 at 15:14
-
In the 16 bit Big-Real-Mode it is possible to use most the bios software interrupts und it is possible for to address 4 GiB, but not the entire address space is free to use and some of the addresses contains the linear framebuffer, memory mapped IO devices and read only memory with bios routines from the mainboard and the display device and other devices. – Dirk Wolfgang Glomp Sep 27 '15 at 18:00
-
@vakus - it depends. If you need to use BIOS functions and all the memory you can, use Unreal mode. Otherwise, it's probably better to use protected mode, since you can do more with it. (Custom interrupts, task scheduling, etc.) – owacoder Sep 27 '15 at 19:50
-
I myself am working on a little OS (for 2 years now). I'm using "virtual mode" to be able to access BIOS interrupts. In "virtual mode" most instructions behave like in real mode however about 30 instructions will cause an interrupt which has to emulate these instructions. Hardware interrupts also call a protected-mode interrupt routine which must then emulate a real-mode interrupt. All of this was about 2 days of work. The advantage is that you can real 32-bit code and you can use paging while in unreal mode many things are limited to the low memory (code, rep movsb, ...) – Martin Rosenau Sep 27 '15 at 19:53
-
@MartinRosenau - Yes, V86 mode is available for use, and is probably easier to access from protected mode, but the OP specifically asked about real mode. And unreal mode is easier to access from real mode than V86 mode. – owacoder Sep 27 '15 at 19:57
-
This is correct. But I understood one of the comments in a way that the user wanted to know if there is the possibility to fully use all memory and being able to call BIOS functions the same time. Virtual mode would be that possibility. Windows 3.1x used this approach and when using the EMM386 memory driver MS-DOS was even running in virtual mode all the time... – Martin Rosenau Sep 27 '15 at 20:04
-
Just wanted to add to @MartinRosenau 's comment that most of the instructions which are limited to 16 bit registers in unreal mode can be modified to use their 32 bit counter parts using the a32 prefix (opcode 0x66 / 0x67), e.g. rep a32 movsb to use edi or a32 loop label to use ecx. – Orby Jun 13 '16 at 14:44