	.arm
	.text
	.global	__fiber_continue
	.type	__fiber_continue, %function

__fiber_continue:
        /* 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}
        /* ========== 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 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}
