Re: [cc65] Multi-purpose memory layout, ca65, ld65

From: Gábor Lénárt <lgb1lgb.hu>
Date: 2011-01-12 16:10:07
Hi,

On Wed, Jan 12, 2011 at 04:45:49PM +0200, Karri Kaksonen wrote:
> The config file can be used for this purpose.
> 
> Put that large amount of data into a segment
> 
> .segment "MYDATA_RODATA"
> 
> In the cfg file place this segment to some address
> MEMORY {
>   GRAPHICS_DATA: start = $200, size = $200, define = yes, file =%O;
>   BSS_DATA: start = $200, size = $400, define = yes, file =%O;
> }
> SEGMENTS {
>   MYDATA_RODATA: load = GRAPHICS_DATA, type = ro, define = yes;
> }
> 
> When you later want to use this for BSS you can write:
> 
> SEGMENTS {
>   BSS: load = BSS_DATA, type = bss, define = yes;
> }
> 
> Now GRAPHICS_DATA and BSS_DATA segments overlap. Does this help?

Yes, kiitos [ok my basic level Finnish knowledge is off-topic here I guess]
:) However, my problem that it's a bit uncomfortable to generate the proper
linker config file this way, if it's not only an example (or maybe only I am
the one who can't understand it too much).  Let me explain the situation a
bit.  I have a program which can be loaded&run on C64, with the usual 'basic
stub' solution.  So I have got segment called BASICSTUB as the first item
inside SEGMENTS.  It's a must, since it must be at the beginning.  But since
I don't know the exact size of that segment as a constant value, it's hard
to use numbers for "start" inside MEMORY, and I guess I can't use it in a
tricky way that I put __SEGXYZ_[SIZE|LOAD|RUN]__ and similar things after
"start =" in part "MEMORY" of the linker config file.  Of course, I can say,
that I can count the size of the basic stub, so I can use a value, but I
would like to know if there is an "elegant" solution for this, without _ANY_
hard coded addresses in the linker file, other than the start of the "RAM"
which is something depends on the CBM target ($7FF on C64, if you put the
load addr as word into it too as the first word).

Your example is great, but it lacks the "real environment" when you don't
know the exact starting address of GRAPHICS_DATA, since basic stub must be
the first (well, if there is no better solution I can use the basic stub
itself too as BSS, just then I can't rerun my program if I "exit" to basic
(overwriting graphics_data is not a problem since it's copied to a place
which is consistent then, and I signal with a byte in the zero page, that
I've already copied that if someone issue "RUN" command again after exiting.
Though it's not _that_ serious problem, I can live with this issue)

I'm sorry if I misunderstood something ...

- Gábor
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Jan 12 16:10:21 2011

This archive was generated by hypermail 2.1.8 : 2011-01-12 16:10:23 CET