context_x86_64.asm 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. [bits 64]
  2. %define MJB_RBX 0
  3. %define MJB_RBP 1
  4. %define MJB_R12 2
  5. %define MJB_R13 3
  6. %define MJB_R14 4
  7. %define MJB_R15 5
  8. %define MJB_RSP 6
  9. %define MJB_PC 7
  10. %define MJB_SIZE (8*8)
  11. EXPORT __mylongjmp
  12. mov rbx, [rdi + MJB_RBX * 8]
  13. mov rbp, [rdi + MJB_RBP * 8]
  14. mov r12, [rdi + MJB_R12 * 8]
  15. mov r13, [rdi + MJB_R13 * 8]
  16. mov r14, [rdi + MJB_R14 * 8]
  17. mov r15, [rdi + MJB_R15 * 8]
  18. test esi, esi
  19. mov eax, 1
  20. cmove esi, eax
  21. mov eax, esi
  22. mov rdx, [rdi + MJB_PC * 8]
  23. mov rsp, [rdi + MJB_RSP * 8]
  24. jmp rdx
  25. EXPORT __mysetjmp
  26. mov [rdi + MJB_RBX * 8], rbx
  27. mov [rdi + MJB_RBP * 8], rbp
  28. mov [rdi + MJB_R12 * 8], r12
  29. mov [rdi + MJB_R13 * 8], r13
  30. mov [rdi + MJB_R14 * 8], r14
  31. mov [rdi + MJB_R15 * 8], r15
  32. lea rdx, [rsp + 8]
  33. mov [rdi + MJB_RSP * 8], rdx
  34. mov rax, [rsp]
  35. mov [rdi + MJB_PC * 8], rax
  36. mov eax, 0
  37. ret