setjump.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2002 by Jonas Maebe and other members of the
  5. Free Pascal development team
  6. SetJmp and LongJmp implementation for exception handling
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. function setjmp(var S : jmp_buf) : longint;assembler;[Public, alias : 'FPC_SETJMP']; nostackframe;
  14. asm
  15. stw r1,0(r3)
  16. mflr r0
  17. stw r2,4(r3)
  18. stw r14,12(r3)
  19. stfd f14,88(r3)
  20. stw r0,8(r3)
  21. stw r15,16(r3)
  22. stfd f15,96(r3)
  23. mfcr r0
  24. stw r16,20(r3)
  25. stfd f16,104(r3)
  26. stw r0,84(r3)
  27. stw r17,24(r3)
  28. stfd f17,112(r3)
  29. stw r18,28(r3)
  30. stfd f18,120(r3)
  31. stw r19,32(r3)
  32. stfd f19,128(r3)
  33. stw r20,36(r3)
  34. stfd f20,136(r3)
  35. stw r21,40(r3)
  36. stfd f21,144(r3)
  37. stw r22,44(r3)
  38. stfd f22,152(r3)
  39. stw r23,48(r3)
  40. stfd f23,160(r3)
  41. stw r24,52(r3)
  42. stfd f24,168(r3)
  43. stw r25,56(r3)
  44. stfd f25,176(r3)
  45. stw r26,60(r3)
  46. stfd f26,184(r3)
  47. stw r27,64(r3)
  48. stfd f27,192(r3)
  49. stw r28,68(r3)
  50. stfd f28,200(r3)
  51. stw r29,72(r3)
  52. stfd f29,208(r3)
  53. stw r30,76(r3)
  54. stfd f30,216(r3)
  55. stw r31,80(r3)
  56. stfd f31,224(r3)
  57. li r3,0
  58. end;
  59. procedure longjmp(var S : jmp_buf;value : longint);assembler;[Public, alias : 'FPC_LONGJMP']; nostackframe;
  60. asm
  61. lwz r1,0(r3)
  62. lwz r2,4(r3)
  63. lwz r0,8(r3)
  64. lwz r14,12(r3)
  65. lfd f14,88(r3)
  66. lwz r15,16(r3)
  67. lfd f15,96(r3)
  68. lwz r16,20(r3)
  69. lfd f16,104(r3)
  70. lwz r17,24(r3)
  71. lfd f17,112(r3)
  72. lwz r18,28(r3)
  73. lfd f18,120(r3)
  74. lwz r19,32(r3)
  75. lfd f19,128(r3)
  76. lwz r20,36(r3)
  77. lfd f20,136(r3)
  78. mtlr r0
  79. lwz r21,40(r3)
  80. lfd f21,144(r3)
  81. lwz r22,44(r3)
  82. lfd f22,152(r3)
  83. lwz r0,84(r3)
  84. lwz r23,48(r3)
  85. lfd f23,160(r3)
  86. lwz r24,52(r3)
  87. lfd f24,168(r3)
  88. lwz r25,56(r3)
  89. lfd f25,176(r3)
  90. mtcrf 0xff,r0
  91. lwz r26,60(r3)
  92. lfd f26,184(r3)
  93. lwz r27,64(r3)
  94. lfd f27,192(r3)
  95. lwz r28,68(r3)
  96. lfd f28,200(r3)
  97. lwz r29,72(r3)
  98. lfd f29,208(r3)
  99. lwz r30,76(r3)
  100. lfd f30,216(r3)
  101. lwz r31,80(r3)
  102. lfd f31,224(r3)
  103. mr r3,r4
  104. end;
  105. {
  106. $Log$
  107. Revision 1.9 2004-10-19 18:51:15 jonas
  108. + "nostackframe" modifier, because the automatic detection in the
  109. compiler to determine that a stack frame is not needed no longer works
  110. Revision 1.8 2003/04/26 20:00:24 florian
  111. * fixed previous commit of setjmp
  112. Revision 1.7 2003/04/26 19:52:07 florian
  113. + implemented longjmp
  114. Revision 1.6 2003/04/26 18:54:30 florian
  115. + implemented setjmp record and longjmp
  116. Revision 1.5 2002/09/07 16:01:26 peter
  117. * old logs removed and tabs fixed
  118. Revision 1.4 2002/08/31 14:27:40 florian
  119. + public and alias directive added to *jmp
  120. Revision 1.3 2002/08/10 17:14:36 jonas
  121. * various fixes, mostly changing the names of the modifies registers to
  122. upper case since that seems to be required by the compiler
  123. Revision 1.2 2002/07/30 17:29:53 florian
  124. + dummy setjmp and longjmp added
  125. + dummy implemtation of the destructor helper
  126. Revision 1.1 2002/07/28 20:43:49 florian
  127. * several fixes for linux/powerpc
  128. * several fixes to MT
  129. }