home *** CD-ROM | disk | FTP | other *** search
/ Best Sellers 7: Football Classics 2 / CD1.iso / utils / wing10 / cmacro32.in_ / cmacro32.in
Text File  |  1995-09-20  |  21KB  |  1,484 lines

  1. ?386regs=1
  2. PMODE=1
  3. ?WIN=0
  4. ?SMALL=1
  5.  
  6. ifndef ?auto32
  7.     ?auto32 = 1
  8. endif
  9.  
  10. comment $
  11. cmacros - assembly macros for interfacing to hlls
  12. (C) Copyright 1984-1994 Microsoft Corp.  All rights reserved.
  13. $
  14. .xcref
  15. .xcref ??_out
  16. ??_out macro t
  17. ifndef ?QUIET
  18. %out t
  19. endif
  20. endm
  21. outif macro name,defval,onmsg,offmsg
  22. ifndef name
  23. ifb <defval>
  24. name=0
  25. else
  26. name=defval
  27. endif
  28. endif
  29. if name
  30. name=1
  31. ifnb <onmsg>
  32. ??_out <! onmsg>
  33. endif
  34. else
  35. ifnb <offmsg>
  36. ??_out <! offmsg>
  37. endif
  38. endif
  39. endm
  40. .xcref ??error
  41. ??error macro msg
  42. e r r o r ----- msg
  43. .err
  44. endm
  45. .xcref ASMpass
  46. .xcref memS,memM,memL,memC,memH,memMOD,sizec,sized
  47. if1
  48. ASMpass=1
  49. ifdef ?SMALL
  50. memS=1
  51. endif
  52. ifdef ?MEDIUM
  53. memM=1
  54. endif
  55. ifdef ?COMPACT
  56. memC=1
  57. endif
  58. ifdef ?LARGE
  59. memL=1
  60. endif
  61. ifdef ?HUGE
  62. memH=1
  63. endif
  64. ??_out <cMacros WinG 32-bit Version - Copyright (C) 1994 Microsoft Corp.>
  65. outif memS,0,<Small model>
  66. outif memM,0,<Medium model>
  67. outif memL,0,<Large model>
  68. outif memC,0,<Compact model>
  69. outif memH,0,<Huge model>
  70. outif ?auto32,0,<Discardable 32bit code segment hack enabled>
  71. memMOD= memS + memM + memL + memC + memH
  72. if memMOD ne 1
  73. if memMOD eq 0
  74. memS = 1
  75. else
  76. ??error <more than 1 memory model selected>
  77. endif
  78. endif
  79. sizec= memM + memL + memH
  80. sized= memL + memC + (memH*2)
  81. outif ?DF,0,<No segments or groups will be defined>
  82. outif ?TF,0,<Epilog sequences assume valid SP>
  83. outif ?WIN,1,<Windows support>
  84. ifdef PMODE
  85. ?pmd=1
  86. ??_out <! 386 protect mode use32>
  87. else
  88. ?pmd=0
  89. endif
  90. ifdef ?386regs
  91. if ?386regs
  92. ??_out <! 386 registers enabled>
  93. endif
  94. else
  95. ?386regs=0
  96. endif
  97. if ?WIN eq 1
  98. outif ?PLM,1,<>
  99. else
  100. outif ?PLM,1,<Pascal calling convention>
  101. endif
  102. ifndef ?NODATA
  103. ?nodata1=0
  104. else
  105. ?nodata1=1
  106. ??_out <! NODATA module>
  107. endif
  108. ifndef ?CHKSTK
  109. ?chkstk1=0
  110. else
  111. ?chkstk1=1
  112. ifdef ?CHKSTKPROC
  113. ??_out <! Private stack checking enabled>
  114. else
  115. ??_out <! Stack checking enabled>
  116. endif
  117. endif
  118. ifndef DOS5
  119. ?DOS5=0
  120. else
  121. ?DOS5=1
  122. ??_out <! DOS5 module>
  123. endif
  124. ifdef ?PROFILE
  125. ??_out <! Native profiling enabled>
  126. endif
  127. else
  128. ASMpass=2
  129. endif
  130. ifdef ?pmd
  131. ;.286p
  132. .386p
  133. endif
  134. if ?386regs
  135. .xcref ?n,?ax,?eax,?bx,?ebx
  136. .xcref ?cx,?ecx,?dx,?edx
  137. .xcref ?si,?esi,?di,?edi,?es,?ds,?fs
  138. .xcref ?gs
  139. else
  140. .xcref ?n,?ax,?ah,?al,?bx,?bh
  141. .xcref ?bl,?cx,?ch,?cl,?dx,?dh
  142. .xcref ?dl,?si,?di,?es,?ds,?bp
  143. .xcref ?sp,?ss,?cs
  144. endif
  145. .xcref ?rsl,?cpd,?argl,?argc,?ba
  146. .xcref ?acb,???,?po
  147. .xcref ?pas,?pc
  148. .xcref uconcat,mpush,mpop
  149. .xcref ?ri,?pp,?pp1,?al1
  150. .xcref ?ad,?ap,?atal,?dd,?dd1,?dd2
  151. .xcref ?pg,?pg1,?aloc,?cs1,?cs2
  152. .xcref ?DF,?TF,?ff,?PLM,?WIN,?ia,?pu,?adj
  153. .xcref ?uf,?rp,?nx,?nd,?nodata1,?chkstk1,?DOS5,?pmd,?lds,?exp
  154. .xcref ?wfp,arg,cCall,cProc,assumes,?cs3,?cs2,?cs1
  155. .xcref defgrp,addseg,createSeg
  156. .xcref save,outif,errnz,errn$,errnz1
  157. .xcref ?PLMPrevParm,?gcc
  158. .xcref ?cCall1,?pcc
  159. ?rsl = 0
  160. ?cpd = 0
  161. ?argl = 0
  162. ?argc = 0
  163. ?ba = 0
  164. ?acb = 0
  165. ??? = 0
  166. ?po = 0
  167. ?pas = 0
  168. ?pc = 0
  169. ?ia = 0
  170. ?pu = 0
  171. ?adj = 0
  172. ?rp = 0
  173. ?uf = 0
  174. ?nd = 0
  175. ?nx = 0
  176. ?wfp = 0
  177. ?lds = 0
  178. ?exp = 0
  179. ?ff = 0
  180. ?dd2 = 0
  181. ?cCall1 = 0
  182. ?pcc = 0
  183. ?PLMPrevParm = 0
  184. .xcref ?casen
  185. if1
  186. ?casen = 0
  187. endif
  188. if ?386regs
  189. ?n = 0000000000000000b
  190. ?ax = 0000000000000001b
  191. ?eax = 0000000000000010b
  192. ?bx = 0000000000000100b
  193. ?ebx = 0000000000001000b
  194. ?cx = 0000000000010000b
  195. ?ecx = 0000000000100000b
  196. ?dx = 0000000001000000b
  197. ?edx = 0000000010000000b
  198. ?si = 0000000100000000b
  199. ?esi = 0000001000000000b
  200. ?di = 0000010000000000b
  201. ?edi = 0000100000000000b
  202. ?ds = 0001000000000000b
  203. ?es = 0010000000000000b
  204. ?fs = 0100000000000000b
  205. ?gs = 1000000000000000b
  206. else
  207. ?n = 0000000000000000b
  208. ?ax = 0000000000000011b
  209. ?ah = 0000000000000001b
  210. ?al = 0000000000000010b
  211. ?bx = 0000000000001100b
  212. ?bh = 0000000000000100b
  213. ?bl = 0000000000001000b
  214. ?cx = 0000000000110000b
  215. ?ch = 0000000000010000b
  216. ?cl = 0000000000100000b
  217. ?dx = 0000000011000000b
  218. ?dh = 0000000001000000b
  219. ?dl = 0000000010000000b
  220. ?si = 0000000100000000b
  221. ?di = 0000001000000000b
  222. ?es = 0000010000000000b
  223. ?ds = 0000100000000000b
  224. ?bp = 0001000000000000b
  225. ?sp = 0010000000000000b
  226. ?ss = 0100000000000000b
  227. ?cs = 1000000000000000b
  228. endif
  229. .cref
  230. uconcat macro a,b,c,d,e,f,g
  231. a&b c&d e&f&g
  232. endm
  233. if ?386regs
  234. mpush macro r
  235. irp x,<ax,eax,bx,ebx,cx,ecx,dx,edx,si,esi,di,edi,ds,es,fs,gs>
  236. if (r and ?&&x)
  237.     push    x
  238. endif
  239. endm
  240. endm
  241. else
  242. mpush macro r
  243. irp x,<ax,bx,cx,dx,si,di,es,ds,bp,sp,ss,cs>
  244. if (r and ?&&x)
  245.     push    x
  246. endif
  247. endm
  248. endm
  249. endif
  250. if ?386regs
  251. mpop macro r
  252. irp x,<gs,fs,es,ds,edi,di,esi,si,edx,dx,ecx,cx,ebx,bx,eax,ax>
  253. if (r and ?&&x)
  254.     pop    x
  255. endif
  256. endm
  257. endm
  258. else
  259. mpop macro r
  260. irp x,<cs,ss,sp,bp,ds,es,di,si,dx,cx,bx,ax>
  261. if (r and ?&&x)
  262.     pop    x
  263. endif
  264. endm
  265. endm
  266. endif
  267. save macro r
  268. ?rsl=0
  269. ?ri ?rsl,<r>
  270. endm
  271. ?ri macro n,r
  272. irp x,<r>
  273. .ERRNDEF ?&&x
  274. n=n or ?&&x
  275. endm
  276. endm
  277. .xcref
  278. .xcref parmB,parmW,parmD,parmQ,parmT,parmCP,parmDP
  279. .cref
  280. parmB macro n
  281. ?pp <n>,<byte>,2,1
  282. endm
  283. parmW macro n
  284. ?pp <n>,<word>,2,2
  285. endm
  286. parmD macro n
  287. ife ?PLM
  288. irp x,<n>
  289. ?pp <&&x>,<dword>,0,4
  290. ?pp <off_&&x>,<word>,2,2
  291. ?pp <seg_&&x>,<word>,2,2
  292. endm
  293. else
  294. irp x,<n>
  295. ?pp <seg_&&x>,<word>,2,2
  296. ?pp <off_&&x>,<word>,2,2
  297. ?pp <&&x>,<dword>,0,4
  298. endm
  299. endif
  300. endm
  301. parmQ macro n
  302. ?pp <n>,<qword>,8,8
  303. endm
  304. parmT macro n
  305. ?pp <n>,<tbyte>,10,10
  306. endm
  307. if sizec
  308. parmCP macro n
  309. parmD <n>
  310. endm
  311. else
  312. parmCP macro n
  313. parmW <n>
  314. endm
  315. endif
  316. if sized
  317. parmDP macro n
  318. parmD <n>
  319. endm
  320. else
  321. parmDP macro n
  322. parmW <n>
  323. endm
  324. endif
  325. ?pp macro n,t,l,s
  326. if ?cpd
  327. .xcref
  328. irp x,<n>
  329. .xcref ?t&&x
  330. ?t&&x=s
  331. ife ?PLM
  332. ?pp1 x,<t>,,,%(?po+?adj)
  333. ?po=?po+l
  334. else
  335. ?PLMPrevParm=?PLMPrevParm+1
  336. ?po=?po+l
  337. ?pp1 x,<t>,%?po,%?adj,,%?PLMPrevParm,%(?PLMPrevParm-1)
  338. endif
  339. endm
  340. .cref
  341. else
  342. ??error <parm(s) "&n" declared outside proc def>
  343. endif
  344. endm
  345. ?pp1 macro n,t,o,a,b,cpc,ppc
  346. ife ?PLM
  347. n equ (t ptr [ebp+b])
  348. else
  349. .xcref
  350. .xcref ?PLMParm&cpc
  351. .cref
  352. ?PLMParm&cpc ¯o po
  353. uconcat <n>,,<equ>,,<(t ptr [ebp+>,%(a+po-o),<])>
  354. ?PLMParm&ppc po
  355. purge ?PLMParm&cpc
  356. &endm
  357. endif
  358. endm
  359. ifndef ?NOPARMR
  360. if ?pmd
  361. parmR macro n,r,r2
  362. ??error <Sorry: ParmR can't be used with PMODE=1>
  363. endm
  364. else
  365. .xcref
  366. .xcref ?pr,parmR
  367. .cref
  368. parmR macro n,r,r2
  369. ?pr n,r,r2,%?rp,%(?ia+2)
  370. endm
  371. ?pr macro n,r,r2,i,o
  372. .xcref
  373. ifnb <r2>
  374. parmR seg_&n,r
  375. parmR off_&n,r2
  376. n equ (dword ptr [ebp-o-2])
  377. .xcref ?t&n
  378. ?t&n=4
  379. else
  380. .xcref ?rp&i
  381. ?rp&i=0
  382. ifdef ?&r
  383. ?rp&i=?&r
  384. endif
  385. if ??? or (?cpd eq 0) or (?rp&i eq 0)
  386. ??error <invalid parmR encountered: &n,&r>
  387. exitm
  388. endif
  389. n equ (word ptr [ebp-o])
  390. ?t&n=2
  391. irp x,<bh,ch,dh,bl,cl,dl,ah,al>
  392. if ?&&x eq ?&r
  393. n equ (byte ptr [ebp-o])
  394. ?t&n=1
  395. exitm
  396. endif
  397. endm
  398. ?ia=?ia+2
  399. ?rp=?rp+1
  400. endif
  401. .cref
  402. endm
  403. endif
  404. endif
  405. .xcref
  406. .xcref localB,localW,localD,localQ,localT,localCP,localDP,localV
  407. .cref
  408. localB macro n
  409. ?aloc <n>,<byte ptr>,1,1,0
  410. endm
  411. localW macro n
  412. ?aloc <n>,<word ptr>,2,2,1
  413. endm
  414. localD macro n
  415. irp x,<n>
  416. ?aloc <seg_&&x>,<word ptr>,2,2,1
  417. ?aloc <off_&&x>,<word ptr>,2,2,1
  418. ?aloc <&&x>,<dword ptr>,0,4,1
  419. endm
  420. endm
  421. localQ macro n
  422. ?aloc <n>,<qword ptr>,8,8,1
  423. endm
  424. localT macro n
  425. ?aloc <n>,<tbyte ptr>,10,10,1
  426. endm
  427. if sizec
  428. localCP macro n
  429. localD <n>
  430. endm
  431. else
  432. localCP macro n
  433. localW <n>
  434. endm
  435. endif
  436. if sized
  437. localDP macro n
  438. localD <n>
  439. endm
  440. else
  441. localDP macro n
  442. localW <n>
  443. endm
  444. endif
  445. localV macro n,a
  446. ?aloc <n>,,%(a),0,1
  447. endm
  448. ?aloc macro n,t,l,s,a
  449. if ?cpd
  450. .xcref
  451. irp x,<n>
  452. ???=???+l
  453. if a
  454. ???=((??? + 1) and 0fffeh)
  455. endif
  456. ?al1 x,<t>,%(???+?ia)
  457. .xcref ?t&&x
  458. ?t&&x=s
  459. endm
  460. .cref
  461. else
  462. ??error <locals "&n" declared outside procedure def>
  463. endif
  464. endm
  465. ?al1 macro n,t,o
  466. n equ (t [ebp-o])
  467. endm
  468. ?gcc macro s,i,cc
  469. s = i
  470. ifnb <cc>
  471. ifidn <cc>,<C>
  472. s=0
  473. endif
  474. ifidn <cc>,<PLM>
  475. s=1
  476. endif
  477. ifidn <cc>,<PASCAL>
  478. s=1
  479. endif
  480. endif
  481. endm
  482. ifndef ?NOGLOBAL
  483. .xcref
  484. .xcref globalB,globalW,globalD,globalQ,globalT,globalCP,globalDP
  485. .cref
  486. globalB macro n,i,s,c
  487. ?ad <n>,1
  488. ?dd n,1,<byte>,<db>,<i>,<s>,<c>
  489. endm
  490. globalW macro n,i,s,c
  491. ?ad <n>,2
  492. ?dd n,1,<word>,<dw>,<i>,<s>,<c>
  493. endm
  494. globalD macro n,i,s,c
  495. ?ad <n>,4
  496. ?dd n,1,<dword>,<dd>,<i>,<s>,<c>
  497. off_&n equ n
  498. seg_&n equ n[2]
  499. endm
  500. globalQ macro n,i,s,c
  501. ?ad <n>,8
  502. ?dd n,1,<qword>,<dq>,<i>,<s>,<c>
  503. endm
  504. globalT macro n,i,s,c
  505. ?ad <n>,10
  506. ?dd n,1,<tbyte>,<dt>,<i>,<s>,<c>
  507. endm
  508.