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

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 z80.eu.

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 hello.com 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.

Share This Post

Feedback/Discuss

Related Articles

Modula-2 Compilers on CP/M

Modula-2 is a great language in general and is a good choice for programming on CP/M. There are three good compilers available for CP/M which all require a Z80 processor and we'll compare each in turn...   Read More

The Pilot Programming Language on CP/M

Pilot was created by John A. Starkweather in the early 1960s as a programming language for Computer Assisted Instruction. It has often been compared to Logo because of its use with children. However,...   Read More

The Mouse Programming Language on CP/M

Mouse is an interpreted stack orientated language designed by Peter Grogono around 1975. It was designed to be a small but powerful language for microcomputers, similar to Forth, but much simpler. On...   Read More

If Only Borland Had Stuck With Turbo Modula-2 For CP/M

I have written previously about why Turbo Pascal is a Great Choice For Programming Under CP/M and now it is time to talk about what could have been. You probably haven't heard of Turbo Modula-2 for CP...   Read More

Turbo Pascal: A Great Choice For Programming Under CP/M

CP/M was blessed with many programming languages, each with their own strengths and weaknesses. I think that Turbo Pascal stands out from these and I'm not alone. When Turbo Pascal was released in 19...   Read More