20

I have an 8086 CPU emulator. It emulates only 8086 instructions. I am searching now for a C compiler to target this emulator with. Is there any C compiler out there that can do this?

Also, having a usable libc and such is not important to me. The emulator uses custom(ie, non-PC) hardware and therefor any libc or even ctr0 would probably have to be rewritten anyway

Earlz
  • 62,085
  • 98
  • 303
  • 499
  • 1
    Any 16-bit DOS compiler. – Hans Passant Dec 20 '10 at 20:12
  • Sadly, yes, too many of them, and too many college professors making their students use them.... – R.. GitHub STOP HELPING ICE Dec 20 '10 at 20:36
  • @R.. @Hans many of the compilers I've seen target higher up than the 8086, usually they go up to 8186 and 8286 opcodes. – Earlz Dec 21 '10 at 21:10
  • @Earlz What about MS C compiler for DOS (QuickC) (as far as I remember, MS-DOS (or at least some core parts of it) never relied on anything above 8086, so..) One link I found (which reports tech problems at the moment) is http://vetusware.com/download/QuickC%202.51/?id=3503, and there're others too. Hope that will help you and (if too late) anyone interested. – mlvljr Aug 11 '11 at 15:55
  • 1
    @mlv thanks but I was looking more for a modernish compiler supporting at least C89 – Earlz Aug 11 '11 at 15:57
  • Microsoft's [QuickC](https://en.wikipedia.org/wiki/QuickC) may do it. But its so old, you may not be able to find it anywhere. I have the 1.44 floppy disks somewhere (there are 5 of them, IIRC). And Microsoft's [MASM](https://en.wikipedia.org/wiki/Microsoft_Macro_Assembler) will surely do it if you don't mind some ASM. – jww May 26 '15 at 04:05
  • 2
    Voting to close as tool rec. See also: https://stackoverflow.com/questions/227762/looking-for-16-bit-x86-compiler – Ciro Santilli OurBigBook.com Sep 04 '15 at 12:56

3 Answers3

12

bcc - Bruce's C compiler

From bcc(1) - Linux man page:

Description

Bcc is a simple C compiler that produces 8086 assembler, in addition compiler compile time options allow 80386 or 6809 versions. The compiler understands traditional K&R C with just the restriction that bit fields are mapped to one of the other integer types.

The default operation is to produce an 8086 executable called a.out from the source file.

Open Watcom

From the description of compiler option / 80x86 run-time convention 0 in Open Watcom C/C++ User’s Guide (PDF link):

(16-bit only) The compiler will make use of only 8086 instructions in the generated object code. This is the default. The resulting code will run on 8086 and all upward compatible processors. The macro __SW_0 will be predefined if "0" is selected

jschmier
  • 15,458
  • 6
  • 54
  • 72
7
  • Are you sure Digital Mars will generate binaries using only 8086 opcodes? – Earlz Dec 20 '10 at 19:51
  • @Earlz: Digital Mars can target the 8088, which is the same instruction set as the 8086: http://www.digitalmars.com/ctg/sc.html#dash023456 – Michael Burr Dec 20 '10 at 19:57
  • 1
    Another compiler that might be worth trying (I'm not sure though - it needs an MS-DOS environment to run in): Turbo C++ 2: http://edn.embarcadero.com/article/20841 – Michael Burr Dec 20 '10 at 20:05
  • 1
    @Mich no thanks, I'll stay as far away from Turbo C as possible lol – Earlz Dec 21 '10 at 21:00
2

Free Pascal can also produce 16 bit 8086 executable. It is not a native compiler, you have to compile it on your contemporary 32/64 bit machine and then copy the executable to your 16 bit IBM 51XX or clone.

gcc-ia16 TK Chia's GCC compiler targeted for 8086. It is actively developed. It is used to compile a huge 16 bit project such as ELKS Linux and all its applications. It is also not a native compiler.

Anton Andreev
  • 2,052
  • 1
  • 22
  • 23