Hi all,

I am targeting a Z80 based system, the sound board of an arcade game. The
memory map has a 2kB RAM chip at $C000~$C7FF. I have little experience with
setting up linkers and Chat GPT is not really helping. The little code I
have written is here
<https://github.com/jotego/jtcores/tree/flstory-894/cores/flstory/custom>.

I need to use a separate crt0.s start up code in order to set up the stack
pointer:

    .module crt0
>     .area _HEADER (ABS)
>     .org 0x0000          ; Reset vector at 0x0000
>     jp _start            ; Jump to main program
>
>     .area _CODE
>     .globl _main
> _start:
>     ld sp, #0xC800       ; Set stack pointer at top of RAM (grows downward)
>     jp _main
>

 That gets executed first indeed. But the main function gets mapped quite
low in the address space, at $20 regardless of my request to start at $100

sdcc -mz80* --code-loc 0x0100 *--data-loc 0xC000 -c custom.c

If I create any global variable in the C file, it gets placed in the ROM
area, not in the RAM, which I have stated in the argument list* --data-loc
0xC000*

I need to link the C file to the assembly code for the stack pointer. Maybe
the linker is getting it wrong there. I am giving this input file to the
linker

MEMORY {
>     ROM (rx) : ORIGIN = 0x0000, LENGTH = 0x4000
>     RAM (rw) : ORIGIN = 0xC000, LENGTH = 0x0800
> }
>
> SECTIONS {
>     .text : { *(.text) } > ROM
>     .rodata : { *(.rodata) } > ROM
>     .data : { *(.data) } > RAM
>     .bss : { *(.bss) } > RAM
> }
>

Where data is said again to be placed above $C000. But this gets ignored
without any warnings.

I have no idea what sdcc expects from the input besides this. Any help will
be appreciated.

Thanks,
Jose Tejada, aka JOTEGO
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to