Re: [cc65] ca65 for stand-alone asm projects

From: Daniel Serpell <daniel.serpell1gmail.com>
Date: 2010-11-06 03:30:13
Hi,

On Fri, Nov 5, 2010 at 7:16 PM, Agent Friday <64subnet@gmail.com> wrote:
[...]
>
> I don't want to go into huge detail in the list at this point, but
> I think that the load address "header" should perhaps be part of a
> file format specification.  Those 2 bytes should in no way disrupt
> the correct specification of either a memeory area or where the code
> segment is actually going to be loaded.

But this is not needed if you use a proper linker config file, as the
header is in a different section. This is flexible, portable and
really simple.

Perhaps what you really need is an option to cl65 to use a "small"
linker config and a small startup library, so you can simply write:
  cl65 -t c64-asm myFile.s

or:
  cl65 -t atari-asm myFile.s

I use the following assembly file as a header for atari:

; ------------------------------------------------------------------------
; EXE header and trailer
;
        .import __CODE_LOAD__, __BSS_LOAD__
        .import _start

        .segment "EXEHDR"
        .word   $FFFF
        .word   __CODE_LOAD__
        .word   __BSS_LOAD__ - 1

        .segment "AUTOSTRT"
        .word   $02E0
        .word   $02E1
        .word   _start
; ------------------------------------------------------------------------

Then, I simply link the header and my own files, which
define the "_start" symbol as entry-point. The linker config
file simply adds the header and trailer to the code:

# Atari file format, without initializations.
FEATURES {
    STARTADDRESS: default = $2E00;
}
MEMORY {
    ZP:      start = $0082, size = $007E, type = rw, define = yes;
    HEADER:  start = $0000, size = $0006, file = %O;
    RAM:     start = %S,    size = $BC20 - %S, file = %O;
    TRAILER: start = $0000, size = $0006, file = %O;
}
SEGMENTS {
    EXEHDR:   load = HEADER,  type = ro;
    CODE:     load = RAM,     type = ro, define = yes;
    RODATA:   load = RAM,     type = ro;
    DATA:     load = RAM,     type = rw;
    BSS:      load = RAM,     type = bss, define = yes;
    ZEROPAGE: load = ZP,      type = zp;
    AUTOSTRT: load = TRAILER, type = ro;
}

Adding headers and linker scripts for all target could
simplify assembly development.

Attached is a patch that adds a new target, named
"atari-asm" with this simple header and linker config
file.

The problem is that I couldn't force the linker to always
import a symbol, so you have to still add to your
assembly files the directive "forceimport _header".

    Daniel.

----------------------------------------------------------------------
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 Nov 6 03:30:21 2010

This archive was generated by hypermail 2.1.8 : 2010-11-06 03:30:25 CET