Re: Calypsi C compiler toolchain for 6502 and 65816
Posted: Sat May 14, 2022 3:09 am
hth313 wrote:
The startup code is provided with the product, both in precompiled form in the library and as source code. This code is short and cruical to get the system initialized properly before you enter the main() function. It is not only doing data copying, it is also clearing variables that are 0 initialized. There may also be multiple areas that needs to be initialized.
hth313 wrote:
What output format do you use? Many formats (e.g. ELF, intel-hex, S-records) contain a concept of an entry point that is supported. If you are doing Commodore PRG then https://github.com/hth313/Calypsi-6502-Commodore may offer some inspiration, though it is for 6502.
to be more specific my custom header is 32 bytes large, first 4 bytes are a hardwired magic number (0x65C81600 in this case), next is a 32-bit address that defines where in memory the program should be loaded into, next is the total amount of bytes to load (32-bit value), and the last one is a 32-bit address that specifies where execution should jump to after loading is done, in order to start the program.
hth313 wrote:
The linker error is because __program_start which is the first executable address must reside in bank 00 as the reset vector is 16 bits, but it seems you have placed it in bank 02. This should be section 'code'.
there is no reason to have it load code into bank 0 since the boot ROM will automatically do a long jump to the header specified address after the whole program has been loaded into memory.
the startup code should never have to deal with any of the vectors at all, since they are hardwired in the boot ROM.
so i'll modify the startup code to just remove the whole reset section, and put the address of __program_start into the header, hopefully that works.
though the assembler syntax will take some getting used to. plus it's like 5 in the morning here and i haven't slept yet, so i'll do all of that after a quick nap.
thanks for helping me getting this running