On 2025-02-03 5:37 p.m., Sean Conner via cctalk wrote:
Do you mean you want a compiler to generate 16-bit
code? Or be compiled
as a 16-bit program to run under Linux? If the later, it's not supported,
or at least, not supported by default [1].
I was hoping to use Embeddable Linux Kernel
Subset (ELKS) BCC compiler
and the 6809 code generator, but NO they had to rewrite it just for the
386.
It took me only a few minutes to find it. There's the GIT repository at
https://github.com/lkundrak/dev86
When I did the compile, there compiler did throw up some warning even
though none were specified because the code is that old, but I did get an
executable:
[spc]matrix:~/repo/dev86/bcc>./bcc
Usage: ./bcc [-ansi] [-options] [-o output] file [files].
I think back then the code was 16 bit rather than 32 bit for the C
compiler.
Open source is
popular because it was free.
No compiler generates bad code,just some hardware was never meant to
have stack based addressing, like the 6502 or the 8088/8086.
Look at the mess that small C has for 8088/8086 code gen.
Self hosting never seems to be important for C compiler on a small machine.
The 8086/8088 was never meant to have stack based addressing? Um, the
8086/8088 has an entire register dedicated to that (BP by the way). The
limitation with BP is that it's bound to the SS segment by default, and in
some memory models that becomes an issue, but to say it doesn't have stack
based addressing? Methinks you are misrembering here.
The PDP-11 and 6809 has the S+,-S the X86 is missing. POP BX; ADD AX BX
compared to ADDD S++ for the 6809.
And self-hosting a C compiler on a small system
isn't easy with 64K of RAM
total. The PDP-11 had at least 64K code space and 64K data space to work
with.
That is true. The C compiler for the 6809 fit in a 64K memory space
under OS9.
-spc
[1] I have run a 16-bit MS-DOS exectuable under Linux, but it was on a
32b x86-based Linux system with a custom program I wrote to run it.
I even had to emulate several MS-DOS system calls to get it to work
(since I needed input from a Unix program to be piped in, I couldn't
use DOSBox for this).
[2] Dated July 27, 2002, which is before git existed, but this
repository was converted to git at some point.