Everything
A.1.1.2 EP relative access

You can reduce the code size by locating variables in a section that can be accessed via the element pointer (EP) and a sld/sst instruction or ld/st instruction. You can locate variables in a section that can be accessed relative to the EP using the following methods.

(1)

Specifying the -Omap/-Osmap option

This optimizes access to external variables. It outputs code that accesses frequently accessed external variables relative to the EP.

(2)

#pragma section directive

Use a #pragma section directive when defining or accessing variables, and specify either ep_disp4, ep_disp5, ep_disp7, ep_disp8, ep_disp16, ep_disp23, or ep_auto as the attribute string.

Note

ep_disp32 does not have an effect to reduce the code size.

 

#pragma section attribute-strings
variable-declaration/definition
#pragma section default

Example 1.

Accessing via a EP-relative 2-byte load/store instruction

#pragma section ep_disp4
int a = 1;              /*allocated to .tdata4 section*/
int b;                  /*allocated to .tbss4 section*/
#pragma section default

Even if ep_disp5, ep_disp7, or ep_disp8 is specified as the attribute string, access is via an EP-relative 2-byte load/store instruction (i.e. is the same as in the case of ep_disp4).

 

Example 2.

Accessing via a EP-relative 4-byte load/store instruction

#pragma section ep_disp16
int a = 1;              /*allocated to .edata section*/
int b;                  /*allocated to .ebss section*/
#pragma section default

 

Example 3.

Accessing via a EP-relative 6-byte load/store instruction

#pragma section ep_disp23
int a = 1;              /*allocated to .edata23 section*/
int b;                  /*allocated to .ebss23 section*/
#pragma section default