Monday, March 14, 2011

SDCC Makefile

Created small test project for sdcc to target the Z80. It links a custom crt0, and explicitly sets the locations for the code and data segment. There are two C files linked. Here is the makefile:


all: ga0.bin ga0.dasm

ga0.bin: ga0.ihx
srec_cat ga0.ihx -intel -o ga0.bin -binary

junk.rel: junk.c
sdcc -mz80 -c junk.c

main.rel: main.c
sdcc -mz80 -c main.c

mycrt.rel: crt0.s
sdasz80 -l -o mycrt.rel crt0.s

ga0.ihx: main.rel junk.rel mycrt.rel
sdcc --no-std-crt0 --code-loc 0x0200 --data-loc 0x1000 \
-V -mz80 -o ga0.ihx mycrt.rel main.rel junk.rel
# -V -mz80 -o ga0.ihx main.rel junk.rel mycrt.rel

ga0.dasm: ga0.bin
z80dasm -t -g 0x0 -l ga0.bin -o ga0.dasm

clean:
rm -f *\.rel *\.ihx *\.sym *\.lst *\.map *\.noi ga0.bin *\.dasm

The file junk.c contains a constant string so that I can verify that it goes in ROM e.g.

const char testing[]= "asdf";

I disassembled the resulting binary using z80dasm and everything seems to be where it ought.

There are some helpful discussion threads on the mailing list regarding the Z80 target.

No comments:

Post a Comment