/* -------------------------------------------------- Use this file to teach: Get the values in A[4], B[5], C[2] into a reg Get the values in A[k], B[k], C[k] into a reg Store the value in a r0 in A[4], B[5], C[2] Store the value in a r0 in A[k], B[k], C[k] -------------------------------------------------- */ .global main, Stop, CodeEnd .global DataStart, DataEnd .global A, B, C, k /* ------------------------------------------------------------------------- There are 5 array defined in the "data segment" at the end of this file byte A[5] = {11, 12, 13, 14, 15} short B[5] = {111, 112, 113, 114, 115} int C[5] = {1111, 1112, 1113, 1114, 1115} There is an int typed variable k (initialized with some integer value) ------------------------------------------------------------------------- */ .text main: // ============================================================ A[3] movw r10, #:lower16:9999 // Use r10 in the demo movt r10, #:upper16:9999 // I initial it with some random value. movw r0, #:lower16:A movt r0, #:upper16:A // Get the value from an array element into r10 // Store the value in r10 into an array element Stop: CodeEnd: nop /* -------------------------------------------------- Begin of the permanent program variables -------------------------------------------------- */ .data DataStart: A: .byte 11, 12, 13, 14, 15 // byte typed array with 5 byte values // in consecutive memory .align 1 // Skip to an address divisible by 2^1=2 B: .2byte 111, 112, 113, 114, 115 // short typed array B .align 2 // Skip to an address divisible by 2^2=4 C: .4byte 1111, 1112, 1113, 1114, 1115 // int typed array C k: .4byte 3 // Index used to access arrays DataEnd: .end