typinfo.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 CallExtendedFunc(s : Pointer;Address : Pointer; INdex,IValue : Longint) : Extended;assembler;
  53. asm
  54. movl S,%esi
  55. movl Address,%edi
  56. // ? Indexed Function
  57. movl Index,%eax
  58. testl %eax,%eax
  59. je .LINoPush
  60. movl IValue,%eax
  61. pushl %eax
  62. .LINoPush:
  63. push %esi
  64. call %edi
  65. //
  66. end;
  67. Function CallExtendedProc(s : Pointer;Address : Pointer;Value : Extended; INdex,IVAlue : Longint) : Integer;assembler;
  68. asm
  69. movl S,%esi
  70. movl Address,%edi
  71. // Push value to set
  72. leal Value,%eax
  73. pushl (%eax)
  74. pushl 4(%eax)
  75. pushl 8(%eax)
  76. // ? Indexed Procedure
  77. movl Index,%eax
  78. testl %eax,%eax
  79. je .LIPNoPush
  80. movl IValue,%eax
  81. pushl %eax
  82. .LIPNoPush:
  83. push %esi
  84. call %edi
  85. end;
  86. Function CallBooleanFunc(s : Pointer;Address : Pointer; Index,IValue : Longint) : Boolean;assembler;
  87. asm
  88. movl S,%esi
  89. movl Address,%edi
  90. // ? Indexed Function
  91. movl Index,%eax
  92. testl %eax,%eax
  93. je .LBNoPush
  94. movl IValue,%eax
  95. pushl %eax
  96. .LBNoPush:
  97. push %esi
  98. call %edi
  99. end;
  100. // Assembler Functions can't have short stringreturn values.
  101. // So we make a Procedure with var parameter.
  102. // That's not true (FK)
  103. Procedure CallSStringFunc(s : Pointer;Address : Pointer; INdex,IValue : Longint;
  104. Var Res: Shortstring);assembler;
  105. asm
  106. movl S,%esi
  107. movl Address,%edi
  108. // ? Indexed Function
  109. movl Index,%eax
  110. testl %eax,%eax
  111. jnz .LSSNoPush
  112. movl IValue,%eax
  113. pushl %eax
  114. // the result is stored in an invisible parameter
  115. pushl Res
  116. .LSSNoPush:
  117. push %esi
  118. call %edi
  119. end;
  120. Procedure CallSStringProc(s : Pointer;Address : Pointer;Const Value : ShortString; INdex,IVAlue : Longint);assembler;
  121. asm
  122. movl S,%esi
  123. movl Address,%edi
  124. // Push value to set
  125. movl Value,%eax
  126. pushl %eax
  127. // ? Indexed Procedure
  128. movl Index,%eax
  129. testl %eax,%eax
  130. // BUG 1 (jnz)
  131. je .LSSPNoPush
  132. movl IValue,%eax
  133. pushl %eax
  134. .LSSPNoPush:
  135. // BUG 2 (push)
  136. pushl %esi
  137. call %edi
  138. end;
  139. {
  140. $Log$
  141. Revision 1.4 2002-09-07 16:01:19 peter
  142. * old logs removed and tabs fixed
  143. }