typinfo.inc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Jonas Maebe,
  5. member of the Free Pascal development team
  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. { This unit provides the same Functionality as the TypInfo Unit }
  13. { of Delphi }
  14. { ---------------------------------------------------------------------
  15. This include contains cpu-specific Low-level calling of methods.
  16. ---------------------------------------------------------------------}
  17. Function CallIntegerFunc(s: Pointer; Address: Pointer; Index, IValue: LongInt): Int64; assembler;
  18. { input: }
  19. { r3: s }
  20. { r4: address }
  21. { r5: index }
  22. { r6: ivalue }
  23. { output: }
  24. { r3-r4: result }
  25. var
  26. oldlr: pointer;
  27. asm
  28. { save current return address }
  29. mflr r0
  30. stw r0,oldlr
  31. mtctr r4
  32. { always pass ivalue as second parameter, it doesn't matter if it }
  33. { isn't used }
  34. mr r4,r6
  35. bctrl
  36. { restore return address }
  37. lwz r0,oldlr
  38. mtlr r0
  39. end;
  40. Function CallIntegerProc(s : Pointer;Address : Pointer;Value : Integer; Index,IValue : Longint) : Integer;assembler;
  41. { input: }
  42. { r3: s }
  43. { r4: address }
  44. { r5: index }
  45. { r6: ivalue }
  46. { output: }
  47. { r3: result }
  48. var
  49. oldlr: pointer;
  50. asm
  51. { save current return address }
  52. mflr r0
  53. stw r0,oldlr
  54. mtctr r4
  55. { always pass ivalue as second parameter, it doesn't matter if it }
  56. { isn't used }
  57. mr r4,r6
  58. bctrl
  59. { restore return address }
  60. lwz r0,oldlr
  61. mtlr r0
  62. end;
  63. Function CallSingleFunc(s : Pointer;Address : Pointer; Index,IValue : Longint) : Single;assembler;
  64. { input: }
  65. { r3: s }
  66. { r4: address }
  67. { r5: index }
  68. { r6: ivalue }
  69. { output: }
  70. { fr1: result }
  71. var
  72. oldlr: pointer;
  73. asm
  74. { save current return address }
  75. mflr r0
  76. stw r0,oldlr
  77. mtctr r4
  78. { always pass ivalue as second parameter, it doesn't matter if it }
  79. { isn't used }
  80. mr r4,r6
  81. bctrl
  82. { restore return address }
  83. lwz r0,oldlr
  84. mtlr r0
  85. end;
  86. Function CallDoubleFunc(s : Pointer;Address : Pointer; Index,IValue : Longint) : Double;assembler;
  87. { input: }
  88. { r3: s }
  89. { r4: address }
  90. { r5: index }
  91. { r6: ivalue }
  92. { output: }
  93. { fr1: result }
  94. var
  95. oldlr: pointer;
  96. asm
  97. { save current return address }
  98. mflr r0
  99. stw r0,oldlr
  100. mtctr r4
  101. { always pass ivalue as second parameter, it doesn't matter if it }
  102. { isn't used }
  103. mr r4,r6
  104. bctrl
  105. { restore return address }
  106. lwz r0,oldlr
  107. mtlr r0
  108. end;
  109. Function CallExtendedFunc(s : Pointer;Address : Pointer; Index,IValue : Longint) : Extended;assembler;
  110. { input: }
  111. { r3: s }
  112. { r4: address }
  113. { r5: index }
  114. { r6: ivalue }
  115. { output: }
  116. { fr1: result }
  117. var
  118. oldlr: pointer;
  119. asm
  120. { save current return address }
  121. mflr r0
  122. stw r0,oldlr
  123. mtctr r4
  124. { always pass ivalue as second parameter, it doesn't matter if it }
  125. { isn't used }
  126. mr r4,r6
  127. bctrl
  128. { restore return address }
  129. lwz r0,oldlr
  130. mtlr r0
  131. end;
  132. Function CallBooleanFunc(s : Pointer;Address : Pointer; Index,IValue : Longint) : Boolean;assembler;
  133. { input: }
  134. { r3: s }
  135. { r4: address }
  136. { r5: index }
  137. { r6: ivalue }
  138. { output: }
  139. { r3: result }
  140. var
  141. oldlr: pointer;
  142. asm
  143. { save current return address }
  144. mflr r0
  145. stw r0,oldlr
  146. mtctr r4
  147. { always pass ivalue as second parameter, it doesn't matter if it }
  148. { isn't used }
  149. mr r4,r6
  150. bctrl
  151. { restore return address }
  152. lwz r0, oldlr
  153. mtlr r0
  154. end;
  155. Procedure CallSStringFunc(s : Pointer;Address : Pointer; INdex,IValue : Longint;
  156. Var Res: Shortstring);assembler;
  157. { input: }
  158. { r3: address of shortstring result (temp) }
  159. { r4: s }
  160. { r5: address }
  161. { r6: index }
  162. { r7: ivalue }
  163. { r8: res }
  164. { output: }
  165. { none }
  166. var
  167. oldlr: pointer;
  168. asm
  169. { save current return address }
  170. mflr r0
  171. stw r0,oldlr
  172. mtctr r5
  173. { always pass ivalue as second parameter, it doesn't matter if it }
  174. { isn't used }
  175. mr r5,r7
  176. bctrl
  177. { restore return address }
  178. lwz r0,oldlr
  179. mtlr r0
  180. end;
  181. Procedure CallSStringProc(s : Pointer;Address : Pointer;Const Value : ShortString; INdex,IVAlue : Longint);assembler;
  182. { input: }
  183. { r3: s }
  184. { r4: address }
  185. { r5: value (address of shortstring) }
  186. { r6: index }
  187. { r7: ivalue }
  188. { output: }
  189. { none }
  190. var
  191. oldlr: pointer;
  192. asm
  193. { save current return address }
  194. mflr r0
  195. stw r0,oldlr
  196. mtctr r4
  197. { always pass ivalue as second parameter, it doesn't matter if it }
  198. { isn't used }
  199. mr r4,r6
  200. bctrl
  201. { restore return address }
  202. lwz r0,oldlr
  203. mtlr r0
  204. end;
  205. {
  206. $Log$
  207. Revision 1.7 2003-04-24 12:28:47 jonas
  208. * fixeed saving/restoring of return address
  209. * synchronized with i386 version
  210. Revision 1.6 2003/04/24 11:50:50 florian
  211. * fixed assembling
  212. Revision 1.5 2003/04/24 11:47:21 florian
  213. * fixed wrong newlines
  214. Revision 1.4 2003/04/23 22:47:13 florian
  215. * fixed compilation
  216. Revision 1.3 2003/04/23 22:19:21 peter
  217. * sstringfunc para updated
  218. Revision 1.2 2002/09/07 16:01:26 peter
  219. * old logs removed and tabs fixed
  220. }