github.com/afumu/libc@v0.0.6/musl/src/setjmp/x32/longjmp.s (about)

     1  /* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
     2  .global _longjmp
     3  .global longjmp
     4  .type _longjmp,@function
     5  .type longjmp,@function
     6  _longjmp:
     7  longjmp:
     8  	mov %rsi,%rax           /* val will be longjmp return */
     9  	test %rax,%rax
    10  	jnz 1f
    11  	inc %rax                /* if val==0, val=1 per longjmp semantics */
    12  1:
    13  	mov (%rdi),%rbx         /* rdi is the jmp_buf, restore regs from it */
    14  	mov 8(%rdi),%rbp
    15  	mov 16(%rdi),%r12
    16  	mov 24(%rdi),%r13
    17  	mov 32(%rdi),%r14
    18  	mov 40(%rdi),%r15
    19  	mov 48(%rdi),%rdx       /* this ends up being the stack pointer */
    20  	mov %rdx,%rsp
    21  	mov 56(%rdi),%rdx       /* this is the instruction pointer */
    22  	jmp *%rdx               /* goto saved address without altering rsp */