Content originally posted in LPCWare by starblue on Fri Aug 08 01:15:28 MST 2014
Quote: IanB
1) If I wanted the assembler to initialise my variables in RAM, where do I put the values to which I would like them initialised?
C code puts initialized variables in the .data section. The values are put in flash and then copied to RAM before the C program (main) starts. The initialization code is usually in some C file called crt<something>.c (CRT for C RunTime). This is an example where a section has two addresses, the load address (LMA) where it is loaded in the flash, and the virtual address (VMA) in RAM during runtime.
Quote: IanB
2) If I had some variables which all relate to one task e.g. PARTITION_START, FAT1_START, FAT2_START etc. I can access them by writing
LDR R3,=PARTITION_START
LDR R2,[R3]
LDR R3,=FAT1_START
LDR R1,[R3]
and I could also write:
LDR R3,=PARTITION_START
LDR R2,[R3]
LDR R1,[R3,#4]
saving a line of code, a place in the literal pool and two instruction cycles; but making the code difficult to read
or I could write
.equ _FAT1_start, FAT1_start - PARTITION_START
LDR R3,=PARTITION_START
LDR R2,[R3]
LDR R1,[R3,_FAT1_START]
but I have to define all the offsets
or is there a better way?
I think you should be able to write the difference directly in the instruction. Otherwise please call an offset xyz_OFFSET.
Jürgen