Cowgol Development Environment Comes To Z80 And CP/M

Cowgol on Z80 running CP/M ties together everything needed to provide a Cowgol development environment (including C and assembler) on a Z80 running the CP/M operating system, making it easier to get up and running with a language aimed to be small, bootstrapped, and modern.

Cowgol is an experimental modern language for (very) small systems.

The Zilog Z80 was an 8-bit microprocessor common in embedded systems of the 1970s and 1980s, and CP/M was a contemporary mass-market operating system. As for Cowgol? It’s an Ada-inspired compiler toolchain and programming language aimed at very small systems, such as the Z80.

What’s different about Cowgol is that it is intended to be self-hosted on these small systems; Cowgol is written in itself, and is able to compile itself. Once one has compiled the compiler for a particular target architecture (for example, the Z80) one could then use that compiler on the target system to compile and run programs for itself.

Thankfully, there’s no need to start from scratch. The Cowgol on Z80 running CP/M repository (see the first link of this post) contains the pre-compiled binaries and guidance on using them.

Cowgol is still under development, but it works. It is a modern language well-suited to (very) small systems, and thanks to this project, getting it up and running on a Z80 running CP/M is about as easy as such things can get.

Thanks to [feinfinger] for the tip!

7 thoughts on “Cowgol Development Environment Comes To Z80 And CP/M

  1. I did Cowgol! It’s still kinda rough around the edges but it is powerful enough to write a compiler in. Obviously. Self-hosting-wise the biggest missing feature is that the compiler’s based around the Lemon parser generator, which is written in C, so changing the parser always requires cross-compiling from a PC. I need to look into replacing that with a hand-written parser. If I can make the code smaller that’d be good too, as currently the compiler front-end is 35kB on the Z80 (and 36kB on the 8080, 43kB on the 6502, and 33kB on the 6303).

  2. It sounds kind of interesting, but why not improve something out there like HITECH-C? A lot of us build on virtual environments, so I’m not sure native target compilation is a big deal?

  3. Huh. Seems to be a weird combination of Cowgol and Z80 HiTech C. The HiTech compiler is required here. Cowgol was originally supposed to host itself, even on CP/M.

    I wonder if the Cowgol here is the current Cowgol 2.0, or only the original 1.0. The official David Given repository is annoying because no compiled release has been made since 1.0, and building the current 2.0 source is very painful. I really wish there was an updated CP/M release. This one looks good except that I can’t understand why HiTech C is bolted on. If that’s the case you might was well program in straight C.

    1. @JRD:
      Cowgol is a very attractive language for anyone working on Z80 based computers. However, for Z80 computers, David Given’s original version on GitHub lacked a decent “development environment”. That is, there was no possibility to compile Cowgol programs using a simple command, as in the case of programs written in C, where you use the command:
      >C source.c
      to get source.c compiled and the source.com executable being built.
      It is exactly what I did, providing a platform to use a single command, like:
      >cowgol source.cow
      to get source.cow compiled , linked and the source.com executable being built.
      More than that, you can mix cowgol, C & assembler:
      >cowgol main.cow routine1.c routine2.as
      to get source.cow and routine1.c compiled, routine2.as assembled, the object files linked and the main.com built.
      The platform uses HiTech’s components (the C compiler and linker), a custom cowgol.com command-line parser & executer(adapted from the original C.COM), and my custom Z80AS assembler.
      See https://github.com/Laci1953/Cowgol_on_CP_M for examples.
      I work now on an enhanced Cowgol compiler, able to compile larger source files, on Z80 systems provided with 128KB or 512KB RAM.
      It will fully use the available RAM space to allocate objects, allowing to process very large Cowgol files (I hope it will be able to compile itself…)

      A small test is already working with a part of the compiler (cowfe.com); the test is executed on a 512KB RAM Z80 computer:

      D>cowfe t.cow test
      COWFE: 18kB free main memory
      448kB free extended memory
      > T.COW
      done: 17kB free main memory
      442kB free extended memory
      D>

      Of course, there is still a long way to go until all tests will be finished…

      Ladislau

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.