/* ======================================================================== Demo file used to teach linked list access ======================================================================== */ .global main, Stop, CodeEnd, DataStart, DataEnd .global head // "head" points to the first element in list /* ======================================================================== I have created this linked list at the end of the file (in data seg): List head->[11]->[22]->[33]->[44]->[55] class List { List next; // Offset = 4 int value; // Offset = 0 } ======================================================================== */ main: // Load the value in variable head.value into r10 // Load the value in variable head.next.value into r10 // Load the value in variable head.next.next.value into r10 // get head.next.value into r1 movw r0, #:lower16:head movt r0, #:upper16:head ldr r0, [r0] // r0 = base addr of 1st elem ldr r0,[r0,#0] // r0 = base adr of 2nd elem ldr r1,[r0,#4] Stop: nop CodeEnd: /* ************************************************************** Permanent variables ************************************************************** */ .data DataStart: head: .4byte p0 // head contains the address of the first list elem // head->[11]->[22]->[33]->[44]->[55] // list structure is: [int value, next] p0: .4byte 11, p3 // p0 contains [11, p3] .skip 8 // *** Gap p1: .4byte 33, p2 // p1 contains [33, p2] p2: .4byte 44, p4 // p2 contains [44, p2] .skip 16 // *** Gap p3: .4byte 22, p1 // p3 contains [22, p2] .skip 8 // *** Gap p4: .4byte 55, 0 // p4 contains [55, p2] DataEnd: .end