2.10.7. Using two register-based structures

Sometimes you need to operate on two structures of the same type at the same time. For example, if you want the equivalent of the pseudo-code:

newloc.x = oldloc.x + (value in r0);
newloc.y = oldloc.y + (value in r1);
newloc.z = oldloc.z + (value in r2);

The base register needs to point alternately to the oldloc structure and to the newloc one. Repeatedly changing the base register would be inefficient. Instead, use a non register-based map, and set up two pointers in two different registers as in Example 2.26.

Example 2.26. 

        MAP     0               ; Non-register based relative map used twice, for
Pointx  FIELD   4               ; old and new data at oldloc and newloc
Pointy  FIELD   4               ; oldloc and newloc are labels for
Pointz  FIELD   4               ; memory allocated in other sections
        ; code
        ADR     r8,oldloc
        ADR     r9,newloc
        LDR     r3,[r8,Pointx]  ; load from oldloc (r8)
        ADD     r3,r3,r0
        STR     r3,[r9,Pointx]  ; store to newloc (r9)
        LDR     r3,[r8,Pointy]
        ADD     r3,r3,r1
        STR     r3,[r9,Pointy]
        LDR     r3,[r8,Pointz]
        ADD     r3,r3,r2
        STR     r3,[r9,Pointz]
Copyright © 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B
Non-Confidential