Writing FreeDOS Programs in C

AlexeyBrin | 133 points

To the list of compiler listed I want to mention this one as well, that is my compiler of choice for 16-bit C in (Free)DOS these days (because it has a MIT license, it's very small, and it runs great inside of DOS itself so no need to mess with cross-compilation and I know if I have an environment like FreeDOS or DOSBox set up I can both compile and run my code, and I will never have to re-install or reconfigure anything when moving between different host systems):

https://github.com/microsoft/MS-DOS/tree/main/v4.0/src/TOOLS

(Not only Microsoft's C compiler in that directory, but also MASM, MAKE, and a bunch of other tools. 1-2 MB of files and you have an entire toolchain for 16-bit DOS.)

1313ed01 | 2 days ago

Is there really a difference between writing a DOS program and writing a FreeDOS program? You just need a period-accurate compiler that can target DOS. Maybe OpenWatcom, maybe DJGPP.

With HXDOS, you can also write a Win32 console-mode program and run it on DOS. 7-zip is an example of a program compatible with HXDOS.

Dwedit | 3 days ago

On conio.h under GNU/Linux or Unix, it might be mimicked with trivial functions and escape codes.

I did similar stuff with TCL and some at-xy lookalike from Forth or 'print at' from the old Basic.

And rewritting these Basic games into C, TCL or whatever it's really fun (and you can defnitively kill the spaghetti code):

https://github.com/GReaperEx/bcg

You can just run BW Basic for FreeDOS, but that's no challenge...

anthk | 2 days ago

I don't know the answer, just asking the question: Is/Was curses available at the time? https://en.wikipedia.org/wiki/Curses_%28programming_library%...

I only remember conio at the time, but without internet you just used what Microsoft gave you. The BBSes I used may have had it, but it's hard to use something if you don't know it exists.

It does look like there is a recent port: https://github.com/wmcbrine/PDCurses

So my guess is curses was not available to DOS at the time, only Unix systems.

xx__yy | 2 days ago

Tangentially related: I was getting awful screen tearing in dosbox with a gl @ 4K@60hz rendering target.

Switching to 1080p@240Hz fixed it. The problem was that 60Hz was close to, but not the framerate the old game asked for.

hedora | 3 days ago

Curious as to whether there are any real-world use cases for doing this (other than curiosity) in DOS. If so, I'd love to hear about them.

dardeaup | 3 days ago

Vibe coders are just going to be staring at this and go... where'd you get that blue mode in Cursor?

sgt | 3 days ago

Would be nice to have a Rust compiler as well

ladyanita22 | 2 days ago