.file "custom_stack_callback.s" .text .global custom_stack_callback .type custom_stack_callback, @function.align 16custom_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