• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
2.global __setjmp
3.global _setjmp
4.global setjmp
5.type __setjmp,@function
6.type _setjmp,@function
7.type setjmp,@function
8__setjmp:
9_setjmp:
10setjmp:
11	mov %rbx,(%rdi)         /* rdi is jmp_buf, move registers onto it */
12	mov %rbp,8(%rdi)
13	mov %r12,16(%rdi)
14	mov %r13,24(%rdi)
15	mov %r14,32(%rdi)
16	mov %r15,40(%rdi)
17	lea 8(%rsp),%rdx        /* this is our rsp WITHOUT current ret addr */
18	mov %rdx,48(%rdi)
19	mov (%rsp),%rdx         /* save return addr ptr for new rip */
20	mov %rdx,56(%rdi)
21	xor %rax,%rax           /* always return 0 */
22	ret
23