typinfo.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Florian Klaempfl
  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. {$ASMMODE ATT}
  18. Function CallIntegerFunc(s: Pointer; Address: Pointer; Index, IValue: LongInt): Int64; assembler;
  19. asm
  20. movl S,%esi
  21. movl Address,%edi
  22. // ? Indexed Function
  23. movl Index,%eax
  24. testl %eax,%eax
  25. je .LINoPush
  26. movl IValue,%eax
  27. pushl %eax
  28. .LINoPush:
  29. push %esi
  30. // reset EDX for routines that return only EAX
  31. xorl %edx,%edx
  32. call %edi
  33. // now the result is in EDX:EAX
  34. end;
  35. Function CallIntegerProc(s : Pointer;Address : Pointer;Value : Integer; INdex,IValue : Longint) : Integer;assembler;
  36. asm
  37. movl S,%esi
  38. movl Address,%edi
  39. // Push value to set
  40. movl Value,%eax
  41. pushl %eax
  42. // ? Indexed Procedure
  43. movl Index,%eax
  44. testl %eax,%eax
  45. je .LIPNoPush
  46. movl IValue,%eax
  47. pushl %eax
  48. .LIPNoPush:
  49. pushl %esi
  50. call %edi
  51. end;
  52. Function CallSingleFunc(s : Pointer; Address : Pointer;
  53. Index, IValue : Longint) : Single; assembler;
  54. asm
  55. movl S,%esi
  56. movl Address,%edi
  57. // ? Indexed Function
  58. movl Index,%eax
  59. testl %eax,%eax
  60. je .LINoPush
  61. movl IValue,%eax
  62. pushl %eax
  63. .LINoPush:
  64. push %esi
  65. call %edi
  66. //
  67. end;
  68. Function CallDoubleFunc(s : Pointer; Address : Pointer;
  69. Index, IValue : Longint) : Double; assembler;
  70. asm
  71. movl S,%esi
  72. movl Address,%edi
  73. // ? Indexed Function
  74. movl Index,%eax
  75. testl %eax,%eax
  76. je .LINoPush
  77. movl IValue,%eax
  78. pushl %eax
  79. .LINoPush:
  80. push %esi
  81. call %edi
  82. //
  83. end;
  84. Function CallExtendedFunc(s : Pointer;Address : Pointer; INdex,IValue : Longint) : Extended;assembler;
  85. asm
  86. movl S,%esi
  87. movl Address,%edi
  88. // ? Indexed Function
  89. movl Index,%eax
  90. testl %eax,%eax
  91. je .LINoPush
  92. movl IValue,%eax
  93. pushl %eax
  94. .LINoPush:
  95. push %esi
  96. call %edi
  97. //
  98. end;
  99. Function CallBooleanFunc(s : Pointer;Address : Pointer; Index,IValue : Longint) : Boolean;assembler;
  100. asm
  101. movl S,%esi
  102. movl Address,%edi
  103. // ? Indexed Function
  104. movl Index,%eax
  105. testl %eax,%eax
  106. je .LBNoPush
  107. movl IValue,%eax
  108. pushl %eax
  109. .LBNoPush:
  110. push %esi
  111. call %edi
  112. end;
  113. // Assembler Functions can't have short stringreturn values.
  114. // So we make a Procedure with var parameter.
  115. // That's not true (FK)
  116. Procedure CallSStringFunc(s : Pointer;Address : Pointer; INdex,IValue : Longint;
  117. Var Res: Shortstring);assembler;
  118. asm
  119. movl S,%esi
  120. movl Address,%edi
  121. // ? Indexed Function
  122. movl Index,%eax
  123. testl %eax,%eax
  124. jnz .LSSNoPush
  125. movl IValue,%eax
  126. pushl %eax
  127. // the result is stored in an invisible parameter
  128. pushl Res
  129. .LSSNoPush:
  130. push %esi
  131. call %edi
  132. end;
  133. Procedure CallSStringProc(s : Pointer;Address : Pointer;Const Value : ShortString; INdex,IVAlue : Longint);assembler;
  134. asm
  135. movl S,%esi
  136. movl Address,%edi
  137. // Push value to set
  138. movl Value,%eax
  139. pushl %eax
  140. // ? Indexed Procedure
  141. movl Index,%eax
  142. testl %eax,%eax
  143. // BUG 1 (jnz)
  144. je .LSSPNoPush
  145. movl IValue,%eax
  146. pushl %eax
  147. .LSSPNoPush:
  148. // BUG 2 (push)
  149. pushl %esi
  150. call %edi
  151. end;
  152. {
  153. $Log$
  154. Revision 1.5 2003-03-29 16:55:56 michael
  155. + Patch from Mattias Gaertner for single typeinfo
  156. Revision 1.4 2002/09/07 16:01:19 peter
  157. * old logs removed and tabs fixed
  158. }