Cowgol gets an update

As mentioned previously

But now new and improved:

The new version features:

  • a proper parser (using Lemon)
  • a table based backend which is simpler to port and produces better code
  • a proper register allocator (based on destination driven allocation, which is absurdly simple and produces good results)
  • fewer compiler stages
  • better code quality (it’s actually pretty good in places)
  • modular compilation
  • a linker
  • smaller binaries

Cowgol is written in cowgol, and targets 8080, Z80, 6502, 386, and a flavour of C (used for bootstrapping.)

A demo within runs in your browser, using the JSBeeb emulator, acting as a BBC Micro Master Turbo model.

1 Like

But can it self compile on the target machine?
EVIL THOUGHT I have TINY C version 1.0
can you boot strap with that?
Code generation requires lots of free registers because
most machines other than the 8 bitters do not have a uniform instruction set. You might have load store for byte or index operations or # constants, with a CISC format for the remainder of the operations. with Bengol I chose to limit complex instructions 1 function per statement and indexing to a simple term and no general unary operations.
expression := Unary r-value | term + {operand r-value } |
( expression )
Nice and simple to decode. The hardware I compile to
has 2 nice features Branches have good sized range ± 4KB. I have set logic condition for things like a= n<6
I can self compile to a 24KB program (20bit words/10 bit bytes, and ~32KB for my 8/16/32 bit cpu.

From the project page:

the end goal is to be able to rebuild the entire compiler on an 8-bit micro, although we’re not there yet