3-2 Program Sources and Sections

The object program that SH compiler generated will be the loadable module after it is linked with other object code like an assembled object code. Compiler also uses the section function which assembler has and divides to several sections according to the memory attribution of the code.

The default setting of the section name in the compiler are here. The default section names are shown here.

By using the same section name in the assembler program with C’s section, you can allocate it at the same memory area as the C language.

Section name can be temporarily changed by the #pragma section pre-processor instructions. The Specified section name is added to default section name. In this example, the section name of the instruction code become PEXT and the section name of variable “a” become BEXT in the sub1 function. In The sub2 function it returns to the previous. So the section name of the instruction code will be “P”.

It is also possible to change section names in units of compiled files. The top address in the section can be specified so it is effective when you want to divide and mount the program in on-chip and off-chip ROMs.

A variable with the initial value has the initial value in section D and the variable area is in section R. The variable area initialization is performed by the program. The HEW automatic generation function includes the section initialization program. If the automatic generation function is not used, a program must be created