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.
This optimizes access to external variables. It outputs code that accesses frequently accessed external variables relative to the EP.
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.
#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).