setjump.inc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. movl 8(%ebp),%eax
  15. movl %ebx,(%eax)
  16. movl %esi,4(%eax)
  17. movl %edi,8(%eax)
  18. movl 4(%ebp),%edi
  19. movl %edi,20(%eax)
  20. movl (%ebp),%edi
  21. movl %edi,12(%eax)
  22. leal 12(%ebp),%edi
  23. movl %edi,16(%eax)
  24. movl 8(%eax),%edi
  25. xorl %eax,%eax
  26. end['EAX'];
  27. Procedure longJmp (Var S : Jmp_buf; value : longint); assembler;[Public, alias : 'FPC_LONGJMP'];
  28. asm
  29. movl 8(%ebp),%ecx
  30. movl 12(%ebp),%eax
  31. movl (%ecx),%ebx
  32. movl 4(%ecx),%esi
  33. movl 8(%ecx),%edi
  34. movl 12(%ecx),%ebp
  35. movl 16(%ecx),%esp
  36. // we should also clear the fpu
  37. // fninit no must be done elsewhere PM
  38. // or we should reset the control word also
  39. jmp 20(%ecx)
  40. end;
  41. {
  42. $Log$
  43. Revision 1.1 2000-07-13 06:30:42 michael
  44. + Initial import
  45. Revision 1.13 2000/05/04 09:47:40 pierre
  46. * Preserve all registers in SetJmp
  47. * set EAX to value filed in LongJmp instead of only 0 or 1
  48. Revision 1.12 2000/03/31 23:12:09 pierre
  49. * remove fninit in longjump
  50. Revision 1.11 2000/02/18 16:16:13 florian
  51. * we don't need to to finit twice ...
  52. Revision 1.10 2000/02/18 15:23:01 florian
  53. * fixed constants in rtti
  54. * longjmp does now a finit
  55. Revision 1.9 2000/02/09 22:12:54 florian
  56. * longjump does now a finit
  57. Revision 1.8 2000/02/09 16:59:29 peter
  58. * truncated log
  59. Revision 1.7 2000/01/07 16:41:33 daniel
  60. * copyright 2000
  61. Revision 1.6 1999/08/18 10:42:13 pierre
  62. * loading of esp value corrected
  63. }