23

I'm looking for the most recent versions of modern C compilers which were/are targeting DOS 8086, also running on DOS 8086 (16-bit). I'm mostly interested in production-ready C compilers, rather than hobby projects (possibly many bugs yet to be discovered).

By modern I mean:

  • support for ANSI C (C89) source files
  • support for generating small model and large model DOS .exe programs

See in my answer what I've found to work.

I'm aware of the following C compilers, but they are not answers to my question, because they have some required features missing:

  • LSI C-86 3.30c released on 1993-08-23: It doesn't support the large memory model.

  • DeSmet C 3.1h (1988) and DeSmet C 3.1N (1992): It seems to support ANSI C and the large memory model. (Compile hello.c using the small model: c88 hello; bind hello. Compile hello.c using the large model: c88 hello b; bbind hello) But it doesn't support the unsigned long type. Also I wasn't able to define a function which takes variable number of arguments (va_list args; doesn't compile). Also compilation breaks in weird ways, e.g. foo->field = 42; doesn't compile (but (*foo).field = 42; does), but then in the next line it compiles. I've given up on this compiler, it has too many bugs.

  • PCC 1.2d: It has the same engine as DeSmet C 2.51. It doesn't support the large memory model.

  • HI-TECH Software Pacific C 7.51 released on 2000-05-10: (1) the compiler is generating some useless overflow warnings for numbers between -40 and 40, so there may be many code generation bugs, probably not worth the effort; (2) the compiler is running out of memory for my tools which Borland Turbo C++ 1.01, Borland C++ 2.0 and Microsoft C 6.00a can compile easily. I've given up on it.

I'm aware of the following C compilers, but they are not answers to my question, because they don't run on DOS 8086:

  • OpenWatcom. I've successfully compiled C code targeting DOS 8086 with the most recent build 2022-11-22 on DOSBox with 5 MiB of memory. Arguably OpenWatcom is the most modern C/C++ compiler still targeting DOS 8086. However, the DOS port of the compiler itself runs in 32-bit protected mode, and thus needs a 386 processor. I'm not using the DOS port though, the native ports to my laptop are faster, and they produce the same DOS program.

  • GCC

  • DJGPP

  • gcc-ia16

  • Clang

  • Microsoft Visual C++

  • Borland C++ Builder

  • TinyCC (TCC)

  • Digital Mars C/C++ 8.57 released on 2022-05-14: The compiler .exe files are for Win32, they don't run on DOS 8086.

  • Smaller C 1.0.1 released on 2021-09-14: Even the DOS real mode compiler tools (e.g. bind/smlrc.exe) need a 386 CPU.

  • Symantec C/C++. This is the successor of Zortech C++, and the compiler executable programs probably run in protected mode, thus they need a 386 CPU. Maybe version 6.0 still contains DOS 8086 programs, I have to try. In version 6.1 there is the sc -b ... command-line flag, but the corresponding scc.exe (C compiler for DOS 8086) and scpp.exe (C++ compiler for DOS 8086) are not provided, probably they were never released. The protected mode programs sccx and scppx.exe run in protected mode, and need a 386 CPU (they work in DOSBox with 2 MiB of memory). Release history:

    • Symantec C++ Professional 6.0 was released in 1993-09.
    • Symantec C++ Professional 6.1 was released in 1993-12.
    • Symantec C++ 7.0 for Windows was released in 1995-07.
    • Symantec C++ 7.2 for Windows 95, Windows NT 3.5, Windows 3.1 and DOS was released in 1995-10.
    • Symantec C++ 7.50 was released in 1997.

Is there any C compiler I've missed? Maybe there is a much more recent (than 1992) minimalistic C compiler.

11
  • 1
    What purpose do you need it for? Nov 23, 2022 at 23:56
  • 8
    @ThorbjørnRavnAndersen: I'm writing some tools for DOS 8086 in C89 (currently compiling them with OpenWatcom targeting DOS 8086), and I was wondering if it was possible to compile them on DOS 8086. If yes, I may want to compare the behavior of different compilers and C libraries, and port my Watcom-specific optimizations.
    – pts
    Nov 24, 2022 at 0:06
  • 4
    Makes sense. There is nothing wrong with cross compiling though. Nov 24, 2022 at 6:10
  • 1
    I'm surprised to see TCC on the list at all; it can't even target 16-bit mode x86, unless I'm missing something in the docs (bellard.org/tcc/tcc-doc.html#linker). (But it's open source, so you could compile it to run on DOS and make Linux ELF or Windows PE executables.) Nov 25, 2022 at 4:52
  • 2
    To stick with the Q&A format used here, you might want to move most of the information in your question into an answer. I’ll delete my answer in a little while since it is useless now that you’ve merged it into your question. Nov 25, 2022 at 13:53

