Everything

-pid


< Compile Options / Microcontroller Options >

[Format]

-pid[={ 16 | 32 }]

 

-

[Default]

The constant area sections C_8, C, C_2, and C_1, the literal section L, and the switch statement branch table sections W, W_2, and W_1 are not handled as PID (position independent data).

[Description]

-

The constant area sections C_8, C, C_2, and C_1, the literal section L, and the switch statement branch table sections W, W_2, and W_1 are handled as PID (position independent data).

-

PID can be accessed through a relative address from the PID register. This allows PID to be located at a desired address after linkage.

-

A single general register is used to implement the PID function.

-

<PID register>

-

Based on the rules in the following table, one register from among R9 to R13 is selected according to the specification of the fint_register option. If the fint_register option is not specified, R13 is selected.

Table 2.10

Correspondences between fint_register Options and PID Registers

fint_register Option

PID Register

No fint_register specification

R13

fint_register = 0

fint_register = 1

R12

fint_register = 2

R11

fint_register = 3

R10

fint_register = 4

R9

-

The PID register can be used only for the purpose of PID access.

-

<Parameters>

-

The parameter selects the maximum bit width of the offset when accessing the constant area section from the PID register as 16 bits or 32 bits.

-

The default for this option when the offset width is omitted is pid=16. When pid=16 is specified, the size of the constant area section that can be accessed by the PID register is limited to 64 Kbytes to 256 Kbytes (varies depending on the access width). When pid=32 is specified, there is no limitation of the size of the constant area section that can be accessed by the PID register, but the size of the code accessing PID is increased.

-

Note that when pid=32 and the map option with valid external symbol-allocation information are specified at the same time, the allocation information causes code the same as if pid=16 was specified to be generated if access by the PID register is possible.

[Examples]

-

Accessing an externally referenced symbol that is const qualified

extern const int pid;
int work;
void func1()
{
        work = pid;
}
[Without -pid]
_func1:
            MOV.L       #_pid,R4
            MOV.L       [R4],R5
            MOV.L       #_work,R4
            MOV.L       R5,[R4]
            RTS
[With -pid=16] (only when the PID register is R13)
_func1:
            MOV.L       _pid-__PID_TOP:16[R13],R5
            MOV.L       #_work,R4
            MOV.L       R5,[R4]
            RTS
            .glb        __PID_TOP
[With -pid=32] (only when the PID register is R13)
_func1:
            ADD         #(_pid-__PID_TOP),R13,R6
            MOV.L       [R6],R5
            MOV.L       #_work,R4
            MOV.L       R5,[R4]
            RTS
            .glb        __PID_TOP

-

Acquiring the address of an externally defined symbol that is const qualified

extern const int pid = 1000;
const int *ptr;
void func2()
{
        ptr = &pid;
}
[Without -pid]
_func2:
            MOV.L       #_ptr,R4
            MOV.L       #_pid,[R4]
            RTS
[With -pid] (only when the PID register is R13)
_func2:
            ADD         #(_pid-__PID_TOP),R13,R5
            MOV.L       #_ptr,R4
            MOV.L       R5,[R4]
            RTS
            .glb        __PID_TOP

[Remarks]

-

The address of an area which is PID should not be used in the initialization expression used for static initialization. If used, error E0523027 will occur.

-

<Example of using a PID address for static initialization>

extern const int pid_data1;          /* Becomes PID */
const int *ptr1_for_pid = &pid_data1;/* Uses PID address in static initialization: Error */
const int pid_data4[] = {1,2,3,4};   /* Becomes PID */
const int *ptr2_for_pid = pid_data4; /* Uses PID address in static initialization: Error */

-

When creating a code for startup of the application program using the PID function, refer to Application Startup, instead of Startup.

-

When the pid option is selected, the same external variables in different files all have to be const qualified. This is because the pid option is used to specify const qualified variables as PID. The pid option (PID function) should not be used when there may be an external variable that is not const qualified.

-

If the map=<file name> option is enabled while the pid option is selected, warning W0530809 may be output when there is an externally referenced variable that is not const qualified but used in different files as the same external variable. In the case, the displayed variable is handled as PID.

-

In C++ or EC++ compilation, the pid option cannot be selected. If selected, message W0511171 is output as a warning and the selection of the pid option is disabled.

-

When the pid option is selected, base=rom=<register> cannot be selected. If selected, message W0551149 is output as a warning and the selection of base=rom=<register> is disabled.

-

If a PID register selected by the pid option is also specified by the base option, warning W0511149 will occur.

-

If the pid option and nouse_pid_register option are selected simultaneously, error E0511150 will occur.

-

For details of the application and PID function, refer to Usage of PIC/PID Function.