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

From: Agent Friday <64subnet1gmail.com>
Date: 2010-11-02 06:52:41
On Mon, Nov 1, 2010 at 7:39 PM, Groepaz <groepaz@gmx.net> wrote:
>  On Dienstag 02 November 2010, you wrote:
> > What I need most are details about linking assembler-only projects,
> > and the format of the final binary.  I've created a config file
> > (shown below) that so far SEEMS to be pretty close to what I want,
> > which is all code in a single file ready to load at $8000.  What I'm
> > getting seems to only be missing the load address as the first 2
> > bytes of the file.
>
> look at the linker configs and respective startup files (crt0) for the c64 or
> other cbm targets. the HEADER segment is what you are missing :)

Thanks Groepaz, that enabled me to figure most of it out.  I had
run across that header segment code in the mail list archive, but it
didn't say where it came from.

Correct me if I'm wrong, but this seems to be mostly (or entirely)
absent from the documentation.  I doubt that I am the first to
stumble on this need.  IMO, if ca65 is to be used as one's primary
assembler and not just for code that supplements a cc65 project,
then the ability to generate a very simple binary file that can be
loaded directly into a stock machine is a must.  Seems like the
solution should be made obvious by the documentation, perhaps
even have its own built-in target tag.

So, I see in source\libsrc\c64\crt0.s that the BASIC stub is placed
in segment "EXEHDR", but I don't see anything in the way you invoke
ld65 or anything in the .cfg file that would cause that segment to
be linked.  Perhaps the "one symbol is referenced" rule means is
forcing the entire crt0 module to be linked; but in my recent
experience, putting code into a segment that is not listed in the
SEGMENTS statement of the config file normally causes an error (or
at least a warning) when I try to build/link it.  But this is not
what we see when compiling for a C64 target.

So I'm left to guess that the linker is performing some amount of
hidden "magic" to make it work, although I don't see why it couldn't
just as well be accomplished explicitly.  For example, if I wanted
to replicate this behavior on my own "target", would it be sufficient
to place an "EXEHDR" entry (or other name I've chosen for the stub)
as the the first item in the segments clause?

Which leads me to the next question...  Are the segments linked into
the final binary in the same order they are listed in the .cfg file?
I wonder how the "EXEHDR", or even the "STARTUP" segment, is trusted
to always appear as the very first thing in the file.

I'd like to help improve the documentation in this respect... Unless
Uz prefers I go about it differently, I would just type it up in the
wiki first, then identify places in the help files that could be
made clearer.

// Agent Friday
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Nov 2 06:52:48 2010

This archive was generated by hypermail 2.1.8 : 2010-11-02 06:52:52 CET