From ARMwiki
Revision as of 06:18, 7 March 2012 by Admin (Talk | contribs)

Jump to: navigation, search

LDR offsets

Under "Immediate Offset" explanation you say: ""R3 points to the structure base, you can load the third element with: "", but I think it should read "eigth element". If not, you need to explain why. Then also the C equivalence for the same should read either:
a) "r0 = r1[4];" OR
b) "r0 = r1[3]; (as C arrays uses 0 as index 1)"
NoctiLucent 20:18, 6 March 2012 (CET)

Thank you for your comments. The reason why LDR R0, [R3, #8] loads the third element of the array (the third word) is that the offset given is specified in bytes; thus the first word is offset #0, the second #4, and #8 would be the third.
Likewise with the C equivalence, the ARM instruction LDR R0, [R1, #4] is asking that we load the second word (offset +4 bytes) from the array indicated, thus the equivalent r0 = r1[1]; is correct.
I shall edit the page to make this clearer.
Rick 05:18, 7 March 2012 (CET)
Personal tools