How to suppress increase in size if I switched from 48-Kbyte to 64 Kbyte?

Question:

When I switched from a 48-Kbyte ROM MCU to a 64-Kbyte ROM MCU in the R8C Series, the program size increased even though I am compiling the same program. How can I suppress this increase in size?

Answer:

Mostly likely, the movement of const variables from Area A (Figure-1) to Area B is the major cause of program size increase.
When the ROM size exceeds 64K bytes, the specified option changes from -R8C to -R8CE. Due to this option change, the const variable section changes from rom_NE (rom_NO) to rom_FE (rom_FO), and the location of the variables moves from Area A to Area B. (Refer to FAQ 106875 for more details.) The program size increases, because the address width that must be accessed for the variables in Area B is larger than that of Area A. This increase of program size can be suppressed to some degree by moving the const variables to Area A.

1. Specification of -fNROM

If compiler option -fNROM is specified, the default attribution of const variables will change from 'far' to 'near'.

The following example is the declaration of const variables without 'near(far)'. The location of these const variables can be changed from Area B to Area A by specifying -fNROM. (Please refer to FAQ 106875 for details.)

[Example]

const

int

i1 = 0;

const

char

c1 = 0;

If the const variables declared with ’far' don't have to be located in Area B, you should delete the ’far' declaration.

[Example]

const far

int

i2 = 0;

const

int

i2 = 0;

const far

char

c2 = 0;

const

char

c2 = 0;

2. Moving section excluding const variables to Area B

Area A may overflow when const variables are moved. When this occurs, it is necessary to move the section located in Area A by default to Area B. Refer to FAQ 106874 for instructions on how to move program sections to Area B. The program (program section) and Variable-Vector-Table (vector section), etc. can also be moved to Area B.