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

From: Christian Grössler <>
Date: 2010-11-11 00:54:23

On 09.11.10 10:33, Oliver Schmidt wrote:
> Hi,
>> ... what about using the INIT feature for the startup code? This
>> code would be execute only once (clearing BSS and what not). So we put it
>> into a segment in the RAM area, after that an init to its start and then put
>> the rest of the code into another RAM area and put it after the init part.
> Just as a remark, here's what the Apple II code does (without any OS support):
> - The INIT segment is placed at the end of the binary. It gets loaded
> at the address range intended for the BSS.
> - The STARTUP code moves the INIT segment right after the BSS (where
> later the heap/stack will go).
> - The INIT segment content is called (having full access to the BSS to
> inititalize it).
> - Later the INIT segment gets overwritten by the heap/stack.
> This makes all programs somewhat larger (because of the move
> operation) but saves at actual runtime the whole INIT segment :-)

But still it has the footprint of the copy operation of the INIT segment :-)

I just looked at the crt0.s file for the Apple, and it's not really obvious
what you are doing there with the copies. With your explanation above
it was clear, but without it, I'd have to thing twice or thrice to see
what is going on. Some comments there would be nice (hint hint) :-)

Recently I was also thinking about leveraging the possibility to have
multiple independent load segments in an Atari exe file.

One idea was to have a "check load address" segment, which verifies that
the selected load address of the exe isn't too low and will overwrite parts
of DOS. Since I haven't found a way to abort the loading of the next memory
segment(s), all it could do is issue a warning, that the program overwrote
parts of DOS and the machine will later probably crash. At least better
than a crash without anything indicating the reason of the crash, IMO.

Another idea was to create a new "atarixl" configuration (similar to apple2
and apple2enh), which copies the ROM into it's underlying RAM and adds
some usable space there to the heap. Code for this was posted by Fatih Aygün
some time ago. The first exe load segment could do this and then be overwritten
by the later load segments of the program, therefore not using up memory
at runtime.
In this "atarixl" configuration, since we can expect a machine with 64k
of memory, the INIT segment could also be loaded after the BSS and not
consume runtime memory since it's residing on the stack area.

To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Nov 11 00:54:54 2010

This archive was generated by hypermail 2.1.8 : 2010-11-11 00:54:57 CET