Re: [cc65] Reusing memory segment?

From: Joseph Rose <rose.joseph121yahoo.com>
Date: 2011-11-22 19:29:07
Thank you!



________________________________
From: Karri Kaksonen <karri@sipo.fi>
To: cc65@musoftware.de 
Sent: Tuesday, November 22, 2011 10:22 AM
Subject: Re: [cc65] Reusing memory segment?


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 19:29:16 2011

This archive was generated by hypermail 2.1.8 : 2011-11-22 19:29:19 CET