setjump.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2002 by Jonas Maebe and David Zhang
  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. procedure longjmp(var s : jmp_buf;value:longint);assembler;nostackframe;[Public,alias:'FPC_LONGJMP'];
  12. asm
  13. lw $31,0($4) #PC
  14. lw $sp,4($4) #SP
  15. lw $16,8($4) #S0,$16
  16. lw $17,12($4)#S1,$16
  17. lw $18,16($4)#S2,$16
  18. lw $19,20($4)#S3,$16
  19. lw $20,24($4)#S4,$16
  20. lw $21,28($4)#S5,$16
  21. lw $22,32($4)#S6,$16
  22. lw $23,36($4)#S7,$16
  23. lw $fp,40($4)#FP
  24. lw $gp,44($4)#GP
  25. j $31
  26. nop
  27. end;
  28. function setjmp(var S:jmp_buf):longint;assembler;nostackframe;[Public,alias:'FPC_SETJMP'];
  29. asm
  30. sw $31,0($4) #PC
  31. sw $sp,4($4) #SP
  32. sw $16,8($4) #S0,$16
  33. sw $17,12($4)#S1,$16
  34. sw $18,16($4)#S2,$16
  35. sw $19,20($4)#S3,$16
  36. sw $20,24($4)#S4,$16
  37. sw $21,28($4)#S5,$16
  38. sw $22,32($4)#S6,$16
  39. sw $23,36($4)#S7,$16
  40. sw $fp,40($4)#FP
  41. sw $gp,44($4)#GP
  42. move $2,$0
  43. end;