setjump.inc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.3 2002-09-07 16:01:19 peter
  44. * old logs removed and tabs fixed
  45. }