setjump.inc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 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. {$ifdef fpc_abi_call0}
  12. function fpc_setjmp(var S : jmp_buf) : longint;assembler;[Public, alias : 'FPC_SETJMP']; compilerproc; nostackframe;
  13. asm
  14. s32i.n a0,S.a0
  15. s32i.n a1,S.a1
  16. s32i.n a8,S.a8
  17. s32i.n a12,S.a12
  18. s32i.n a13,S.a13
  19. s32i.n a14,S.a14
  20. s32i.n a15,S.a15
  21. movi.n a2,0
  22. end;
  23. procedure fpc_longjmp(var S : jmp_buf;value : longint);assembler;[Public, alias : 'FPC_LONGJMP']; compilerproc; nostackframe;
  24. asm
  25. l32i.n a0,S.a0
  26. l32i.n a1,S.a1
  27. l32i.n a8,S.a8
  28. l32i.n a12,S.a12
  29. l32i.n a13,S.a13
  30. l32i.n a14,S.a14
  31. l32i.n a15,S.a15
  32. movi.n a2,1
  33. movnez a2,value,value
  34. end;
  35. {$elseif defined(freertos) and defined(fpc_abi_windowed)}
  36. function fpc_setjmp(var S : jmp_buf) : longint;assembler;[Public, alias : 'FPC_SETJMP']; compilerproc; nostackframe;
  37. asm
  38. j.l setjmp,a15
  39. end;
  40. procedure fpc_longjmp(var S : jmp_buf;value : longint);assembler;[Public, alias : 'FPC_LONGJMP']; compilerproc; nostackframe;
  41. asm
  42. j.l longjmp,a15
  43. end;
  44. {$else}
  45. function fpc_setjmp(var S : jmp_buf) : longint;assembler;[Public, alias : 'FPC_SETJMP']; compilerproc; nostackframe;
  46. asm
  47. entry a1,16
  48. movi.n a2,0
  49. end;
  50. procedure fpc_longjmp(var S : jmp_buf;value : longint);assembler;[Public, alias : 'FPC_LONGJMP']; compilerproc; nostackframe;
  51. asm
  52. entry a1,16
  53. movi.n a2,1
  54. movnez a2,value,value
  55. end;
  56. {$endif}