That should be useful. Thank you! ________________________________ From: Greg King <greg.king4@verizon.net> To: cc65@musoftware.de Sent: Friday, December 2, 2011 12:24 AM Subject: Re: [cc65] Reusing memory segment? From: "Karri Kaksonen"; on Tues., Nov. 22, 2011; at 10:22 AM -0500 > > 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 (e.g., CBM tape buffers) > > for several different purposes. Rather than access the memory > > through a pointer variable, I'd like to use an absolute address. > > How do I do that? > > Create a segment for that purpose, and give it an absolute address. > > In a configuration file: > MEMORY { > BUF1: start = $2400, size = $122C, file = ""; > BUF2: start = $2400, size = $122C, file = ""; > } > SEGMENTS { > TAPEBUFFER: load = BUF1, type = rw; > TEMPBUFFER: load = BUF2, type = rw; > } > > Later in the process of building your program, > you can use those buffers like this: > cl65 --data-segment=TAPEBUFFER -c tapebuffer.c > cl65 --data-segment=TEMPBUFFER -c tempbuffer.c > > Inside "tapebuffer.c", you can 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 that way, you don't need pointers, as the linker will take care of > re-using the space. Or, if you don't want to use a special configuration file, then you can use macroes to hide the absolute addresses: #define TAPE_BUFFER ((unsigned char*)0x033c) or #define TAPE_BUFFER ((unsigned char[192])0x033c) Then, you can use them as arrays: TAPE_BUFFER[location] = data; ... fwrite(TAPE_BUFFER, 1, 128, fd); ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail. ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Fri Dec 2 15:09:00 2011
This archive was generated by hypermail 2.1.8 : 2011-12-02 15:09:05 CET