.global main, Stop, CodeEnd .global DataStart, DataEnd .global a, b, c .text main: // Statement: c = a + 5*b; // 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 value in int 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 ldrsh r2,[r0] // Move value in short var into r2 // Compute 5*b mov r3, #5 // r3 = 5 mul r2, r3, r2 // r2 = r3 * r2 = 5*b // Compute a + 5*b add r1, r1, r2 // r1 = a + b // Store sum (in r1) to var c movw r0, #:lower16:c // Moves the address of memory movt r0, #:upper16:c // variable c into register r0 strb r1,[r0] // Store sum in r1 to byte 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