/* -------------------------------------------------- Define required labels for EGTAPI -------------------------------------------------- */ .global main, Stop, CodeEnd .global DataStart, DataEnd .global x, y /* -------------------------------------------------- Begin of the program instructions -------------------------------------------------- */ .text main: movw r0, #:lower16:x // Moves the address of memory movt r0, #:upper16:x // variable x into register r0 mov r1, #-2 // Move -2 into short var x (correct !) str r1,[r0] // x = -2, correct // Change strh to strb and you will get x = 254 !! // Can you explain why x contains 254 ? // Change strh to str and you will get y = -1 !! // Can you explain why y gets updated to -1 ? Stop: CodeEnd: nop /* -------------------------------------------------- Begin of the permanent program variables -------------------------------------------------- */ .data DataStart: x: .2byte 4 // short typed variable y: .2byte 9999 // short typed variable DataEnd: .end