Re: [cc65] ca65 question

From: <silverdr1inet.com.pl>
Date: 2008-01-21 18:12:17
On 2008-01-21, at 08:29, Ullrich von Bassewitz wrote:

>
> Good morning!

Good afternoon ;-) and thank you very much for the quick answers!

[...]

> A simple config file to start with would be:
>
> ----------------------------------------------------------------------
> MEMORY {
>     RAM: start = $07FF, size = $C801, file = %O, define = yes;
> }
> SEGMENTS {
>     BASICSTUB: load = RAM, type = ro;
>     CODE:      load = RAM, type = ro;
>     DATA:      load = RAM, type = rw;
> }
> ----------------------------------------------------------------------
>
> This will create 3 segments: One for the basic stub placed at the  
> start of the
> program, one for code, and one for data.

I think I finally start to understand how it works... The segments  
are stored in the binary file in the order specified within the  
"SEGMENTS" stanza, right? It means if I change the order within the  
stanza, it will affect the order of storing the segments, right?

And since all segments should "load" into "RAM" of "MEMORY", they get  
assembled (or rather relocated) relative to the RAM specification.  
Since RAM is specified to start at $07ff and I add two bytes at the  
beginning of the first-to-store segment:

	.word basicstub
basicstub:
	.word _nextline
	[...]

those two bytes get relocated to $07ff but are eventually skipped by  
the LOAD routines (used for load address) and since they point to  
($07ff + 2 bytes) - in the end I get what I need ($0801), right?

I'd say it is somewhat counterintuitive to me but I hope I got it  
correctly in the end?
The question - can I fully rely on this behaviour or are there still  
other factors, which may affect the (re)location of the code upon  
linking?

Another question - how is it done that compiled and linked C programs  
don't require special care about LOAD pointer bytes? Can I use some  
implicit behaviour to achieve the same or is it part of the c64 (or  
other for other systems) library, which gets linked in the STARTUP  
and actually does similar thing to what I do in the BASICSTUB?

> It assumes that zeropage locations
> are addressed directly.

Could you be so kind as to elaborate still a bit on this?

Best regards,

P.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Jan 21 18:11:46 2008

This archive was generated by hypermail 2.1.8 : 2008-01-21 18:11:49 CET