/* ============================================================ Demo file used to teach linked list access ============================================================ */ .global main, Stop, CodeEnd, DataStart, DataEnd .global head /* ========================================================== I have created this linked list at the end of the file (in data seg): List head->[111,21,31]->[222,22,32]->[333,23,33]-> ->[444,24,34]->[555,25,35] class List { int value1; // Offset = 0 short value2; // Offset = 4 short value3; // Offset = 6 List next; // Offset = 8 } =========================================================== */ main: // Get head.next.next.value3 movw r0, #:lower16:head movt r0, #:upper16:head // r0 = addr(head) ldr r0, [r0] // r0 = head ldr r0, [r0, #8] // r0 = head.next ldr r0, [r0, #8] // r0 = head.next.next ldrsh r0, [r0, #6] // r0 = head.next.next.value3 // Store r0 in head.value1 movw r1, #:lower16:head movt r1, #:upper16:head // r0 = addr(head) ldr r1, [r1] // r0 = head str r0, [r1, #0] // offset(value1) = 0 (int) Stop: CodeEnd: nop /* ************************************************************** Linked list ************************************************************** */ .data .align 12 DataStart: // list structure is: [int value1, short value2, short value3, next] p0: .4byte 333 // Object [333,23,33,p2] .2byte 23, 33 .4byte p2 .skip 4 // gap p1: .4byte 111 // Object [111,21,31,p3] .2byte 21, 31 .4byte p3 // No gap p2: .4byte 444 // Object [444,24,34,p4] .2byte 24, 34 .4byte p4 .skip 4 // gap p3: .4byte 222 // Object [222,22,32,p2] .2byte 22, 32 .4byte p0 .skip 4 // gap p4: .4byte 555 // Object [555,25,35,null] .2byte 25, 35 .4byte 0 head: .4byte p1 // head contains the address of the first list elem // head->[111,21,31]->[222,22,32]->[333,23,33]-> // ->[444,24,34]->[555,25,35] DataEnd: .end