2
0

setjump.inc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2002 by Jonas Maebe and other members of the
  4. Free Pascal development team
  5. SetJmp and LongJmp implementation for exception handling
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. jmp_buf = packed record
  14. r1, r2, lr,r14,r15,
  15. r16,r17,r18,r19,r20,
  16. r21,r22,r23,r24,r25,
  17. r26,r27,r28,r29,r30,
  18. r31,cr : int64;
  19. // 176
  20. f14,f15,f16,
  21. // 200
  22. f17,f18,f19,f20,f21,
  23. f22,f23,f24,f25,f26,
  24. f27,f28,f29,f30,f31 : double;
  25. end;
  26. pjmp_buf = ^jmp_buf;}
  27. function fpc_setjmp(var S : jmp_buf) : longint;assembler;[Public, alias : 'FPC_SETJMP']; nostackframe; compilerproc;
  28. asm
  29. std r1,0(r3) // store r1
  30. mflr r0
  31. std r2,8(r3) // store r2
  32. std r14,24(r3) // store r14
  33. stfd f14,176(r3) // store f14
  34. std r0,16(r3) // store lr
  35. std r15,32(r3) // store r15
  36. stfd f15,184(r3) // store f15
  37. mfcr r0
  38. std r16,40(r3) // store r16
  39. stfd f16,192(r3) // store f16
  40. stw r0,168(r3) // store cr
  41. std r17,48(r3) // store r17
  42. stfd f17,200(r3) // store f17
  43. std r18,56(r3) // ...
  44. stfd f18,208(r3)
  45. std r19,64(r3)
  46. stfd f19,216(r3)
  47. std r20,72(r3)
  48. stfd f20,224(r3)
  49. std r21,80(r3)
  50. stfd f21,232(r3)
  51. std r22,88(r3)
  52. stfd f22,240(r3)
  53. std r23,96(r3)
  54. stfd f23,248(r3)
  55. std r24,104(r3)
  56. stfd f24,256(r3)
  57. std r25,112(r3)
  58. stfd f25,264(r3)
  59. std r26,120(r3)
  60. stfd f26,272(r3)
  61. std r27,128(r3)
  62. stfd f27,280(r3)
  63. std r28,136(r3)
  64. stfd f28,288(r3)
  65. std r29,144(r3)
  66. stfd f29,296(r3)
  67. std r30,152(r3)
  68. stfd f30,304(r3)
  69. std r31,160(r3)
  70. stfd f31,312(r3)
  71. li r3,0
  72. end;
  73. procedure fpc_longjmp(var S : jmp_buf;value : longint);assembler;[Public, alias : 'FPC_LONGJMP']; nostackframe; compilerproc;
  74. asm
  75. ld r1,0(r3) // load r1
  76. ld r2,8(r3) // load r2
  77. ld r0,16(r3) // load lr
  78. ld r14,24(r3) // load r14
  79. lfd f14,176(r3)
  80. ld r15,32(r3) // load r15
  81. lfd f15,184(r3)
  82. ld r16,40(r3)
  83. lfd f16,192(r3)
  84. ld r17,48(r3)
  85. lfd f17,200(r3)
  86. ld r18,56(r3)
  87. lfd f18,208(r3)
  88. ld r19,64(r3)
  89. lfd f19,216(r3)
  90. ld r20,72(r3)
  91. lfd f20,224(r3)
  92. mtlr r0
  93. ld r21,80(r3)
  94. lfd f21,232(r3)
  95. ld r22,88(r3)
  96. lfd f22,240(r3)
  97. lwz r0,168(r3)
  98. ld r23,96(r3)
  99. lfd f23,248(r3)
  100. ld r24,104(r3)
  101. lfd f24,256(r3)
  102. ld r25,112(r3)
  103. lfd f25,264(r3)
  104. mtcrf 0xff,r0
  105. ld r26,120(r3)
  106. lfd f26,272(r3)
  107. ld r27,128(r3)
  108. lfd f27,280(r3)
  109. ld r28,136(r3)
  110. lfd f28,288(r3)
  111. ld r29,144(r3)
  112. lfd f29,296(r3)
  113. ld r30,152(r3)
  114. lfd f30,304(r3)
  115. ld r31,160(r3)
  116. lfd f31,312(r3)
  117. mr r3,r4
  118. end;