.arm .text .global __cs_switch_context .type __cs_switch_context, %function __cs_switch_context: /* Parameter List (in order) * r0 = pointer to continuation (should hold value of target stack will be filled with this continuation) * * Return * r0 = continuation that returned control back to the caller (null if fallthrough) * * Variables * r1 = temporary for the old stack pointer */ /* ========== Save State ========== */ /* store programm counter for later return */ push {lr} /* store callee saved registers */ push {r4-r12,lr} /* store floating point extension registers */ #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) sub sp, sp, #64 vstmia sp, {d8-d15} #endif /* ========== Save State ========== */ /* Perform change to new stack */ /* Keep old stack as result from this function. */ mov r1, sp /* Switch to new stack pointer. */ mov sp, r0 /* ========== Restore State ========== */ /* restore floating point extension registers */ #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) vldmia sp, {d8-d15} add sp, sp, #64 #endif /* restore callee saved registers */ pop {r4-r12,lr} /* ========== Restore State ========== */ /* Just return back from the call. */ /* This is the end of a fiber, so we have no continuation. */ mov r0, r1 pop {pc}