[cc65] cfg-files and the linker and so on..

From: Mats Andrén <matan3251student.liu.se>
Date: 2004-09-25 16:55:12
Hello!

Yet another one (me) trying to get into cc65...

I'm coding a tool for C64 and I want to place a specific part of the
code at $1000 in memory (a music player). That part is 100% assembler
and the size of it is not know beforehand, but simply depends on how
big that part of the source becomes. Except for that I want to let
cc65 decide where to put the rest of the program (and editor for the
musicplayer, diskdrive-code and so on) which will be written mostly in
C. As a first step I modified the C64.cfg file a bit to look like
this:

MEMORY {
    ZP: start = $02, size = $1A, type = rw, define = yes;
    LORAM: 
        start  = $07ff
        size   = $0801
        fill   = yes
        define = yes;
    PLAYERRAM:
        start  = $1000
        size   = $1000
        fill   = yes
        define = yes;
    RAM:
        start  = $2000
        size   = $a000
        define = yes;
}

SEGMENTS {
    STARTUP:
        load = LORAM, type = wprot;
    LOWCODE: 
        load = LORAM
        type = wprot
        optional = yes;
    CODE:
        load = RAM, type = wprot;
    RODATA:
        load = RAM, type = wprot;
    DATA:
        load = RAM, type = rw;
    BSS:
        load = RAM, type = bss
        define = yes;
    ZEROPAGE:
        load = ZP, type = zp;
}

FEATURES {
    CONDES:
        segment = RODATA,
            type = constructor,
            label = __CONSTRUCTOR_TABLE__,
            count = __CONSTRUCTOR_COUNT__;
    CONDES:
        segment = RODATA,
            type = destructor,
            label = __DESTRUCTOR_TABLE__,
            count = __DESTRUCTOR_COUNT__;
    # condes functions with type 2 are called in the interrupt
    CONDES:
        segment = RODATA,
            type = 2,
            label = __IRQFUNC_TABLE__,
            count = __IRQFUNC_COUNT__;
}

SYMBOLS {
    __STACKSIZE__ = $800;       # 2K stack
}

This works nicely, but the RAM area after the startupcode
($08xx-$0fff) is now unused since the editor code segment currently
starts at $2000. Now let's say that I'd like to be able to simply
relocate the asm-player-code to some other adress, like $6000 or
whatever, then I'd obviously like to have some of the editor-code
going before that segment and some of it after it since the memory
after the player-code would be to small to hold the complete editor code.
Is that possible somehow, or am I asking too much? Perhaps I have to
do this by myself, by changing here and there in my C code where
different parts of the C code should go, so some of it ends up before
the player and some of it ends up after it?

Also, the size of the asm-player-code is not really known, but changes
as I do changes to the player-code. Could the linker (or something
else) somehow detect where the playercode ends and automatically make
the C code start right after it, without me having to explicitly
define beforehand how big the asm-player-code-segment should be in the
cfg-file?

Also, should I really be required to have that "fill = yes"-snippet in
the cfg-file to make the linker understand that I don't want a binary
that only contains the code I've actually written, but that I actually
want it to automatically end up at those places in memory that I have
specified in the cfg-file, with chunks of empty space in between? I
thought "load = $xxxx" was supposed to take care of that?

I am really new to cc65 (even though I have used ca65 a bit before),
so please bear with me if I'm just confused and do not make sense.

Any suggestion for a better cfg-file for me?

Have a nice day!

/Mats

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Sep 25 16:53:49 2004

This archive was generated by hypermail 2.1.8 : 2004-09-25 16:53:58 CEST