3 Answers 3

17

The most recently-released C compiler I’m aware of for 16-bit DOS (host and target) is HI-TECH Software’s Pacific C, version 7.51, released on 1996-01-20. The IDE, PPD, requires a 286, but PACC, the command-line compiler driver, runs on an 8086.

There might have been a later release of a Digital Mars (formerly Zortech) C compiler hosted on 16-bit DOS, but I’m not familiar with the DOS-hosted history of that compiler after Zortech C++ 3.0r2 (1991-08-02), which is the last version that run on an 8086. Zortech C++ became Symantec C++, which was only available hosted on Windows, and then the Digital Mars Development System, which is also only available hosted on Windows.

10
9

There's also the Zortech C compiler from Walter Bright at his Digital Mars site. It supports 16 bits (DOS, Windows) and 32 bits (DOS with extender, Windows and OS/2). Walter Bright works now mostly on his new language D but still supports his C and C++ compiler when something important happens.

https://www.digitalmars.com/download/freecompiler.html

1
  • 4
    The Digital Mars compiler doesn’t run on 16-bit DOS however. Nov 24, 2022 at 15:59
5

I can confirm that the following C compilers work. I've also indicated the latest version of each which still runs on DOS 8086.

  • Borland Turbo C++ 1.01 released on 1991-02-27. The next version, 3.00 has tcc.exe which needs a 386 or newer processor.
  • Borland C++ 2.0 released on 1991-04-23. The next version, 3.00 has bcc.exe which needs a 386 or newer processor.
  • Microsoft C 6.00a released on 1990-09-12. The next version, 7.0 has cl.exe which needs a 386 or newer processor. C++ support was added in 7.0.
  • Zortech C++ 3.1 released on 1992-12-07. The compiler supports both C and C++, depending on the source file extension. To run it on DOS 8086, invoke it as ztc -b .... Without the -b flag it needs a 386 CPU, and it runs in protected mode. It seems to work for my test tool programs with minor modifications, like the compilers above.
  • Watcom C 9.01 released on 1992-05-28. The next version, 9.5 has wcc.exe which needs a 386 or newer processor. Please note that I wasn't able to get a copy of wcc.exe (which targets the 8086 in 16-bit mode) in Watcom C 9.01, but only the wcc386.exe (which targets the 386 in 32-bit mode). The wcc386.exe I obtained was indeed a DOS 8086 .exe program, so most probably the corresponding wcc.exe is also like that.

I've also tried compilers suggested in other answers, but either they don't run on DOS 8086, or they have some features lacking or serious bugs which prevent me from using them.

1
  • 2
    I'm a fan of Turbo C 2.x. I used it on a 4.77MHz 8088 until I got my 80386, and while its performance wasn't as good as Turbo Pascal it was still adequate (much better than Turbo C++). I think the version I downloaded from the Borland Museum was almost the same as the one I used back in the day, except that on the Museum version, printf("%0.1f", 99.96 would correctly output 100.0 while my version from the 1980s would output 00.0.
    – supercat
    Jan 18 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.