setjump.inc 1.6 KB

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