Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

300 lines
6.7 KiB

  1. ; $Id: macros.asm,v 1.4 1995/09/27 09:26:54 james Exp $
  2. ;
  3. ; Copyright (c) RenderMorphics Ltd. 1993, 1994
  4. ; Version 1.0beta2
  5. ;
  6. ; All rights reserved.
  7. ;
  8. ; This file contains private, unpublished information and may not be
  9. ; copied in part or in whole without express permission of
  10. ; RenderMorphics Ltd.
  11. ;
  12. ;
  13. ;the 8086 macros...
  14. ;the general purpose macros just so you can write code more easily
  15. ifdef INTEL
  16. func macro name
  17. public name
  18. name:
  19. endm
  20. else
  21. func macro name
  22. public _&name
  23. name: ;lay down both labels so I have one I know will
  24. _&name: ;always be available for asm to call.
  25. endm
  26. endif
  27. push_all macro
  28. irp z,<edi,esi,edx,ecx,ebx,eax>
  29. push z
  30. endm
  31. endm
  32. pop_all macro
  33. irp z,<eax,ebx,ecx,edx,esi,edi>
  34. pop z
  35. endm
  36. endm
  37. push_m macro list
  38. irp z,<list>
  39. push z
  40. endm
  41. endm
  42. pop_m macro list
  43. irp z,<list>
  44. pop z
  45. endm
  46. endm
  47. byte_eax equ al
  48. byte_ebx equ bl
  49. byte_ecx equ cl
  50. byte_edx equ dl
  51. word_eax equ ax
  52. word_ebx equ bx
  53. word_ecx equ cx
  54. word_edx equ dx
  55. word_edi equ di
  56. word_esi equ si
  57. word_ebp equ bp
  58. ; Divide eax by divisor, an 8 bit precision fixed point number.
  59. ; Divisor must be positive.
  60. ; result in eax, edx is trashed.
  61. Div8 macro divisor
  62. local divide, nodivide
  63. cdq
  64. xor edx, eax
  65. sar edx, 017H
  66. cmp divisor, edx
  67. jg divide
  68. sar eax, 1fH
  69. xor eax, 7fffffffH
  70. jmp nodivide
  71. divide:
  72. mov edx, eax
  73. sar edx, 018h
  74. shl eax, 008h
  75. idiv divisor
  76. nodivide:
  77. endm
  78. ; Divide eax by divisor, an 16 bit precision fixed point number.
  79. ; Divisor must be positive.
  80. ; result in eax, edx is trashed.
  81. Div16 macro divisor
  82. local divide, nodivide
  83. cdq
  84. xor edx, eax
  85. sar edx, 0fH
  86. cmp divisor, edx
  87. jg divide
  88. sar eax, 1fH
  89. xor eax, 7fffffffH
  90. jmp nodivide
  91. divide:
  92. mov edx, eax
  93. sar edx, 010h
  94. shl eax, 010h
  95. idiv divisor
  96. nodivide:
  97. endm
  98. ES_PREFIX macro
  99. ifndef NT
  100. db 26h
  101. endif
  102. endm
  103. beginargs macro
  104. align 4
  105. stack = 4 ;return address
  106. vars = 0 ;no vars yet
  107. args = 0 ;no args yet
  108. endm
  109. endargs macro
  110. sub esp, vars
  111. endm
  112. savereg macro arg
  113. push arg
  114. stack = stack + 4
  115. endm
  116. saveregs macro arglist
  117. irp z,<arglist>
  118. savereg z
  119. endm
  120. endm
  121. defvar macro name
  122. name = vars
  123. vars = vars + 4
  124. stack = stack + 4
  125. endm
  126. defvars macro arglist
  127. irp z,<arglist>
  128. defvar z
  129. endm
  130. endm
  131. defarg macro name
  132. name = stack + args
  133. args = args + 4
  134. endm
  135. defargs macro arglist
  136. irp z,<arglist>
  137. defarg z
  138. endm
  139. endm
  140. regarg macro name
  141. ifdef STACK_CALL
  142. defarg name
  143. else
  144. defvar name
  145. endif
  146. endm
  147. regargs macro arglist
  148. irp z,<arglist>
  149. regarg z
  150. endm
  151. endm
  152. return macro
  153. ifdef STACK_CALL
  154. ret
  155. else
  156. ret args
  157. endif
  158. endm
  159. ifdef BCC ;{
  160. beginproc macro prefix,GF,Te,Tr,name ;{
  161. align 4
  162. ifndef DEPTH
  163. display "DEPTH must be defined for modules using the beginproc macro"
  164. endif
  165. if DEPTH eq 0
  166. prefix&name equ _&prefix&GF&Tr&Te&name
  167. else
  168. if DEPTH eq 8
  169. prefix&name equ _&prefix&8&GF&Tr&Te&name
  170. else
  171. prefix&name equ _&prefix&16&GF&Tr&Te&name
  172. endif
  173. endif
  174. public prefix&name
  175. prefix&name proc
  176. endm ;}
  177. else ;} ifndef BCC {
  178. beginproc macro prefix,GF,Z,Te,Tr,name ;{
  179. align 4
  180. ifndef DEPTH
  181. display "DEPTH must be defined for modules using the beginproc macro"
  182. endif
  183. ifdef STACK_CALL ;{
  184. if DEPTH eq 0
  185. prefix&name equ prefix&GF&Z&Tr&Te&name
  186. else
  187. if DEPTH eq 8
  188. prefix&name equ prefix&8_&GF&Z&Tr&Te&name
  189. else
  190. prefix&name equ prefix&16_&GF&Z&Tr&Te&name
  191. endif
  192. endif
  193. else ;} else {
  194. if DEPTH eq 0
  195. prefix&name equ prefix&GF&Tr&Te&name&_
  196. else
  197. if DEPTH eq 8
  198. prefix&name equ prefix&8&GF&Tr&Te&name&_
  199. else
  200. prefix&name equ prefix&16&GF&Tr&Te&name&_
  201. endif
  202. endif
  203. endif ;}
  204. public prefix&name
  205. prefix&name proc
  206. endm ;}
  207. endif ;}
  208. ifdef BCC ;{
  209. endproc macro prefix,name ;{
  210. ifndef DEPTH
  211. display "DEPTH must be defined for modules using the endproc macro"
  212. endif
  213. if DEPTH eq 8
  214. _&prefix&name endp
  215. else
  216. _&prefix&name endp
  217. endif
  218. endm ;}
  219. else ;} ifndef BCC {
  220. endproc macro prefix,GF,Z,Te,Tr,name ;{
  221. ifndef DEPTH
  222. display "DEPTH must be defined for modules using the endproc macro"
  223. endif
  224. ifdef STACK_CALL
  225. if DEPTH eq 0
  226. prefix&GF&Tr&Te&name endp
  227. else
  228. if DEPTH eq 8
  229. prefix&8_&GF&Z&Tr&Te&name endp
  230. else
  231. prefix&16_&GF&Z&Tr&Te&name endp
  232. endif
  233. endif
  234. else
  235. if DEPTH eq 0
  236. prefix&GF&Tr&Te&name&_ endp
  237. else
  238. if DEPTH eq 8
  239. prefix&8&GF&Tr&Te&name&_ endp
  240. else
  241. prefix&16&GF&Tr&Te&name&_ endp
  242. endif
  243. endif
  244. endif
  245. endm ;}
  246. endif ;}
  247. ; ************************************************************************
  248. itoval macro reg
  249. shl reg,10h
  250. endm
  251. FDUP macro
  252. fld st(0)
  253. endm
  254. FDROP macro
  255. fstp st(0)
  256. endm
  257. FRECIPROCAL macro
  258. fld1
  259. fdivrp st(1),st
  260. endm
  261. FCOMXX macro v
  262. fcom v
  263. fnstsw ax
  264. sahf
  265. endm