.global main, Stop, CodeEnd, DataStart, DataEnd .global head, ptr main: /* ------------------------------------- ptr.next = head; -------------------------------------- */ // Get the value in the LHS movw r0, #:lower16:head movt r0, #:upper16:head // r0 = addr(head) ldr r0, [r0] // r0 = head // Get the ADDRESS in the RHS movw r1, #:lower16:ptr movt r1, #:upper16:ptr // r1 = addr(ptr) ldr r1, [r1] // r1 = ptr // Note: Addr(RHS) = r1+4 // Store the LHS in the addr of RHS str r0, [r1, #4] /* ------------------------------------- head = ptr; -------------------------------------- */ // Get the value in the LHS movw r0, #:lower16:ptr movt r0, #:upper16:ptr // r0 = addr(ptr) ldr r0, [r0] // r0 = ptr // Get the ADDRESS in the RHS movw r1, #:lower16:head movt r1, #:upper16:head // r1 = addr(head) // Addr(RHS) = r1 // Store the LHS in the addr of RHS str r0, [r1] 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] ptr: .word p9 // 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, p4] p3: .4byte 22, p1 // p3 contains [22, p1] p4: .4byte 55, 0 // p4 contains [55, 0] p9: .4byte 99, 0 // p9 contains [99, 0] DataEnd: .end