setjmp.S 963 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #
  2. # arch/i386/setjmp.S
  3. #
  4. # setjmp/longjmp for the i386 architecture
  5. #
  6. #
  7. # The jmp_buf is assumed to contain the following, in order:
  8. # %ebx
  9. # %esp
  10. # %ebp
  11. # %esi
  12. # %edi
  13. # <return address>
  14. #
  15. .text
  16. .align 4
  17. .globl setjmp
  18. .type setjmp, @function
  19. setjmp:
  20. #ifdef _REGPARM
  21. movl %eax,%edx
  22. #else
  23. movl 4(%esp),%edx
  24. #endif
  25. popl %ecx # Return address, and adjust the stack
  26. xorl %eax,%eax # Return value
  27. movl %ebx,(%edx)
  28. movl %esp,4(%edx) # Post-return %esp!
  29. pushl %ecx # Make the call/return stack happy
  30. movl %ebp,8(%edx)
  31. movl %esi,12(%edx)
  32. movl %edi,16(%edx)
  33. movl %ecx,20(%edx) # Return address
  34. ret
  35. .size setjmp,.-setjmp
  36. .text
  37. .align 4
  38. .globl longjmp
  39. .type longjmp, @function
  40. longjmp:
  41. #ifdef _REGPARM
  42. xchgl %eax,%edx
  43. #else
  44. movl 4(%esp),%edx # jmp_ptr address
  45. movl 8(%esp),%eax # Return value
  46. #endif
  47. movl (%edx),%ebx
  48. movl 4(%edx),%esp
  49. movl 8(%edx),%ebp
  50. movl 12(%edx),%esi
  51. movl 16(%edx),%edi
  52. jmp *20(%edx)
  53. .size longjmp,.-longjmp