| 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
This can be downloaded from their site, here. You do need to register, but it is a simple process and doesn't take long.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:
I>hello hello, world

