Hello,
I found this topic very close to my today/yesterday work. I know, the last post came in 2007, but who knows, maybe we can help each other.
The reason why I started to seek for a Z80 C-Compiler, because I cannot program big things in Assembly. And I got used to use C for programming.
So I have started yesterday with SDCC, Today I made a little program, and tested it. I wanted to share my experiences.
For a new Project I do the following:
1. I create a C-code with the 'int main(void)' function and other sub functions
2. Compile the project with the folowing command which places the file at memory 0x4000
sdcc main.c -mz80 --code-loc 0x4000 --data-loc 0x4000
3. Then I convert the created main.ihx file to binary format using the hex2bin.exe
hex2bin.exe -p 0 main.ihx
(-p 0 means, the unused bytes im file has to be ZERO)
4. I copy the data from 0x4000 to the end and I give it to the emulator
As I started the program from 0x4000, it didn't work, the program returned immediately. As I made a dissassembly listing I had noticed, that the first 10 bytes are foreign code. See attachment, the red line shows where the first planned instruction starts, the instruction before 'DEC SP' means the main function has a integer return value it's still ok, but the others are not from me.
If I jump it over, and call 0x400A, the program runs normally.
Does anyone know, what for are these first 10 bytes, and how can I switch it off in SDCC?