Re: [cc65] Link Options and Atari Bank Switching...

From: Shawn Jefferson <jefferson_shawn_a8bit1yahoo.com>
Date: 2004-03-04 18:05:26
Hi Chris,

"Martin, Chris" <cmartin@ti.com> wrote:Hello,

>I have some code that uses the Atari 130XE bank 
>switching to do some things. In my link.cfg file, I 
>have basically defined all code to be placed between 
>the 0x8000 and 0xbc1f address space. However, my code

>has grown to a point where it will no longer fit in 
>this space. 

I did exactly this with one of my projects.

>I would like to place code in the address spaces:
>0x2800-0x3fff and 0x8000-0xbc1f. I am not sure 
>exactly how to break this up.

Here's the linker config file from my project:

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;
    SECHDR: start = $0000, size = $4, file = %O;
    RAM2: start = $8000, 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;
    CODE2: load = RAM2, type = wprot, define = yes;
    DATA: load = RAM2, type = rw;
    RODATA: load = RAM2, type = wprot;
    ZEROPAGE: load = ZP, type = zp;
    AUTOSTRT: load = RAM2, type = wprot, define = yes;
}
FEATURES {
    CONDES: segment = RODATA,
	    type = constructor,
	    label = __CONSTRUCTOR_TABLE__,
	    count = __CONSTRUCTOR_COUNT__;
    CONDES: segment = RODATA,
	    type = destructor,
	    label = __DESTRUCTOR_TABLE__,
	    count = __DESTRUCTOR_COUNT__;
}
SYMBOLS {
    __STACKSIZE__ = $800;       # 2K stack
}

Then you can control where code is placed with:
#pragma codeseg("CODE2")

But there are several things you need to watch out
for:

1. The standard crt0.s file (startup code) calculates
the BSS segment and the autostart segement assuming
the standard linker configuration.  That is why my
segments above are arranged in the manner they are.

2. When the atari loads the file it loads it at the
start address and loads it contiguously.  You need to
somehow account for the big space at $4000-7FFF. 
Luckily the atari can do multiple load segments in one
file.  That is the point of the SECHDR stuff above.

Here's a file that is linked to my project to
accomplish that:

    .import __CODE2_LOAD__, __AUTOSTRT_LOAD__

; CHUNK HEADER
    .segment "CHKHDR"
    .word __CODE2_LOAD__
    .word __AUTOSTRT_LOAD__ - 1
    .code
    .reloc

My project left the $4000-7FFF area alone so that I
could use it all for data storage.  If you are going
to place code there then you will have to do something
similiar but have some way to load the additional code
to the extended memory yourself (from an external file
I think.)  You may be able to make use of the init
vector of an atari executable for this function
perhaps... never tried that myself.



__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Mar 4 18:06:01 2004

This archive was generated by hypermail 2.1.8 : 2004-03-04 18:06:07 CET