Has anyone written a C++ compiler in Z80?

Page 1/3
| 2 | 3

By Chilly Willy

Expert (103)

Chilly Willy's picture

31-01-2023, 18:17

I am curious if anyone has written a C++ compiler in Z80 assembly for the MSX?

I would love to take a peek at that code for a project that I am currently working on.

Thanks up front

Login or register to post comments

By geijoenr

Champion (364)

geijoenr's picture

31-01-2023, 18:59

Not exactly what you are asking for but you can take a look at this post maybe:

https://msx.org/forum/msx-talk/development/z80babel-c-d-rust...

By Chilly Willy

Expert (103)

Chilly Willy's picture

31-01-2023, 21:03

I was thinking something along the line of a C++ compiler that is native to the MSX written in Z80 with source.

No libraries other than the standard STDIO and the like if I can remember

By Manuel

Ascended (19468)

Manuel's picture

01-02-2023, 00:16

C++ is a very complex language. You can't even think about writing a compiler for it on a Z80. Not even a parser. There is only one or two (quite limited) C compilers written for MSX... and that's it. And C++ is several magnitudes more complex.
Better go for cross compilation...

Why would you be interested in this? Care to explain?

By ducasp

Paladin (680)

ducasp's picture

01-02-2023, 14:23

I'm not even sure if c++ cross compiling would worth the trouble... There is a lot of overhead for a puny 3.58MHz z80 and 64KB memory, performance probably wouldn't be great and it would consume much memory...

By Chilly Willy

Expert (103)

Chilly Willy's picture

01-02-2023, 17:21

Thanks everyone for their answers.

Now, is there a C++ compiler written in Z80 with source for the MSX or any other Z80 based system.

Even if it was written for CP/M and I can convert it from 8080? To Z80

By Grauw

Ascended (10768)

Grauw's picture

01-02-2023, 18:01

No, it does not exist.

There is not even a proper C++ compiler for Z80 on PC. There are some attempts here and there, but they are incomplete afaik.

So for the time being C is the best you can do.

By Chilly Willy

Expert (103)

Chilly Willy's picture

01-02-2023, 18:21

Grauw wrote:

No, it does not exist.

There is not even a proper C++ compiler for Z80 on PC. There are some attempts here and there, but they are incomplete afaik.

So for the time being C is the best you can do.

OK, how about just plain C.

I know there is a C compiler that will output Z80 code because they do it over at Atari Age all the time for the Colecovision. Just that it is SDCC for Windows.

Then again, it's not a native Z80 written compiler.

I guess I will have to write it from scratch then right Gov'Na...
40 years of MSX and you would think that it was done by now. First time for everything I hear.

By aoineko

Paladin (1004)

aoineko's picture

01-02-2023, 18:37

SDCC is multi-plateform (not just Windows) and even if it target not only the z80, it generate good assembler code (especially with its new calling convention).

If you want a z80 only compiler, check z88dk.

By Manuel

Ascended (19468)

Manuel's picture

01-02-2023, 19:37

There are a few limited C compilers for MSX. The best one is probably ASCII's MSX-C. Check generation MSX for several others.
- Hi-Tech C for CP/M
- BDS C
- GST C

Note that this says C++ compiler: https://www.generation-msx.nl/software/hisoft/c-compiler/2492/
But it's just a C-compiler with some extras. (Dunno what though...)

By PingPong

Enlighted (4138)

PingPong's picture

01-02-2023, 21:24

I can't imagine even how much memory would eat supporting all OOP features and others things that C++ had over plain C. Think about templates, virtual table dispatched methods and every other kind of feautures. a simple C++ code with one virtual class targeting z80 asm would probably result in a huge machine code size with horrible performances.....

Try to imagine the size of a simple copy constructor code with 10 members to manage.....

As an experiment one could try to compile C++ code to plain C code (there are c++ compilers that can do this) and try to compile the result with SDCC to have an idea of how would the asm code will be in size and performances.

Page 1/3
| 2 | 3