/* -------------------------------------------------- Define required labels for EGTAPI -------------------------------------------------- */ .global main, Stop, CodeEnd, DataStart, DataEnd /* -------------------------------------------------- Begin of the program instructions -------------------------------------------------- */ .text main: mov r0, #3 push {r0} mov r0, #2 push {r0} mov r0, #1 push {r0} bl A add sp, sp, #12 // Pop 3 int parameters Stop: nop // Stop point of main( ) /* ---------------------------------------------------------------- Function A(a,b,) with 2 int local variables ---------------------------------------------------------------- */ A: /* ============================================================= Function Prelude: Save PC and LR and allocate local variable ============================================================= */ push {lr} // Save LR (return address) push {fp} // Save FP (used by caller) mov fp, sp // Mark the stack top location before // allocating any local variables sub sp, sp, #8 // Allocate 2 int variables on the stack ldr r0, [fp, #8] // Access first parameter ldr r0, [fp, #-4] // Access first local variable /* ============================================================= Function Postlude: de-allocate local variable and restore FP ============================================================= */ mov sp, fp // De-allocate local variables pop {fp} // Restore fp pop {pc} // Return to the caller CodeEnd: nop /* -------------------------------------------------- Begin of the permanent program variables -------------------------------------------------- */ .data DataStart: DataEnd: .end