I’m not exactly sure exactly how I’m supposed to use the Z-80 code that ships with SDCC. There is a set of C library source code with processor specific directories. I can link against it, and the linker doesn’t complain about missing putchar and getchar. I can define my own putchar and it doesn’t complain about multiply defined putchar. This is not what I’d expect.
There is seemingly no makefile that would use these to create libraries. So I copied them to my local area and wrote my own makefiles to make my own libraries. I used the assembler and compiler to create a ‘z80.lib’ in the z80 directory. Then a crt.lib, float.lib, and longlong.lib in the src directory.
This approach presented some questions.
- sdar gives a segmentation fault--so I'm using the deprecated sdcclib
- some functions are multiply defined--mostly low level basic arithmetic. Why?
- some functions are completely unimplemented--mostly the char is.* functions. Why?
- there are several printf options, none of which seeming appropriate
So my plan to get this working is to:
- add the implementation for the is.* functions
- add an implementation for __print_format
- add getchar and putchar
This should give me a version of C that will work for my purposes. I’ll leave out longlong and float.
I also have to look into something I saw. A developer of a graphing calculator said on the SDCC forum, I think, the Z-80 compiler stopped creating correct code after some checkin. So I’ll have to consider pulling that last version from SVN and compiling that.
Or look into other toolchains. Or fixing it if it’s broken and contributing to the sdcc project.
I also don’t know how to do something that I’d like to do. Namely, I want to have a C runtime in bank 0 and then an application in bank 1. So I want the bank 1 application to access the C runtime code in bank 0 without actually linking it. That might involve an assembly file that defines a bunch of stubs that forward to the actual code– just a set of jumps that jump the appropriate code in bank 0 or maybe to a vector in bank 0 so that I can replace the code in bank0 without needing to recompile the applications.
Just stuff I’m thinking about….