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

.align 4
custom_stack_callback:
        /* r0   new stack adress (passed as parameter) */
        /* r4   temporary for restoring old stack (callee saved, so we get the correct value in case of a return) */
        push {r4, lr}       /* store the callee saved register as required and the return address */
        mov r4, sp          /* store current stack pointer */
        mov sp, r0          /* update stack pointer to new user level stack */
        bl callback         /* enter next tasks (will not return if continuation is stolen) */
        mov sp, r4          /* restore to the old stack pointer */
        pop {r4, pc}        /* restore the callee saved register as required and returns */
