Page 1 of 1

Questions about Unreal Mode.

Posted: Tue Nov 16, 2010 2:53 pm
by mschummi
I want to develop a tiny kernel - actually I want to run an interpreter for a language I've been working on for some time (is something for writting graph optimization algorithms)
But I don't need memory protection and I don't care if all the code is run under ring 0. Besides, it would be easier to have access to BIOS calls.

So, I've read about unreal "mode", and it sounds like a good ideia but I have some questions:
1. All the code I've read set the 4gb limit only for DS and ES segment. Why? That way, code is still limited to 1MB right? Is it ok to set 4gb limit to CS also?
2. In order access 32-bit indexed memory, I've read asm instructions should have a 'a32' preffix, so the processor would use the right operand size. Is there any C compiler that is capable of generating code with this right operand size, when dereferencing 32-bit pointers? (And also able to use 32-bit registers when adding and multipling 32-bit numbers). If it runs on DOS, that would be great.
3. Should I forget about unreal mode, and just use protected mode, using a GDT with a single 4gb segment? (and if I need to use BIOS calls, I just switch back to real mode).

Thanks in advance and sorry about the bad english

Re: Questions about Unreal Mode.

Posted: Tue Nov 16, 2010 3:15 pm
by Combuster
Unreal mode only works for little code and lots of data - you can make CS larger, but the instruction pointer is still 16 bits. Also, the bigger DOS apps already run in 32-bit mode and just pop back to real mode when needing the BIOS. There are some tricks to use GCC for (un)real mode, but it only works reasonably cleanly up to 64kb of code.

Also, what is the reason that you can not just write a regular hosted (DOS-)application?

Re: Questions about Unreal Mode.

Posted: Wed Nov 17, 2010 10:35 pm
by b.zaar
If you're interested in creating apps for DOS in protected mode use DJGPP or a DPMI host. They use 32 bit protected mode with support for DOS and BIOS interrupts.

Re: Questions about Unreal Mode.

Posted: Fri Nov 19, 2010 3:21 pm
by b.zaar
berkus wrote:Don't use DJGPP, if you have to write DOS applications, please use OpenWatcom.
It's been a while since I've done any DOS coding and didn't know about OpenWatcom. Might have to play with it sometime.

Re: Questions about Unreal Mode.

Posted: Fri Nov 19, 2010 4:59 pm
by Combuster
From what I've seen, OpenWatcom is no less buggy than DJGPP, and has a much smaller established user base. It does however provide support for segmentation rather than being restricted to GCC's typical 32-bit code.

But to give DJGPP the blanket accusation of being bad is wrong - it is a perfectly fine DOS compiler. It's just an order of magnitude worse compared to other alternatives for the average (=crosscompiling) task performed around here. But this is not that average case.