Questions about Unreal Mode.

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
mschummi
Posts: 3
Joined: Sat Aug 29, 2009 3:08 pm

Questions about Unreal Mode.

Post 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
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: Questions about Unreal Mode.

Post 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?
"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 ]
User avatar
b.zaar
Member
Member
Posts: 294
Joined: Wed May 21, 2008 4:33 am
Location: Mars MTC +6:00
Contact:

Re: Questions about Unreal Mode.

Post 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.
"God! Not Unix" - Richard Stallman

Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
User avatar
b.zaar
Member
Member
Posts: 294
Joined: Wed May 21, 2008 4:33 am
Location: Mars MTC +6:00
Contact:

Re: Questions about Unreal Mode.

Post 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.
"God! Not Unix" - Richard Stallman

Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
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: Questions about Unreal Mode.

Post 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.
"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 ]
Post Reply