Data Addressing. NXP CodeWarrior Development Studio
Reklaam
Reklaam
Data Addressing
21.3 Data Addressing
In absolute addressing, the compiler generates two instructions to fetch the address of a
variable. For example the compiler translates Listing 21-1 on page 372
into the instructions in
Listing 21-1. Source Code
int red; int redsky; void sky()
{
red = 1;
redsky = 2;
}
Listing 21-2. Generated Code
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 (
Listing 21-3. 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:
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
372 Freescale Semiconductor, Inc.
Laadi alla
Reklaam