Thursday, March 10, 2011

Testing sdcc

Downloaded sdcc-src-3.0.0.tar.bz2

Disable pic support which requires gputils):

./configure --disable-pic-port --disable-pic16-port

Created a couple of C files and compiled/linked - refer to the docs - file containing the main() function MUST be the FIRST file specified in the command line:

sdcc -mz80 -c junk.c
sdcc -mz80 -c main.c
sdcc -mz80 -o crap.ihx main.rel junk.rel

Create a binary:
srec_cat crap.ihx -intel -o sadf.bin -binary

Examine the binary (unused locations are filled with 0's):
z80dasm.exe -l -g 0x0 sadf.bin | less

When sdcc, the compiler front-end, calls the linker it will cause a copy of the default linker settings to be created in the working directory (file ends with ".lnk" which will show that a crt0 module has been linked from

/usr/local/bin/../share/sdcc/lib/z80/crt0.rel

The correponding source crto.S can be found here:

/usr/local/bin/../share/sdcc/lib/src/z80/crt0.s

Examination of crto.s shows that it includes the Z80 interrupt vectors.

I will use --no-std-crt0 and provide my own crt0.rel

And here apparently is how we create and use a custom linker script::
If you want to make a custom linker script, build a dummy application and copy the script generated by SDCC. Edit the file and then call the linker directly instead of using SDCC (compile the modules individually using SDCC, then link with aslink). Be careful that you copy the linker script to someplace other than your build output directory, otherwise SDCC might accidentally overwrite it.

Not having any luck yet running sdld on it's own.

No comments:

Post a Comment