Re: [cc65] How to find highest address of my C code?

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2012-01-04 00:09:06
Hi!

On Tue, Jan 03, 2012 at 11:54:08PM +0100, Johan Kotlinski wrote:
> I'm trying to achieve something, but not sure how to go about it.
> The idea is that I want to use all available RAM for a particular
> temporary buffer that should end at $8000. The problem is that I don't
> know how to tell where the buffer should start, i.e., what is the
> highest address used by my CC65 code. From map file, I can see that
> RODATA segment ends at 0x5959. But how can I "find" this address from
> within my C code?

Add "define = yes" to the segment in the linker config. See

    http://www.cc65.org/snapshot-doc/ld65-5.html#ss5.2

for the symbols defined. Since the symbols start with an underscore, they can
be accessed from C. But beware: They're addresses. Example:

/* The following two are defined by the linker */
extern unsigned char _RODATA_RUN__;
extern unsigned char _RODATA_SIZE__;
                                                 
/* Some defines for easier reading ... */
#define RODATA_START    ((unsigned) &_RODATA_RUN__)
#define RODATA_SIZE     ((unsigned) &_RODATA_SIZE__)
#define RODATA_END      (RODATA_START + RODATA_SIZE)

You can use the symbols for the memory area in a similar way. There's an
additional "__NAME_FILL__" symbol which tells, how much space in the memory
area was actually used.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Jan 4 00:09:14 2012

This archive was generated by hypermail 2.1.8 : 2012-01-04 00:09:17 CET