Unix C Cross Compilers for Z80s

Duane Morse duane at anasazi.UUCP
Sat Apr 27 08:16:43 AEST 1985


We are looking for a good C compiler that runs under Unix and
produces code for a Z80. I'd appreciate personal testimonies to
the merits and defects of the existing products. To kick this
discussion off, I'll tell what I know about Q/C from The Code
Works.

Q/C was designed to run under CP/M, but most of the source was
written in C. I am porting it to our Megaframe SysV Unix (CTIX).

Restrictions & design flaws in Q/C. (1) No unsigned characters; all characters
are sign extended to ints. (2) No voids. (3) Arguments are pushed
on the stack in the order given, so functions taking a variable
number of arguments are impossible to write (printf & scanf are
handled by having the compiler explicitly LOOK for "printf" and
"scanf" -- it then adds an argument for the number of user
arguments). (4) The pre-processor supplied doesn't allow #defines
with parameters (I got around this by throwing away the built-in
preprocessor and invoking the public domain cpp). (5) No declarations
are allowed in compound statements. (6) Some restrictions on what
a function can return. (7) No longs, floats, or doubles. No bit
fields. No initialization of auto or register variables. Registers
can only hold ints and pointers. (8) The compiler itself assumes
16-bit ints, so there are some subtle code generation problems
compiling the compiler on a larger machine.

Bugs discovered thus far in Version 3.2. (1) If ptr points to a
structure and xxx is an element of the structure, the compiler
complains that it doesn't know what to do with ptr++->xxx. It
doesn't complain about ++ptr->xxx, but it doesn't do the right
thing. (However, (ptr++)->xxx and (++ptr)->xxx both seem to work
properly.)

Strong points. I've ported a couple of programs from Unix to CP/M
using Q/C, and the effort was minor. I didn't have to change much
in the source, and the programs ran the first time. From this
I feel that the compiler is fairly solid.

Weak points. Besides the restrictions (admittedly, some of them are not
particularly important as far as we are concerned), Q/C doesn't
try to do much optimization (not surprising since it is a 1-pass
compiler). I don't have any benchmarks to confirm this, but I
suspect that resulting programs may be somewhat big and slow.
properly.)



More information about the Comp.lang.c mailing list