Re: [cc65] Bank Switching

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2002-09-21 00:13:57


On Thu, Sep 19, 2002 at 04:02:33PM -0700, Shawn Jefferson wrote:
> Ok, I took a look at the linker config file.  Would setting up the memory
> areas like this work?

As far as I remember, the "type = empty" specification is only allowed for
segments, not for memory areas. If you don't want to place any segments into
this memory area, just drop the line, it is not needed.

> This might be a stupid question but since I know little about how compilers
> work I'll ask anyway: Is there a way to allow the code to go into both RAM1
> and RAM2 if it overflows one area?  I didn't see anything in the ld65.html doc
> that shows that type of setup.

This has nothing to do with compilers in general, it is a ld65 specific
question. And the answer is "no": while this feature would be useful
sometimes, it would also be rather complex to implement. And, having this
feature, there would again be people asking why the linker is not able to
optimize section placement so that each memory area reaches an optimal fill
level (a section is the part from one segment that comes from one object
file). So for now, you will have to do placement manually.

> Using the bank section on the atari from cc65 seems like it will be a bear.
> Only 15k in RAM2, and 8k in RAM1! Maybe it would be better to use RAM2 for
> code, and RAM1 for rodata, data, bss.

You can also place code from some modules in other segments using the
--code-name option for the compiler. An example would be to use

        --code-name CODE2

for some of your modules and then use a linker config line like

    CODE2: load = RAM1, type = wprot;

to place this segment into the RAM1 area. Or, for even more flexibility, place
the code from *each* module in a different segment, for example by using this
makefile rule:

.c.o:
  	@echo $<
       	@$(CC) -Oirs --code-name CODE_$(basename $<) -t $(SYS) -I../include/ $<
	@$(AS) $(basename $<).s

This will place the code from a module named foo.c into a segment named
CODE_foo, and code from bar.c into CODE_bar. Using the map file, you can later
move the segment to reach an optimal fill level for each memory segment. One
could also think of a tool that uses information from the map file to generate
an optimal linker config...

Please do also note that you may have to modify the startup file and be
careful to load everything into the right place. If, for example, the code for
RAM1 and RAM2 goes into the same file, you will have to make sure that the
first 8K from the file are loaded into low memory, while the last 15K are
loaded into high memory. The linker will just write the data to the file, it
is not involved when loading the data!

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-09-21 00:14:14 CEST