Serentty / rusty-dos

A Rust skeleton for an MS-DOS program for IBM compatibles and the PC-98, including some PC-98-specific functionality
145 stars 9 forks source link

What about Unreal Mode? #10

Open pygy opened 2 years ago

pygy commented 2 years ago

Have you thought of using the latest and greatest in pure DOS programming, i.e. unreal mode which lets you access the whole range of memory from real mode, as a flat address space?

The main drawback is that the resulting binary will not be compatible with exotic shells and OSes like MS Windows or OS/2 Warp, but seriously, who cares about them?

Serentty commented 2 years ago

When I first made this project a few years ago, I used real mode, as I am sure you can tell. A while later some people figured out how to use DJGPP with it, but at that point I had sort of lost enthusiasm because I had already gotten Rust code to show some messages in DOSBox, and the initial goal of the novelty had been achieved, so I never got it working myself well enough to merge it. However, in the past few weeks I have gotten heavily interested in MS-DOS again, this time on real hardware. In fact, I am kind of curious: did you find this project through my website Serentty.com? That is what I have been working on the past few days. But that aside, the point is, my enthusiasm is back, so I open to trying new things! If switching to unreal mode is as simple as running some assembly and then using 32-bit pointers as normal, then that sounds like a great approach. I understand the appeal of protected mode of course, given that this requires at least a 386 at the moment due to the compiler used, but I also understand the appeal of being in what is fundamentally more like an unrestricted form of real mode. It feels more authentic as “DOS programming” in a way, being right against the hardware. The idea that future compiler advancements would make it possible to simply recompile for the 286 is also a real draw.

So all that is basically saying: yes, this is interesting to me, and if you have some more information or suggestions, please do go on.

pygy commented 2 years ago

Yes, I found this via your Web site, which was posted on HN, and I loved the whimsy, which is why I followed up.

I never programmed in DOS, and have little practical advice to give you. I know of unreal mode because I've been a DOSBox beta tester a long time ago, and it was a big deal when they added support for it in the emulator (Ultima 7 couldn't run in Windows).

If switching to unreal mode is as simple as running some assembly and then using 32-bit pointers as normal, then that sounds like a great approach.

This is my understanding, but my knowledge is pretty shallow. I should let you use the full 4MB from real mode using 32 bits pointers.

I have no idea how addressing works on the 286... AFAIR it uses 16 bits pointers, where unreal mode will not help.

Serentty commented 2 years ago

Interesting. I skimmed the Wikipedia article briefly and it said that unreal mode requires at least a 286. Regardless, it is not too big of a deal because this currently requires at least a 386 anyway.

I should let you use the full 4MB from real mode using 32 bits pointers.

You meant to write G and not M, right?

pygy commented 2 years ago

I may be misremembering, but I thought your 386 had 4MBs (which was pretty good at the time). I remember 8MB being the baseline when I bought a Pentium (I bought it with 32, you never have too little RAM).

You could I suppose reach 4GB with a suitable motherboard/chipset

Serentty commented 2 years ago

Oh, I see what you meant! Yeah, I was not thinking of my 386 in particular, just 32-bit x86 in general. I do in fact have 4 MiB of RAM in the 386, which I am going to upgrade to 16.

pygy commented 2 years ago

Now that's an amazing set up.

I didn't know you could go that high on 386 motherboards... Is it a desktop-class machine?

Serentty commented 2 years ago

Yep, it’s a desktop—the old horizontal kind. It has three full 16-bit ISA slots too, which is really nice. The model is an HP Vectra 386/25N. Externally, the case is identical to this picture except for the model number on the left.

image

pygy commented 2 years ago

Gorgeous, thanks for the pick :-)

tkchia commented 1 year ago

Hello @Serentty,

In case it is useful, the osdev.org wiki has a page with sample code for switching to "big unreal mode". Michal Necasek also has a blog entry about the general history of unreal mode.

The osdev.org sample code will probably work in "real" real mode. But it will not work from V86 mode, which may happen if your DOS system has an Expanded Memory Manager (EMM) running.

Thank you!