setjump.inc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. movl Jmp_buf.ebx(%edx),%ebx
  28. movl Jmp_buf.esi(%edx),%esi
  29. movl Jmp_buf.edi(%edx),%edi
  30. movl Jmp_buf.bp(%edx),%ebp
  31. movl Jmp_buf.sp(%edx),%esp
  32. // we should also clear the fpu
  33. // fninit no must be done elsewhere PM
  34. // or we should reset the control word also
  35. jmp Jmp_buf.pc(%edx)
  36. end;