Installing the HI-TECH Z80 C Compiler for CP/M

  /     /   C     CP/M     Programming     Retro     Tutorial     Z80    

My language of choice is C and I am currently getting more involved with the CP/M operating system. I have therefore decided that it would be nice to have a C compiler working under CP/M. There are a number of options available in the archives, but I have found that HI-TECH are allowing their CP/M C Compiler to be downloaded for free. This is a very good product, has good documentation, is almost ANSI C compliant and can be used for commercial and non-commercial use. This, therefore, is the one I have chosen.

Downloading the HI-TECH Z80 CP/M C Compiler

At one time this could be downloaded from the HI-TECH site, however the best place to get it from now is

The files are self-extracting lharc'ed archives so I installed lha, which is part of my Debian distro. To extract the contents of the main compiler archive, I created a subdirectory called z80v309. I entered it and ran:

$ lha e ../z80v309.exe

The extracted contents comes to 413k which is too large for the 8" SD disks that my emulator supports, so I used Cpmtools to create a 4Mb HDD image to put the files on. Hopefully however, this should fit on your disks.

Using the C compiler

To test the C compiler I went to the B: drive, where I'm storing my development work, and created a file called hello.c containing the classic "hello, world" source code:

void main(void)
   printf("hello, world\n");

To compile the source (hello.c on my B: drive) in verbose mode, using the compiler on my I: drive, I run the following:

I> c -v b:hello.c

This leaves the executable on the I: drive. Now all we need to do is run it to ensure that it has compiled properly:

I> hello

Which gives the correct output as below:

hello, world

Where Now?

The next step, if you haven't already done it, is to extract the documentation file, z80doc.exe. This is an extensive document that should really help you get to grips with using the compiler. Now all you have to do is start tinkering and see what you can create.

Creative Commons License
Installing the HI-TECH Z80 C Compiler for CP/M by Lawrence Woodman is licensed under a Creative Commons Attribution 4.0 International License.

Related Articles

Installing ZDE 1.6, a programmers editor for CP/M

To do any serious programming under CP/M, the first thing you need is a good programmers editor. There aren't many in the archives, but I have tried most of them and found ZDE to be the best. It is s...   Read More

Transferring Files to and from CP/M .D71 Disk Images Using ctools

Using Vice to emulate a Commodore 128 running CP/M works very well, but it isn't easy to get CP/M files directly onto and off a .D64/.D71 disk image. The easiest way to do this under Linux is to use c...   Read More

Emulating a CP/M System With z80pack

z80pack is great for creating an emulated CP/M system. It can either be used to create a general CP/M system or can emulate a specific system such as an IMSAI or ALTAIR including a graphical front-pan...   Read More

Adding a Basic Stub to a VIC-20 Assembly Language Program

To make machine language programs more friendly it is nice to add a basic stub which contains a line with a SYS statement to start the code. This is easy to do on the Vic-20 and the process gives you ...   Read More

Beginning Assembly Programming on the Commodore VIC-20

The Commodore Vic-20 is a great machine to learn an assembly language on. It was released in 1981 and was the first computer to sell one million units, which contributes to its popularity today. The ...   Read More

Sign up to get new articles straight to your inbox.

Delivered by FeedBurner


blog comments powered by Disqus