Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.7 KiB

  1. ;***
  2. ;setjmp.asm
  3. ;
  4. ; Copyright (C) 1993-2001, Microsoft Corporation. All rights reserved.
  5. ;
  6. ;Purpose:
  7. ; Contains setjmp();
  8. ; split from exsup.asm for granularity purposes.
  9. ;
  10. ;Notes:
  11. ;
  12. ;Revision History:
  13. ; 04-13-93 JWM Module created.
  14. ; 10-14-93 GJF Merged in NT verson.
  15. ; 01-12-94 PML Added C9.0 generic EH callback for unwind. Split
  16. ; into setjmp.asm, setjmp3.asm, and longjmp.asm.
  17. ; 02-10-94 GJF -1 is the end-of-exception-handler chain marker, not 0.
  18. ; 01-11-95 GJF Purged raisex(). Nobody uses it. Nobody even remembers
  19. ; what it was used for (it was part of the test harness
  20. ; for early EH unit testing).
  21. ; 01-11-95 SKS Remove MASM 5.X support
  22. ; 01-13-95 JWM Added NLG routines for debugger support.
  23. ; 04-11-95 JWM NLG_Return moved to lowhelpr.asm.
  24. ; 04-21-95 JWM NLG routines moved to exsup.asm.
  25. ;
  26. ;*******************************************************************************
  27. ;hnt = -D_WIN32 -Dsmall32 -Dflat32 -Mx $this;
  28. ;Define small32 and flat32 since these are not defined in the NT build process
  29. small32 equ 1
  30. flat32 equ 1
  31. .xlist
  32. include pversion.inc
  33. ?DFDATA = 1
  34. ?NODATA = 1
  35. include cmacros.inc
  36. include exsup.inc
  37. .list
  38. assumes DS,DATA
  39. assumes FS,DATA
  40. BeginCODE
  41. ; Following symbol defined in exsup.asm
  42. extrn __except_list:near
  43. ; int
  44. ; _setjmp (
  45. ; OUT jmp_buf env)
  46. ;
  47. ; Routine Description:
  48. ;
  49. ; (Old) implementation of setjmp intrinsic. Saves the current
  50. ; nonvolatile register state in the specified jump buffer and returns
  51. ; a function value of zero.
  52. ;
  53. ; Saves the callee-save registers, stack pointer and return address.
  54. ; Also saves the exception registration list head.
  55. ;
  56. ; This code is only present for old apps that link to the DLL runtimes,
  57. ; or old object files compiles with C8.0. It intentionally duplicates
  58. ; the old setjmp bugs, blindly assuming that the topmost EH node is a
  59. ; C8.0 SEH node.
  60. ;
  61. ; Arguments:
  62. ;
  63. ; env - Address of the buffer for storing the state information
  64. ;
  65. ; Return Value:
  66. ;
  67. ; A value of zero is returned.
  68. public __setjmp
  69. __setjmp PROC NEAR
  70. mov edx, [esp+4]
  71. mov [edx.saved_ebp], ebp ; old bp and the rest
  72. mov [edx.saved_ebx], ebx
  73. mov [edx.saved_edi], edi
  74. mov [edx.saved_esi], esi
  75. mov [edx.saved_esp], esp
  76. mov eax, [esp] ; return address
  77. mov [edx.saved_return], eax
  78. mov eax, dword ptr fs:__except_list
  79. mov [edx.saved_xregistration], eax
  80. cmp eax, -1 ; -1 means no higher-level handler
  81. jnz short _sj_save_trylevel
  82. mov dword ptr [edx.saved_trylevel], -1 ;something invalid
  83. jmp short _sj_done
  84. _sj_save_trylevel:
  85. mov eax, [eax + C8_TRYLEVEL]
  86. mov [edx.saved_trylevel], eax
  87. _sj_done:
  88. sub eax, eax
  89. ret
  90. __setjmp ENDP
  91. EndCODE
  92. END