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.

368 lines
7.5 KiB

  1. ;****************************Public Macro************************************
  2. ;
  3. ; ComposeInst Inst,p1,p2,p3,p4,p5,p6,p7,p8,p9
  4. ;
  5. ; This macro simply concatenates all arguments into one string.
  6. ;
  7. ; History:
  8. ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
  9. ; Created
  10. ;
  11. ;****************************************************************************
  12. ComposeInst macro Inst,p1,p2,p3,p4,p5,p6,p7,p8,p9
  13. &Inst &p1&p2&p3&p4&p5&p6&p7&p8&p9
  14. endm
  15. ;****************************Public Macro************************************
  16. ;
  17. ; CountArg cCount,ArgList
  18. ;
  19. ; This macro count the number of arguments in the ArgList and returns
  20. ; the value in cCount.
  21. ;
  22. ; History:
  23. ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
  24. ; Created
  25. ;
  26. ;****************************************************************************
  27. CountArg macro cCount,ArgList
  28. cCount = 0
  29. irp arg,<ArgList>
  30. cCount = cCount+1
  31. endm
  32. endm
  33. ;****************************Public Macro************************************
  34. ;
  35. ; RevPush ArgList,cCount
  36. ;
  37. ; This macro pushes the arguments in ArgList in the reverse order
  38. ; and returns the number of arguments in cCount.
  39. ;
  40. ; History:
  41. ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
  42. ; Created
  43. ;
  44. ;****************************************************************************
  45. RevPush macro ArgList,cCount
  46. Local index,x
  47. CountArg cCount,<ArgList>
  48. index = cCount
  49. rept cCount
  50. x = 0
  51. irp arg,<ArgList>
  52. x = x+1
  53. ife index-x
  54. push arg
  55. exitm
  56. endif
  57. endm
  58. index = index-1
  59. endm
  60. endm
  61. ;****************************Public Macro************************************
  62. ;
  63. ; The following sections contain calling-convention related macros for:
  64. ;
  65. ; PUBLICP Func,N
  66. ; to define a public label
  67. ;
  68. ; EXTRNP Func,N
  69. ; to define a external near label
  70. ;
  71. ; LABELP Func,N
  72. ; to label an address as a routine entry point
  73. ;
  74. ; cProc Func,N,ArgList
  75. ; to declare a routine header
  76. ;
  77. ; ProcName Name,Func,N
  78. ; to rename a function Func to Name. Using it in conjunction with
  79. ; normal function declaration (with the new name) will solve an error
  80. ; caused by a long parameter list routine that exhausts page width.
  81. ;
  82. ; cRet Func
  83. ; to return from Func routines (declared with cProc or ProcName.)
  84. ;
  85. ; endProc Func
  86. ; to declare the end of routine (declared with cProc or ProcName.)
  87. ;
  88. ; endMod Func
  89. ; to declare the end of module with an entry point at Func (declared
  90. ; with cProc or ProcName.)
  91. ;
  92. ; cCall Func,ArgList
  93. ; to call to a routine--Func--with the arguments pushed on the stack
  94. ;
  95. ; ptrCall Func,ArgList
  96. ; to call through a pointer with the arguments pushed on the stack
  97. ;
  98. ; MovAddr dest,Func,n
  99. ; to move the address of the routine--Func--into dest.
  100. ;
  101. ; Note that for the standard calling convention all the function names,
  102. ; Func, are automatically converted to Func@N where N is the number of
  103. ; bytes in the argument list.
  104. ;
  105. ; History:
  106. ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
  107. ; Created
  108. ;
  109. ;****************************************************************************
  110. IFNDEF DOS_PLATFORM
  111. IFNDEF STD_CALL
  112. ;****************************************************************************
  113. ;
  114. ; This section is used exclusively for C calling convention.
  115. ;
  116. ;****************************************************************************
  117. PUBLICP macro Func,N
  118. public &Func
  119. endm
  120. EXTRNP macro Func,N
  121. extrn &Func:NEAR
  122. endm
  123. LABELP macro Func,N
  124. &Func LABEL NEAR
  125. endm
  126. ProcName macro Name,Func,N
  127. &Name EQU <&Func>
  128. endm
  129. cProc macro Func,N,ArgList
  130. ProcName xxx&Func,Func,N
  131. xxx&Func proc &ArgList
  132. endm
  133. cRet macro Func
  134. ret
  135. endm
  136. endProc macro Func
  137. xxx&Func endp
  138. endm
  139. endMod macro Func
  140. end xxx&Func
  141. endm
  142. ptrCall macro Func,ArgList
  143. Local Bytes
  144. RevPush <ArgList>,Bytes
  145. Bytes = Bytes*4
  146. call &Func
  147. if Bytes GT 0
  148. add esp,Bytes
  149. endif
  150. endm
  151. cCall macro Func,ArgList
  152. Local Bytes
  153. RevPush <ArgList>,Bytes
  154. Bytes = Bytes*4
  155. call &Func
  156. if Bytes GT 0
  157. add esp,Bytes
  158. endif
  159. endm
  160. MovAddr macro dest,addr,n
  161. mov dest,offset FLAT:&addr
  162. endm
  163. ENDIF ; STD_CALL
  164. ELSE
  165. IFNDEF STD_CALL
  166. ;****************************************************************************
  167. ;
  168. ; This section is used exclusively for Pascal calling convention.
  169. ;
  170. ;****************************************************************************
  171. PUBLICP macro Func,N
  172. public &Func
  173. endm
  174. EXTRNP macro Func,N
  175. extrn &Func:NEAR
  176. endm
  177. LABELP macro Func,N
  178. &Func LABEL NEAR
  179. endm
  180. ProcName macro Name,Func,N
  181. &Name EQU <&Func>
  182. endm
  183. cProc macro Func,N,ArgList
  184. ProcName xxx&Func,Func,N
  185. xxx&Func proc &ArgList
  186. endm
  187. cRet macro Func
  188. ret
  189. endm
  190. endProc macro Func
  191. xxx&Func endp
  192. endm
  193. endMod macro Func
  194. end xxx&Func
  195. endm
  196. cCall macro Func,ArgList
  197. irp arg,<ArgList>
  198. push arg
  199. endm
  200. call &Func
  201. endm
  202. MovAddr macro dest,addr,n
  203. mov dest,offset FLAT:&addr
  204. endm
  205. ENDIF : ~STD_CALL
  206. ENDIF ; DOS_PLATFORM
  207. IFDEF STD_CALL
  208. ;****************************************************************************
  209. ;
  210. ; This section is used exclusively for the standard calling convention.
  211. ;
  212. ;****************************************************************************
  213. PUBLICP macro Func,N
  214. ifb <N>
  215. public &Func&@0
  216. else
  217. public &Func&@&N
  218. endif
  219. endm
  220. EXTRNP macro Func,N
  221. ifb <N>
  222. extrn &Func&@0:NEAR
  223. else
  224. extrn &Func&@&N:NEAR
  225. endif
  226. endm
  227. LABELP macro Func,N
  228. ifb <N>
  229. &Func&@0 LABEL NEAR
  230. else
  231. &Func&@&N LABEL NEAR
  232. endif
  233. endm
  234. ProcName macro Name,Func,N
  235. ifb <N>
  236. cByte&Func EQU 0
  237. &Name EQU <&Func&@0>
  238. else
  239. cByte&Func EQU N
  240. &Name EQU <&Func&@&N>
  241. endif
  242. endm
  243. cProc macro Func,N,ArgList
  244. ProcName xxx&Func,Func,N
  245. xxx&Func proc &ArgList
  246. endm
  247. cRet macro Func
  248. ret cByte&Func
  249. endm
  250. endProc macro Func
  251. xxx&Func endp
  252. endm
  253. endMod macro Func
  254. end xxx&Func
  255. endm
  256. ptrCall macro Func,ArgList
  257. Local Bytes
  258. RevPush <ArgList>,Bytes
  259. call &Func
  260. endm
  261. cCall macro Func,ArgList
  262. Local Bytes
  263. RevPush <ArgList>,Bytes
  264. Bytes = Bytes*4
  265. ComposeInst <call>,&Func,<@>,%(Bytes)
  266. endm
  267. MovAddr macro dest,addr,n
  268. ComposeInst <mov >,dest,<,offset FLAT:>,addr,<@>,n
  269. endm
  270. ENDIF ;STD_CALL
  271.