.global main, Stop, CodeEnd, DataStart, DataEnd .global head main: // We need to get the start of the list stored in the variable "head" // 1. Get the address of the variable "head" movw r0, #:lower16:head movt r0, #:upper16:head // r0 = addr(head) // 2. Get the value stored in the variable "head" ldr r0, [r0] // r0 = addr(first list elem) // r0 now has the base address of // the first list element ! ldr r1, [r0,#0] // r1 = head.value // Note: you can also use "ldr r1, [r0]" ldr r0, [r0,#4] // r0 = addr(2nd list elem) !!! // r0 now has the base address of // the 2nd list element ! ldr r2, [r0,#0] // r2 = head.next.value !! ldr r0, [r0,#4] // r0 = addr(3rd list elem) !!! // r0 now has the base address of // the 3rd list element ! ldr r3, [r0,#0] // r3 = head.next.next.value !! ldr r0, [r0,#4] // r0 = addr(4th list elem) !!! // r0 now has the base address of // the 4th list element ! ldr r4, [r0,#0] // r4 = head.next.next.next.value !! // And so on... Stop: nop CodeEnd: /* ************************************************************** Permanent variables ************************************************************** */ .data DataStart: head: .word 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] p1: .4byte 33, p2 // p1 contains [33, p2] p2: .4byte 44, p4 // p2 contains [44, p2] p3: .4byte 22, p1 // p3 contains [22, p2] p4: .4byte 55, 0 // p4 contains [55, p2] DataEnd: .end