/* -------------------------------------------------- Define required labels for EGTAPI -------------------------------------------------- */ .global main, Stop, CodeEnd, DataStart, DataEnd /* -------------------------------------------------- if ( x > y ) Swap x and y -------------------------------------------------- */ .text main: // Test if ( x > y ) movw r0, #:lower16:x movt r0, #:upper16:x // r0 = addr(x) ldr r1, [r0] // r1 = x movw r2, #:lower16:y movt r2, #:upper16:y // r2 = addr(y) ldr r3, [r2] // r3 = y cmp r1, r3 // Compare x ? y ble ifEnd // Branch if x <= y to ifEnd // x > y is TRUE: swap x and y str r1, [r2] // Store the x-copy in y (in memory) str r3, [r0] // Store the y-copy in x (in memory) ifEnd: Stop: CodeEnd: nop /* -------------------------------------------------- Begin of the permanent program variables -------------------------------------------------- */ .data DataStart: x: .4byte 9 // x = 9 -- try a value smaller that 4 y: .4byte 4 // y = 4 DataEnd: .end