rttip.inc 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,97 by xxxx
  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. { Run-Time type information routines - processor dependent part }
  13. {$ASMMODE DIRECT}
  14. Procedure Initialize (Data,TypeInfo : pointer);[Public,Alias : 'INITIALIZE'];assembler;
  15. asm
  16. # Save registers
  17. push %eax
  18. push %ebx
  19. push %ecx
  20. push %edx
  21. # decide what type it is
  22. movl 12(%ebp),%ebx
  23. movb (%ebx),%al
  24. subb $10,%al
  25. jz .DoAnsiStringInit
  26. decb %al
  27. jz .DoAnsiStringInit
  28. subb $2,%al
  29. jz .DoArrayInit
  30. decb %al
  31. jz .DoRecordInit
  32. jmp .ExitInitialize
  33. .DoRecordInit:
  34. incl %ebx
  35. movzbl (%ebx),%eax
  36. # Skip also recordsize.
  37. addl $5,%eax
  38. addl %eax,%ebx
  39. # %ebx points to element count. Set in %edx
  40. movl (%ebx),%edx
  41. addl $4,%ebx
  42. # %ebx points to First element in record
  43. .MyRecordInitLoop:
  44. decl %edx
  45. jl .ExitInitialize
  46. # Calculate data
  47. movl 8(%ebp),%eax
  48. addl (%ebx),%eax
  49. addl $4,%ebx
  50. # Push type
  51. pushl (%ebx)
  52. addl $4,%ebx
  53. # push data
  54. pushl %eax
  55. call INITIALIZE
  56. jmp .MyRecordInitLoop
  57. # Array handling
  58. .DoArrayInit:
  59. # %ebx points to size. Put size in ecx
  60. movl (%ebx),%ecx
  61. addl $4, %ebx
  62. # %ebx points to count. Put count in %edx
  63. movl (%ebx),%edx
  64. addl $4, %ebx
  65. # %ebx points to type. Put into ebx.
  66. # Start treating elements.
  67. .MyArrayInitLoop:
  68. decl %edx
  69. jl .ExitInitialize
  70. # push type
  71. pushl (%ebx)
  72. # calculate data
  73. movl %ecx,%eax
  74. imull %edx,%eax
  75. addl 8(%ebp),%eax
  76. # push data
  77. pushl %eax
  78. call INITIALIZE
  79. jmp .MyArrayInitLoop
  80. # AnsiString handling :
  81. .DoAnsiStringInit:
  82. movl $0,8(%ebp)
  83. .ExitInitialize:
  84. pop %edx
  85. pop %ecx
  86. pop %ebx
  87. pop %eax
  88. end;
  89. Procedure Finalize (Data,TypeInfo: Pointer);[Public,Alias : 'FINALIZE']; assembler;
  90. asm
  91. push %eax
  92. push %ebx
  93. push %ecx
  94. push %edx
  95. # decide what type it is
  96. movl 12(%ebp),%ebx
  97. movb (%ebx),%al
  98. subb $10,%al
  99. jz .DoAnsiStringFinal
  100. decb %al
  101. jz .DoAnsiStringFinal
  102. subb $2,%al
  103. jz .DoArrayFinal
  104. decb %al
  105. jz .DoRecordFinal
  106. jmp .ExitFinalize
  107. .DoRecordFinal:
  108. incl %ebx
  109. movzbl (%ebx),%eax
  110. # Skip also recordsize.
  111. addl $5,%eax
  112. addl %eax,%ebx
  113. # %ebx points to element count. Set in %edx
  114. movl (%ebx),%edx
  115. addl $4,%ebx
  116. # %ebx points to First element in record
  117. .MyRecordFinalLoop:
  118. decl %edx
  119. jl .ExitFinalize
  120. # Calculate data
  121. movl 8(%ebp),%eax
  122. addl (%ebx),%eax
  123. addl $4,%ebx
  124. # Push type
  125. pushl (%ebx)
  126. addl $4,%ebx
  127. # push data
  128. pushl %eax
  129. call FINALIZE
  130. jmp .MyRecordFinalLoop
  131. # Array handling
  132. .DoArrayFinal:
  133. # %ebx points to size. Put size in ecx
  134. movl (%ebx),%ecx
  135. addl $4, %ebx
  136. # %ebx points to count. Put count in %edx
  137. movl (%ebx),%edx
  138. addl $4, %ebx
  139. # %ebx points to type. Put into ebx.
  140. # Start treating elements.
  141. .MyArrayFinalLoop:
  142. decl %edx
  143. jl .ExitFinalize
  144. # push type
  145. pushl (%ebx)
  146. # calculate data
  147. movl %ecx,%eax
  148. imull %edx,%eax
  149. addl 8(%ebp),%eax
  150. # push data
  151. pushl %eax
  152. call FINALIZE
  153. jmp .MyArrayFinalLoop
  154. # AnsiString handling :
  155. .DoAnsiStringFinal:
  156. movl 8(%ebp),%eax
  157. pushl %eax
  158. call DECR_ANSI_REF
  159. .ExitFinalize:
  160. pop %edx
  161. pop %ecx
  162. pop %ebx
  163. pop %eax
  164. end;
  165. Procedure Addref (Data,TypeInfo : Pointer); [Public,alias : 'ADDREF'];Assembler;
  166. asm
  167. # Save registers
  168. push %eax
  169. push %ebx
  170. push %ecx
  171. push %edx
  172. # decide what type it is
  173. movl 12(%ebp),%ebx
  174. movb (%ebx),%al
  175. subb $10,%al
  176. jz .DoAnsiStringAddRef
  177. decb %al
  178. jz .DoAnsiStringAddRef
  179. subb $2,%al
  180. jz .DoArrayAddRef
  181. decb %al
  182. jz .DoRecordAddRef
  183. jmp .ExitAddRef
  184. .DoRecordAddRef:
  185. incl %ebx
  186. movzbl (%ebx),%eax
  187. # Skip also recordsize.
  188. addl $5,%eax
  189. addl %eax,%ebx
  190. # %ebx points to element count. Set in %edx
  191. movl (%ebx),%edx
  192. addl $4,%ebx
  193. # %ebx points to First element in record
  194. .MyRecordAddRefLoop:
  195. decl %edx
  196. jl .ExitAddRef
  197. # Calculate data
  198. movl 8(%ebp),%eax
  199. addl (%ebx),%eax
  200. addl $4,%ebx
  201. # Push type
  202. pushl (%ebx)
  203. addl $4,%ebx
  204. # push data
  205. pushl %eax
  206. call ADDREF
  207. jmp .MyRecordAddRefLoop
  208. # Array handling
  209. .DoArrayAddRef:
  210. # %ebx points to size. Put size in ecx
  211. movl (%ebx),%ecx
  212. addl $4, %ebx
  213. # %ebx points to count. Put count in %edx
  214. movl (%ebx),%edx
  215. addl $4, %ebx
  216. # %ebx points to type. Put into ebx.
  217. # Start treating elements.
  218. .MyArrayAddRefLoop:
  219. decl %edx
  220. jl .ExitAddRef
  221. # push type
  222. pushl (%ebx)
  223. # calculate data
  224. movl %ecx,%eax
  225. imull %edx,%eax
  226. addl 8(%ebp),%eax
  227. # push data
  228. pushl %eax
  229. call ADDREF
  230. jmp .MyArrayAddRefLoop
  231. # AnsiString handling :
  232. .DoAnsiStringAddRef:
  233. movl 8(%ebp),%eax
  234. pushl %eax
  235. call INCR_ANSI_REF
  236. .ExitAddRef:
  237. pop %edx
  238. pop %ecx
  239. pop %ebx
  240. pop %eax
  241. end;
  242. Procedure DecRef (Data,TypeInfo : Pointer); [Public,alias : 'DECREF'];Assembler;
  243. asm
  244. # Save registers
  245. push %eax
  246. push %ebx
  247. push %ecx
  248. push %edx
  249. # decide what type it is
  250. movl 12(%ebp),%ebx
  251. movb (%ebx),%al
  252. subb $10,%al
  253. jz .DoAnsiStringDecRef
  254. decb %al
  255. jz .DoAnsiStringDecRef
  256. subb $2,%al
  257. jz .DoArrayDecRef
  258. decb %al
  259. jz .DoRecordDecRef
  260. jmp .ExitDecRef
  261. .DoRecordDecRef:
  262. incl %ebx
  263. movzbl (%ebx),%eax
  264. # Skip also recordsize.
  265. addl $5,%eax
  266. addl %eax,%ebx
  267. # %ebx points to element count. Set in %edx
  268. movl (%ebx),%edx
  269. addl $4,%ebx
  270. # %ebx points to First element in record
  271. .MyRecordDecRefLoop:
  272. decl %edx
  273. jl .ExitDecRef
  274. # Calculate data
  275. movl 8(%ebp),%eax
  276. addl (%ebx),%eax
  277. addl $4,%ebx
  278. # Push type
  279. pushl (%ebx)
  280. addl $4,%ebx
  281. # push data
  282. pushl %eax
  283. call DECREF
  284. jmp .MyRecordDecRefLoop
  285. # Array handling
  286. .DoArrayDecRef:
  287. # %ebx points to size. Put size in ecx
  288. movl (%ebx),%ecx
  289. addl $4, %ebx
  290. # %ebx points to count. Put count in %edx
  291. movl (%ebx),%edx
  292. addl $4, %ebx
  293. # %ebx points to type. Put into ebx.
  294. # Start treating elements.
  295. .MyArrayDecRefLoop:
  296. decl %edx
  297. jl .ExitDecRef
  298. # push type
  299. pushl (%ebx)
  300. # calculate data
  301. movl %ecx,%eax
  302. imull %edx,%eax
  303. addl 8(%ebp),%eax
  304. # push data
  305. pushl %eax
  306. call DECREF
  307. jmp .MyArrayDecRefLoop
  308. # AnsiString handling :
  309. .DoAnsiStringDecRef:
  310. movl 8(%ebp),%eax
  311. pushl %eax
  312. call DECR_ANSI_REF
  313. .ExitDecRef:
  314. pop %edx
  315. pop %ecx
  316. pop %ebx
  317. pop %eax
  318. end;
  319. {$ASMMODE DEFAULT}
  320. {
  321. $Log$
  322. Revision 1.5 1998-06-25 08:41:43 florian
  323. * better rtti
  324. Revision 1.4 1998/06/17 11:50:43 michael
  325. + Small patch: forgot to make alias public
  326. Revision 1.3 1998/06/10 07:46:49 michael
  327. + Forgot to commit some changes
  328. Revision 1.2 1998/06/08 19:31:03 michael
  329. + Implemented DecRef
  330. Revision 1.1 1998/06/08 15:32:12 michael
  331. + Split rtti according to processor. Implemented optimized i386 code.
  332. }