View Full Version : C++ on Z80

September 6th, 2016, 12:09 PM
This might be old news to some, but I post it here anyway:


ziloo :mrgreen:

September 6th, 2016, 01:28 PM
It should be mentioned that this is a cross-compiler with a limited set of classes. It's not clear if the compiler will support STL, nor the C++ standard library.

September 7th, 2016, 09:14 PM
Interesting, but it's not C++, here is what they show for a Hello World program:

include Text.ccz80++

class Program
static void main()
Text.PrintString("Hello World");
} Here is its description of itself:

It can be viewed as an evolution of the language ccz80, but ccZ80++ adds definition of classes, use of objects and a syntax closest to the C++ language to allow a more rapid learning.

September 7th, 2016, 11:25 PM
I am wondering why.....doesn't z80 allow for a standard C++ development or
it is just too much of an effort?


September 8th, 2016, 07:57 AM
I suppose it could be done, but C++ generates a lot of data structures for the various objects used and that coupled with increased stack usage on a memory constrained system like the Z80 means it's probably not the best choice.

September 8th, 2016, 08:04 AM
This reminds me of the early C++ implementations, where C++ was only a preprocessor and generated plain C code.

September 8th, 2016, 02:26 PM
I am wondering why.....doesn't z80 allow for a standard C++ development or
it is just too much of an effort?

The Z80's registers aren't the best fit for a language that likes 16-bit integers and passing parameters on the stack. The Z80 is at its best with 8-bit operations, and doesn't have any SP-relative addressing modes. The usual technique is to use IX or IY as a frame pointer, but using IX-relative instructions to populate a 16-bit register takes 38 clock cycles, compared with 16-20 to load it from memory or 10 to POP it off the stack. And accessing data with an offset of 128 or more from the frame pointer would be even less efficient.

September 8th, 2016, 02:41 PM
It's pretty obvious that the 8085 opcodes 38, d9 and ed (hex) were an attempt in that direction. Not nearly enough, though.

September 8th, 2016, 09:53 PM
LDSI - 38

I modified SmallC to use these three instructions. My primitive measurements show code speed increase of approx. 15% (and of coarse also code size decrease).