/* -------------------------------------------------- Define required labels for EGTAPI -------------------------------------------------- */ .global main, Stop, CodeEnd .global DataStart, DataEnd .global a, b, c /* -------------------------------------------------- Begin of the program instructions -------------------------------------------------- */ .text main: // Move a into r1 movw r0, #:lower16:a // Moves the address of memory movt r0, #:upper16:a // variable a into register r0 ldr r1,[r0] // Move int value from var into r1 // Move b into r2 movw r0, #:lower16:b // Moves the address of memory movt r0, #:upper16:b // variable b into register r0 ldr r2,[r0] // Move int value from var into r2 // Add them up add r2, r1, r2 // r2 = a + b // Move sum in r2 to c movw r0, #:lower16:c // Moves the address of memory movt r0, #:upper16:c // variable c into register r0 str r2,[r0] // Move suim in r2 to var c Stop: CodeEnd: nop /* -------------------------------------------------- Begin of the permanent program variables -------------------------------------------------- */ .data DataStart: a: .4byte 4 // a contains the value 4 b: .4byte 5 // b contains the value 5 c: .skip 4 // c is not initialized (will contain 0) DataEnd: .end