Re: [cc65] Platform specific docs

Date view Thread view Subject view

From: Shawn Jefferson (shawnjefferson_at_24fightingchickens.com)
Date: 2003-10-27 21:03:37


On Sat, 18 Oct 2003 07:39:39 +0200, Ullric wrote:

>On Fri, Oct 17, 2003 at 01:14:46PM +0200, Christian Groessler wrote:
>> I've added a atari.sgml file with your docs to the CVS. You can get it
>> from the daily snapshot. Please take a look and tell me any omissions,
>> errors, improvements you might see.

Will there be some mention somewhere of the way the heap location is
calculated?  My writing on this subject was removed from the
atari.sgml file, I'm guessing because it is not platform specific.
However, this did trip me up a little when I went about moving
segments around in memory.

Here is an addition to the binary format section:

You can utilize multiple load segments in a cc65 executable by
inserting a segment header ($FF $FF <start memory address> <end memory
address> ).  Since the start address and end address of the first
segment is calculated in the crt0.s file from the initial load address
of your program (default is $2E00) and the end of the BSS segment, you
will either have to write your own crt0.s and link it to your program,
or reposition the segments in memory so that the default crt0.s
calculates the correct values.  An example of the later method
follows:

[segheader.s]:
    .import __CODE2_LOAD__, __AUTOSTRT_LOAD__

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

[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;
    SEGHDR: 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 = SEGHDR, 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;
}

With this setup I have two segments in my executable file that DOS
will load at $2000 and $8000 respectively, leaving the extended bank
window ($4000-$7FFF) alone.  Using this method you need to be careful
not to allocate too much memory since the BSS section is in the
smaller chunk of memory.  By carefully placing mycode into either
CODE, or CODE2 segments and not using malloc I was able to avoid any
potential problems.  As you can see, it may be easier to write your
own crt0.s file with the modified values.

[end]

Feel free to edit this, or change it around.  This was a first draft
and I probably didn't put things in the most succinct way possible.

Well, there you go.


--
Shawn Jefferson
----------------------------------------------------------------------
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 : 2003-10-27 21:06:44 CET