I've compiled a little test program to hopefully getting started on my new target. For now it's just a basic z80 with 64K ram, no specific rom or compatible peripherals. Code and Data are in the same address space. After compiling using the command below, i'm seeing quite a large startup code present inside the binary. As I would like to customize this code a bit I was wondering where this code is located and how to alter this?
zcc +z80 -v -O3 -startup=0 -clib=new --list test.c --no-crt -o test -lm -create-app
So is it possible to alter the startup code using a z80 project or would it be a better solution to create a new target for my platform?
Thanks in advance.
Startup code for new target?
Re: Startup code for new target?
Try changing -startup=31 for minimal footprint
Re: Startup code for new target?
Ohh wow using te startup=31 will remove all the startcode, that's a bit more then I would have expected
But maybe not so bad at all, at least I can now work from a clean start without some startup code I don't need. The only problem is off-coarse that I also don't have a starting point anymore (See test code below) or no JP to main function. I could add some inline instructions but is there a way to add a JP to main()?
Code: Select all
//#include <z80.h>
__asm
DI
IM 1
LD SP,0FFFFh
__endasm
void z80_outp(unsigned char Port, unsigned char Data)
{
__asm
POP AF
POP HL
POP BC
PUSH AF
OUT (C),L
__endasm
}
int main()
{
z80_outp(0xd8,0x0e);
return 0;
}
Code: Select all
;Addr Hexa ASCII Z80 Mnemonic Comments
T0000h F3...... ๓... DI
T0001h ED56.... ํV.. IM 1
T0003h 31FFFF.. 1. LD SP,0FFFFh
T0006h F1...... ๑... POP AF
T0007h E1...... แ... POP HL
T0008h C1...... ม... POP BC
T0009h F5...... ๕... PUSH AF
T000Ah ED69.... ํi.. OUT (C),L ;
T000Ch C9...... ษ... RET
T000Dh 21D800.. !ุ.. LD HL,000D8h
T0010h E5...... ๅ... PUSH HL
T0011h 2E0E.... .... LD L,00Eh
T0013h E5...... ๅ... PUSH HL
T0014h CD0600.. อ... CALL T0006H
T0017h C1...... ม... POP BC
T0018h C1...... ม... POP BC
T0019h 210000.. !... LD HL,00000h
T001Ch C9...... ษ... RET
Re: Startup code for new target?
You can remove the --no-crt and use just -startup=31
Re: Startup code for new target?
Thanks for your message, because of this I re-tested the effect of this and found out that the last time I've tested with this operand the reason nothing seems to change was because the compiler isn't generating a new .bin file anymore. So the disassembler kept looking at a old file
But knowing this it seems that using the --no-crt or startup=31 are actually doing the same thing.
Why doesn't the output of files change between startup=0 or startup=31?
Re: Startup code for new target?
Now knowing that it's possible to just place the crt0.asm file directly beside your source files and use the following command to tel z88dk to use it:
Is it then also possible to copy the "Z80_CRT_0.ASM.M4" file out of the "Z88dk\libsrc\_DEVELOPMENT\target\z80\startup" folder and use it as the crt0.asm file inside my project directory? I presume that this (if not altered) will generate the same code then using the "zcc +z80 -v -O3 -startup=0 -clib=new program.c" command?
Any thoughts?
Code: Select all
zcc +z80 -crt0=crt0.asm program.c
Any thoughts?
Re: Startup code for new target?
I've got the custom CRT working. In the end it became clear to me that with the amount of customization that is possible, it was better for compatibility sake, to switch back to using the default z80 target. Got all special stuff tailored using pragma's now. A lot of searching but in the end it is working now.
The overall reason that the CPU got stuck inside the CRT was because I've got my assembly interrupt code defined inside the code_crt_init section which isn't allowed but I didn't know that it automatically was executing code inside this section
The overall reason that the CPU got stuck inside the CRT was because I've got my assembly interrupt code defined inside the code_crt_init section which isn't allowed but I didn't know that it automatically was executing code inside this section