Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
psf
psf
@psf@oldbytes.space  ·  activity timestamp 2 weeks ago

I should post about the latest #retrocomputing project I started.

Problem: I'd like an open-source, self-hosting C compiler on 8086, that supports the large memory model, overlays, and enough C89 to build Lua.

This seems to not exist! K&R is much more common in this size category. Around the time of C89, many compilers bloated to the point of requiring a 386 or better host, though they could still target 8086. The 8086 holdouts were, in general, commercial products that never got a source release.

One notable exception was DeSmet C http://www.desmet-c.com. It seems to have started life as a commercial PC fork of Bell Labs PCC, a small and sturdy K&R compiler. DeSmet 3.1 added "draft ANSI C" support, but this is incomplete, and riddled with code-gen bugs. This version later found itself on Github as OpenDC https://github.com/the-grue/OpenDC.

Aside from all the bugs, this is a pretty cool package: its dis/assembler, debugger, text editor, and some other utilities were also open sourced, and it runs on an 8088 with 256K RAM and two 360K floppies.

The OpenDC person did a good job packaging things up into an easily buildable form, and fixing syntax errors that probably came from running the sources through a different compiler version than expected, so... yes, it does indeed build and self-host... and I've done this on my Book 8088.

So now I will try to fix the bugs and add the missing C89 features. There are many, many of both... gulp.

Desk with Book 8088 laptop displaying some assembler type mismatch errors.  Coffee mug and desk toys in background.
Desk with Book 8088 laptop displaying some assembler type mismatch errors. Coffee mug and desk toys in background.
Desk with Book 8088 laptop displaying some assembler type mismatch errors. Coffee mug and desk toys in background.
GitHub

GitHub - the-grue/OpenDC: DeSmet C - Open source and completely built with latest toolchain

DeSmet C - Open source and completely built with latest toolchain - the-grue/OpenDC
  • Copy link
  • Flag this post
  • Block
psf
psf
@psf@oldbytes.space replied  ·  activity timestamp 2 weeks ago

The #DeSmetC compiler codebase is the hairiest code I've had the experience of hacking. K&R style, many global variables, short cryptic names, spooky action at a distance, the shotgun-surgery pattern for type handling splatted around everywhere, oh baby.

For all that, I managed to fix the codegen bug from the Github issues on the ~second day of working on the compiler... that's the beauty of a small codebase.

My fork is here: https://gitlab.cs.washington.edu/fidelp/open_desmet_c
1 bug down, 999 to go...

#retrocomputing

DOSBox-X displaying some successful compiling/assembling messages.
DOSBox-X displaying some successful compiling/assembling messages.
DOSBox-X displaying some successful compiling/assembling messages.

Shotgun surgery - Wikipedia

  • Copy link
  • Flag this comment
  • Block
psf
psf
@psf@oldbytes.space replied  ·  activity timestamp 2 weeks ago

Ooh, the-grue, the current maintainer of OpenDC #DesmetC, took my code-gen patch, how awesome! Usually when I pick up an old codebase like this, the maintainer is long gone.

So @linear if you end up wanting to submit patches, that's the place: https://github.com/the-grue/OpenDC
My fork will remain just an unofficial fork.

GitHub

GitHub - the-grue/OpenDC: DeSmet C - Open source and completely built with latest toolchain

DeSmet C - Open source and completely built with latest toolchain - the-grue/OpenDC
  • Copy link
  • Flag this comment
  • Block
Matthijs De Smedt
Matthijs De Smedt
@anji@metalhead.club replied  ·  activity timestamp 2 weeks ago

@psf I had never heard of this before. What an odd name for a C compiler! I like it.

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct