In absolute addressing, the compiler generates two instructions to fetch the address of a variable. For example the compiler translates Source Code into the instructions in Generated Code.
int red;
int redsky;
void sky()
{
red = 1;
redsky = 2;
}
li r3,1 lis r4,red@ha addi r4,r4,red@l stw r3,0(r4) li r5,2 lis r6,redsky@ha addi r6,r6,redsky@l stw r5,0(r6)
Each variable access takes two instructions and a total of four bytes to make a simple assignment. If you set the small data threshold to be at least the size of an int data type, the compiler generates instructions to fetch variables with one instruction ( Fetching variables with one instruction).
li r3,1 stw r3,red li r4,2 stw r4,redsky
Because small data sections are limited in size you might not be able to put all of your application data into the small data and small data2 sections. We recommend that you make the threshold as high as possible until the linker reports that you have exceeded the size of the section.
If you do exceed the available small data space, consider using pooled data.
Because the linker can not deadstrip unused pooled data, you should:
The code in Zero Small Data Threshold has a zero small data threshold.
lis r3,...bss.0@ha addi r3,r3,...bss.0@l li r0,1 stw r0,0(r3) li r0,2 stw r0,4(r3)
When pooled data is implemented, the first used variable of either the .data , .bss or .rodata section gets a two-instruction fetch of the first variable in that section. Subsequent fetches in that function use the register containing the already-loaded section address with a calculated offset.