Re: [cc65] Reusing memory segment?

From: Karri Kaksonen <karri1sipo.fi>
Date: 2011-11-22 16:22:11
On 11/22/2011 04:43 PM, Joseph Rose wrote:
> Let's say I'm working on a big project and need a temporary buffer 
> and can reuse the same section of memory (i.e. CBM tape buffers) for 
> several different purposes.  Rather than access the memory through a 
> pointer, I'd like to use an absolute address.  How do I do that?
> --
> Joseph Rose, a.k.a. Harry Potter
> Working magic in the computer community

Create a segment for that purpose and give it an absolute address.

In the configuration file:

MEMORY {
     BUF1: start = $2400, size = $122C, define = yes, file = %O;
     BUF2: start = $2400, size = $122C, define = yes, file = %O;
}

SEGMENTS {
     TAPEBUFFER: load = BUF1, type = rw, define = yes;
     TEMPBUFFER: load = BUF2, type = rw, define = yes;
}

Later in the code you can use these buffers like this:

cc65 --data-segment=TAPEBUFFER tapebuffer.c

cc65 --data-segment=TEMPBUFFER tempbuffer.c

Inside tapebuffer.c you can then allocate space for your data.

int abc;
char name[48];

In tempbuffer.c you can allocate some other data.

char b;
char c;
int d[10];

In this way you don't need pointers as the linker will take care of 
re-using the space.

--
Karri


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Nov 22 17:03:54 2011

This archive was generated by hypermail 2.1.8 : 2011-11-22 17:03:57 CET