setjump.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by the Free Pascal development team
  4. SetJmp and LongJmp implementation for exception handling
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. Function SetJmp (Var S : Jmp_buf) : longint;assembler;[Public, alias : 'FPC_SETJMP'];
  12. asm
  13. {$ifndef REGCALL}
  14. movl 8(%ebp),%eax
  15. {$endif}
  16. movl %ebx,(%eax)
  17. movl %esi,4(%eax)
  18. movl %edi,8(%eax)
  19. movl 4(%ebp),%edi
  20. movl %edi,20(%eax)
  21. movl (%ebp),%edi
  22. movl %edi,12(%eax)
  23. {$ifdef REGCALL}
  24. leal 8(%ebp),%edi
  25. {$else}
  26. leal 12(%ebp),%edi
  27. {$endif}
  28. movl %edi,16(%eax)
  29. movl 8(%eax),%edi
  30. xorl %eax,%eax
  31. end['EAX'];
  32. Procedure longJmp (Var S : Jmp_buf; value : longint); assembler;[Public, alias : 'FPC_LONGJMP'];
  33. asm
  34. {$ifdef REGCALL}
  35. xchgl %edx,%eax
  36. {$else}
  37. movl 8(%ebp),%edx
  38. movl 12(%ebp),%eax
  39. {$endif}
  40. movl (%edx),%ebx
  41. movl 4(%edx),%esi
  42. movl 8(%edx),%edi
  43. movl 12(%edx),%ebp
  44. movl 16(%edx),%esp
  45. // we should also clear the fpu
  46. // fninit no must be done elsewhere PM
  47. // or we should reset the control word also
  48. jmp 20(%edx)
  49. end;