The variable was placed in zero page by a #pragma, so this was expected. The small memory model is specified in the compiler command line arguments (-Ms).
prm file listed below.
------------------------------------------------------------------------------------------------------------------------------------------------------------
/* This is a linker parameter file for the mc9s08ll8 */
NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
NO_INIT_Z_RAM = NO_INIT 0x0060 TO 0x0061;
Z_RAM = READ_WRITE 0x0062 TO 0x00FF;
RAM = READ_WRITE 0x0100 TO 0x087F;
ROM = READ_ONLY 0xD800 TO 0xFFAD;
ROM1 = READ_ONLY 0xFFC0 TO 0xFFD7;
/* INTVECTS = READ_ONLY 0xFFD8 TO 0xFFFF; Reserved for Interrupt Vectors */
END
PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */
DEFAULT_RAM, /* non-zero page variables */
INTO RAM;
_PRESTART, /* startup code */
STARTUP, /* startup data structures */
ROM_VAR, /* constant variables */
STRINGS, /* string literals */
VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */
DEFAULT_ROM,
COPY /* copy down information: how to initialize variables */
INTO ROM; /* ,ROM1: To use "ROM1" as well, pass the option -OnB=b to the compiler */
NI_ZEROPAGE INTO NO_INIT_Z_RAM;
_DATA_ZEROPAGE, /* zero page variables */
MY_ZEROPAGE INTO Z_RAM;
END
ENTRIES
credit /* Force inclusion of unused variable */
END
STACKSIZE 0x50
VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */
------------------------------------------------------------------------------------------------------------------------------------------------------------
I have two const unsigned char[] and one const unsigned short[] that are correctly being located in ROM.
From the map file,
log_table D892 22 34 5 .rodata
digit D8B4 A 10 2 .rodata
credit D8BE 2B 43 0 .rodata
I have not run out of space. In fact I have recently reduced the code size by removing no longer needed functionality.
Also from the map file,
Summary of section sizes per section type:
READ_ONLY (R): 20CE (dec: 8398)
READ_WRITE (R/W): 118 (dec: 280)
NO_INIT (N/I): 9C (dec: 156)
It is just,
const unsigned char proportional_band = 100;
that is not getting alloccated anywhere.
bigmac wrote,
"Even though the map file may list the variable as not (yet) used, the linker is likely to be allocating the variable, and its address needs to be confirmed."
How can I tell if the linker is allocating the variable and where?