Re: [cc65] static memory allocation question

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2001-08-31 15:00:43


On Fri, Aug 31, 2001 at 02:31:18PM +0200, Arvid Norberg wrote:
> Right now I just use the memory at 0x3000, but it is not a good idea, as the
> compiler puts other static data in that memory that gets destroyed by my
> characters.
> Is there a way to tell the compiler to leave some memory unused for these
> kind of things?
> Or is there another way it should be done?

What I would do is to use a special memory configuration for the linker.
Probably the easiest way is to place the character data above all other data
and add an alignment to the memory area, so it will be on a 1K boundary. The
disadvantage is that further measures, the pad data will also go into the
output file.

Another possibility would be to allocate $7FF bytes for the character data,
and place the actual data at the beginning. An area of size $7FF bytes will
always contain a 1K block on a 1K boundary, so all you have to do is to move
the 1K of character data inside the (almost 2K) block to the proper address.
You will waste nearly 1K when doing this, but it avoids changing the linker
config (and you waste nearly 1K worst case with all other methods as well).

Like this:

chardata.s:
----------------------------------------------------------------------------
       	.export	 _chardata_orig
       	.export	 _chardata

       	; Export symbol for 1K boundary inside this module
       	_chardata = (_chardata_orig + $3FF) .bitand .bitnot $3FF

       	.data
chardata_orig:
        .include "chardata.bin"	 	; The actual character data (1K)
       	.res	 $3FF	  	 	; Empty space
----------------------------------------------------------------------------

Your C initialization code would then do something like

----------------------------------------------------------------------------
   	extern const char chardata_orig[];
   	extern char chardata[];

   	...
   	memmove (chardata, chardata_orig, $400);
   	...
----------------------------------------------------------------------------

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 : 2001-12-14 22:05:42 CET