2
0

setjump.inc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. function setjmp(var S : jmp_buf) : longint;assembler;[Public, alias : 'FPC_SETJMP'];nostackframe;
  12. asm
  13. {$if defined(CPUCORTEXM3) or defined(CPUARMV7M)}
  14. stmia r0!, {v1-v6, sl, fp}
  15. mov r2, sp
  16. stmia r0!, {r2, lr}
  17. mov r0,#0
  18. mov pc,lr
  19. {$else}
  20. stmia r0,{v1-v6, sl, fp, sp, lr}
  21. mov r0,#0
  22. mov pc,lr
  23. {$endif}
  24. end;
  25. procedure longjmp(var S : jmp_buf;value : longint);assembler;[Public, alias : 'FPC_LONGJMP'];
  26. asm
  27. {$if defined(CPUCORTEXM3) or defined(CPUARMV7M)}
  28. mov ip, r0
  29. movs r0, r1
  30. it eq
  31. moveq r0, #1
  32. ldmia ip,{v1-v6, sl, fp}
  33. ldr sp, [ip]
  34. add ip, ip, #4
  35. ldr pc, [ip]
  36. {$else}
  37. mov ip, r0
  38. movs r0, r1
  39. moveq r0, #1
  40. ldmia ip,{v1-v6, sl, fp, sp, pc}
  41. {$endif}
  42. end;