custom_stack_callback.s 758 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
	.file	"custom_stack_callback.s"
	.text
	.global	custom_stack_callback
	.type	custom_stack_callback, @function

.align 16
custom_stack_callback:
        # rdi = new stack adress (passed as parameter)
        # r12 temporary for restoring old stack (callee saved, so we get the correct value in case of a return)
        push %r12           # store the callee saved register as required
        movq %rsp, %r12     # store current stack pointer
        movq %rdi, %rsp     # update stack pointer to new user level stack
        call callback       # enter next tasks (will not return if continuation is stolen)
        movq %r12, %rsp     # restore to the old stack pointer
        pop %r12            # restore the callee saved register as required
    	ret