There are two types of constants with ARM: rodata and literal pools.
The rodata is used for stuff marked "const" in C, and the literal
pool is used for large immediate values.
Consider the code:
const char hello[] = "hello";
void fn(void)
{
x = 5;
y = 0x12345678;
}
hello is stored in rodata
The 5 in x = 5 is small enough that this can fit in an immediate
value and will compile to something like:
mov r4,#5
The value 0x12345678 is too large to store in an immediate
instruction so the emmittted code becomes something like:
ldr r4,[pc,xxxx]
...
.word 0x12345678
The actual data for 0x12345678 is stored as a literal value in
the .text section along with the code and is loaded indirectly using
the offset from the pc. This is called a literal pool.
BTW The assembler will do this for us automatically. All you need to
do is write:
ldr r4,=0x12345678
The assmebler will look at the value and determine if it can be done
with a mov. If not then a suitable literal pool is made.Message
Re: Flash variables
2005-04-26 by embeddedjanitor
Attachments
- No local attachments were found for this message.