Re: [cc65] Bank Switching

Date view Thread view Subject view

From: Christian Groessler (cpg_at_aladdin.de)
Date: 2002-09-25 12:51:06


On 09/24/2002 04:13:20 PM MST "Shawn Jefferson" wrote:
>
>>>> Christian Groessler <cpg_at_aladdin.de> 09/20/02 04:22PM >>>
>
>>So with some linker and segments fiddling, one should be able to make
>>RAM2 a separate chunk in the file. The AUTOSTRT chunk should be last
>>(unless you know what you do), because I think it's address will be
>>called immediately after being loaded, before the remaining chunks get
>>loaded.
>
>Ok, I think I succeeded in setting this up with these files:
>
>atari.cfg:
>
>MEMORY {
>    ZP: start = $82, size = $7E, type = rw;
>    HEADER: start = $0000, size = $6, file = %O;
>    RAM1: start = $2000, size = $2000, file = %O;
>    BANK: start = $4000, size = $3FFF, type = ro;   # just to show the memory layout, not used
>    SECHDR: start = $8000, size = $4, file = %O;
>    RAM2: start = $8004, size = $3C1F, file = %O;
>}
>SEGMENTS {
>    EXEHDR: load = HEADER, type = wprot;
>    CODE: load = RAM1, type = wprot, define = yes;
>    BSS: load = RAM1, type = bss, define = yes;
>    CHKHDR: load = SECHDR, type = wprot;
>    RODATA: load = RAM2, type = wprot, define = yes;
>    DATA: load = RAM2, type = rw;
>    ZEROPAGE: load = ZP, type = zp;
>    AUTOSTRT: load = RAM2, type = wprot, define = yes;
>}
>
>and chunk.s:
>
>    .import __RODATA_LOAD__, __AUTOSTRT_LOAD__
>
>; CHUNK HEADER
>    .segment "CHKHDR"
>    .word __RODATA_LOAD__
>    .word __AUTOSTRT_LOAD__ - 1
>    .code
>    .reloc
>
>From looking at the source code for crt0.s in the atari library, the
>main header uses the values for CODE and BSS - 1 to create the
>header, so you are sort of stuck with putting the code and bss (what
>does that stand for?) in the first memory segment.  Unless there is a
>way to override this without recompiling the library.  The first

You'll only need to recompile and change crt0.s...

I think you can also free the 4 bytes at $8000, since they're part of
the load file format, but not loaded into memory. The start address of
SECHDR doesn't matter. So you could use

    SECHDR: start = $0, size = $4, file = %O;
    RAM2: start = $8000, size = $3C1F, file = %O;

I don't know whether the  linker complains if HEADER and SECHDR have
the same start address, if yes, you could take some other value for
SECHDR start address.

regards,
chris

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-09-25 12:51:24 CEST