setjump.inc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 fpc_SetJmp (Var S : Jmp_buf) : longint;assembler;nostackframe;[Public, alias : 'FPC_SETJMP']; compilerproc;
  12. asm
  13. movl %ebx,Jmp_buf.ebx(%eax)
  14. movl %esi,Jmp_buf.esi(%eax)
  15. movl %edi,Jmp_buf.edi(%eax)
  16. movl %ebp,Jmp_buf.bp(%eax)
  17. leal 4(%esp),%edi
  18. movl %edi,Jmp_buf.sp(%eax)
  19. movl (%esp),%edi
  20. movl %edi,Jmp_buf.pc(%eax)
  21. movl Jmp_buf.edi(%eax),%edi
  22. xorl %eax,%eax
  23. end;
  24. Procedure fpc_longJmp (Var S : Jmp_buf; value : longint); assembler;nostackframe;[Public, alias : 'FPC_LONGJMP']; compilerproc;
  25. asm
  26. xchgl %edx,%eax
  27. testl %eax,%eax
  28. jnz .L1
  29. incl %eax
  30. .L1:
  31. movl Jmp_buf.ebx(%edx),%ebx
  32. movl Jmp_buf.esi(%edx),%esi
  33. movl Jmp_buf.edi(%edx),%edi
  34. movl Jmp_buf.bp(%edx),%ebp
  35. movl Jmp_buf.sp(%edx),%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 Jmp_buf.pc(%edx)
  40. end;