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.

1483 lines
21 KiB

  1. ?386regs=1
  2. PMODE=1
  3. ?WIN=0
  4. ?SMALL=1
  5. ifndef ?auto32
  6. ?auto32 = 1
  7. endif
  8. comment $
  9. cmacros - assembly macros for interfacing to hlls
  10. (C)Copyright Microsoft Corp. 1984-1988
  11. $
  12. .xcref
  13. .xcref ??_out
  14. ??_out macro t
  15. ifndef ?QUIET
  16. %out t
  17. endif
  18. endm
  19. outif macro name,defval,onmsg,offmsg
  20. ifndef name
  21. ifb <defval>
  22. name=0
  23. else
  24. name=defval
  25. endif
  26. endif
  27. if name
  28. name=1
  29. ifnb <onmsg>
  30. ??_out <! onmsg>
  31. endif
  32. else
  33. ifnb <offmsg>
  34. ??_out <! offmsg>
  35. endif
  36. endif
  37. endm
  38. .xcref ??error
  39. ??error macro msg
  40. e r r o r ----- msg
  41. .err
  42. endm
  43. .xcref ASMpass
  44. .xcref memS,memM,memL,memC,memH,memMOD,sizec,sized
  45. if1
  46. ASMpass=1
  47. ifdef ?SMALL
  48. memS=1
  49. endif
  50. ifdef ?MEDIUM
  51. memM=1
  52. endif
  53. ifdef ?COMPACT
  54. memC=1
  55. endif
  56. ifdef ?LARGE
  57. memL=1
  58. endif
  59. ifdef ?HUGE
  60. memH=1
  61. endif
  62. ??_out <cMacros ToddLa 32-bit Version - Copyright (c) Microsoft Corp. 1992>
  63. outif memS,0,<Small model>
  64. outif memM,0,<Medium model>
  65. outif memL,0,<Large model>
  66. outif memC,0,<Compact model>
  67. outif memH,0,<Huge model>
  68. outif ?auto32,0,<Discardable 32bit code segment hack enabled>
  69. memMOD= memS + memM + memL + memC + memH
  70. if memMOD ne 1
  71. if memMOD eq 0
  72. memS = 1
  73. else
  74. ??error <more than 1 memory model selected>
  75. endif
  76. endif
  77. sizec= memM + memL + memH
  78. sized= memL + memC + (memH*2)
  79. outif ?DF,0,<No segments or groups will be defined>
  80. outif ?TF,0,<Epilog sequences assume valid SP>
  81. outif ?WIN,1,<Windows support>
  82. ifdef PMODE
  83. ?pmd=1
  84. ??_out <! 386 protect mode use32>
  85. else
  86. ?pmd=0
  87. endif
  88. ifdef ?386regs
  89. if ?386regs
  90. ??_out <! 386 registers enabled>
  91. endif
  92. else
  93. ?386regs=0
  94. endif
  95. if ?WIN eq 1
  96. outif ?PLM,1,<>
  97. else
  98. outif ?PLM,1,<Pascal calling convention>
  99. endif
  100. ifndef ?NODATA
  101. ?nodata1=0
  102. else
  103. ?nodata1=1
  104. ??_out <! NODATA module>
  105. endif
  106. ifndef ?CHKSTK
  107. ?chkstk1=0
  108. else
  109. ?chkstk1=1
  110. ifdef ?CHKSTKPROC
  111. ??_out <! Private stack checking enabled>
  112. else
  113. ??_out <! Stack checking enabled>
  114. endif
  115. endif
  116. ifndef DOS5
  117. ?DOS5=0
  118. else
  119. ?DOS5=1
  120. ??_out <! DOS5 module>
  121. endif
  122. ifdef ?PROFILE
  123. ??_out <! Native profiling enabled>
  124. endif
  125. else
  126. ASMpass=2
  127. endif
  128. ifdef ?pmd
  129. ;.286p
  130. .386p
  131. endif
  132. if ?386regs
  133. .xcref ?n,?ax,?eax,?bx,?ebx
  134. .xcref ?cx,?ecx,?dx,?edx
  135. .xcref ?si,?esi,?di,?edi,?es,?ds,?fs
  136. .xcref ?gs
  137. else
  138. .xcref ?n,?ax,?ah,?al,?bx,?bh
  139. .xcref ?bl,?cx,?ch,?cl,?dx,?dh
  140. .xcref ?dl,?si,?di,?es,?ds,?bp
  141. .xcref ?sp,?ss,?cs
  142. endif
  143. .xcref ?rsl,?cpd,?argl,?argc,?ba
  144. .xcref ?acb,???,?po
  145. .xcref ?pas,?pc
  146. .xcref uconcat,mpush,mpop
  147. .xcref ?ri,?pp,?pp1,?al1
  148. .xcref ?ad,?ap,?atal,?dd,?dd1,?dd2
  149. .xcref ?pg,?pg1,?aloc,?cs1,?cs2
  150. .xcref ?DF,?TF,?ff,?PLM,?WIN,?ia,?pu,?adj
  151. .xcref ?uf,?rp,?nx,?nd,?nodata1,?chkstk1,?DOS5,?pmd,?lds,?exp
  152. .xcref ?wfp,arg,cCall,cProc,assumes,?cs3,?cs2,?cs1
  153. .xcref defgrp,addseg,createSeg
  154. .xcref save,outif,errnz,errn$,errnz1
  155. .xcref ?PLMPrevParm,?gcc
  156. .xcref ?cCall1,?pcc
  157. ?rsl = 0
  158. ?cpd = 0
  159. ?argl = 0
  160. ?argc = 0
  161. ?ba = 0
  162. ?acb = 0
  163. ??? = 0
  164. ?po = 0
  165. ?pas = 0
  166. ?pc = 0
  167. ?ia = 0
  168. ?pu = 0
  169. ?adj = 0
  170. ?rp = 0
  171. ?uf = 0
  172. ?nd = 0
  173. ?nx = 0
  174. ?wfp = 0
  175. ?lds = 0
  176. ?exp = 0
  177. ?ff = 0
  178. ?dd2 = 0
  179. ?cCall1 = 0
  180. ?pcc = 0
  181. ?PLMPrevParm = 0
  182. .xcref ?casen
  183. if1
  184. ?casen = 0
  185. endif
  186. if ?386regs
  187. ?n = 0000000000000000b
  188. ?ax = 0000000000000001b
  189. ?eax = 0000000000000010b
  190. ?bx = 0000000000000100b
  191. ?ebx = 0000000000001000b
  192. ?cx = 0000000000010000b
  193. ?ecx = 0000000000100000b
  194. ?dx = 0000000001000000b
  195. ?edx = 0000000010000000b
  196. ?si = 0000000100000000b
  197. ?esi = 0000001000000000b
  198. ?di = 0000010000000000b
  199. ?edi = 0000100000000000b
  200. ?ds = 0001000000000000b
  201. ?es = 0010000000000000b
  202. ?fs = 0100000000000000b
  203. ?gs = 1000000000000000b
  204. else
  205. ?n = 0000000000000000b
  206. ?ax = 0000000000000011b
  207. ?ah = 0000000000000001b
  208. ?al = 0000000000000010b
  209. ?bx = 0000000000001100b
  210. ?bh = 0000000000000100b
  211. ?bl = 0000000000001000b
  212. ?cx = 0000000000110000b
  213. ?ch = 0000000000010000b
  214. ?cl = 0000000000100000b
  215. ?dx = 0000000011000000b
  216. ?dh = 0000000001000000b
  217. ?dl = 0000000010000000b
  218. ?si = 0000000100000000b
  219. ?di = 0000001000000000b
  220. ?es = 0000010000000000b
  221. ?ds = 0000100000000000b
  222. ?bp = 0001000000000000b
  223. ?sp = 0010000000000000b
  224. ?ss = 0100000000000000b
  225. ?cs = 1000000000000000b
  226. endif
  227. .cref
  228. uconcat macro a,b,c,d,e,f,g
  229. a&b c&d e&f&g
  230. endm
  231. if ?386regs
  232. mpush macro r
  233. irp x,<ax,eax,bx,ebx,cx,ecx,dx,edx,si,esi,di,edi,ds,es,fs,gs>
  234. if (r and ?&&x)
  235. push x
  236. endif
  237. endm
  238. endm
  239. else
  240. mpush macro r
  241. irp x,<ax,bx,cx,dx,si,di,es,ds,bp,sp,ss,cs>
  242. if (r and ?&&x)
  243. push x
  244. endif
  245. endm
  246. endm
  247. endif
  248. if ?386regs
  249. mpop macro r
  250. irp x,<gs,fs,es,ds,edi,di,esi,si,edx,dx,ecx,cx,ebx,bx,eax,ax>
  251. if (r and ?&&x)
  252. pop x
  253. endif
  254. endm
  255. endm
  256. else
  257. mpop macro r
  258. irp x,<cs,ss,sp,bp,ds,es,di,si,dx,cx,bx,ax>
  259. if (r and ?&&x)
  260. pop x
  261. endif
  262. endm
  263. endm
  264. endif
  265. save macro r
  266. ?rsl=0
  267. ?ri ?rsl,<r>
  268. endm
  269. ?ri macro n,r
  270. irp x,<r>
  271. .ERRNDEF ?&&x
  272. n=n or ?&&x
  273. endm
  274. endm
  275. .xcref
  276. .xcref parmB,parmW,parmD,parmQ,parmT,parmCP,parmDP
  277. .cref
  278. parmB macro n
  279. ?pp <n>,<byte>,2,1
  280. endm
  281. parmW macro n
  282. ?pp <n>,<word>,2,2
  283. endm
  284. parmD macro n
  285. ife ?PLM
  286. irp x,<n>
  287. ?pp <&&x>,<dword>,0,4
  288. ?pp <off_&&x>,<word>,2,2
  289. ?pp <seg_&&x>,<word>,2,2
  290. endm
  291. else
  292. irp x,<n>
  293. ?pp <seg_&&x>,<word>,2,2
  294. ?pp <off_&&x>,<word>,2,2
  295. ?pp <&&x>,<dword>,0,4
  296. endm
  297. endif
  298. endm
  299. parmQ macro n
  300. ?pp <n>,<qword>,8,8
  301. endm
  302. parmT macro n
  303. ?pp <n>,<tbyte>,10,10
  304. endm
  305. if sizec
  306. parmCP macro n
  307. parmD <n>
  308. endm
  309. else
  310. parmCP macro n
  311. parmW <n>
  312. endm
  313. endif
  314. if sized
  315. parmDP macro n
  316. parmD <n>
  317. endm
  318. else
  319. parmDP macro n
  320. parmW <n>
  321. endm
  322. endif
  323. ?pp macro n,t,l,s
  324. if ?cpd
  325. .xcref
  326. irp x,<n>
  327. .xcref ?t&&x
  328. ?t&&x=s
  329. ife ?PLM
  330. ?pp1 x,<t>,,,%(?po+?adj)
  331. ?po=?po+l
  332. else
  333. ?PLMPrevParm=?PLMPrevParm+1
  334. ?po=?po+l
  335. ?pp1 x,<t>,%?po,%?adj,,%?PLMPrevParm,%(?PLMPrevParm-1)
  336. endif
  337. endm
  338. .cref
  339. else
  340. ??error <parm(s) "&n" declared outside proc def>
  341. endif
  342. endm
  343. ?pp1 macro n,t,o,a,b,cpc,ppc
  344. ife ?PLM
  345. n equ (t ptr [ebp+b])
  346. else
  347. .xcref
  348. .xcref ?PLMParm&cpc
  349. .cref
  350. ?PLMParm&cpc &macro po
  351. uconcat <n>,,<equ>,,<(t ptr [ebp+>,%(a+po-o),<])>
  352. ?PLMParm&ppc po
  353. purge ?PLMParm&cpc
  354. &endm
  355. endif
  356. endm
  357. ifndef ?NOPARMR
  358. if ?pmd
  359. parmR macro n,r,r2
  360. ??error <Sorry: ParmR can't be used with PMODE=1>
  361. endm
  362. else
  363. .xcref
  364. .xcref ?pr,parmR
  365. .cref
  366. parmR macro n,r,r2
  367. ?pr n,r,r2,%?rp,%(?ia+2)
  368. endm
  369. ?pr macro n,r,r2,i,o
  370. .xcref
  371. ifnb <r2>
  372. parmR seg_&n,r
  373. parmR off_&n,r2
  374. n equ (dword ptr [ebp-o-2])
  375. .xcref ?t&n
  376. ?t&n=4
  377. else
  378. .xcref ?rp&i
  379. ?rp&i=0
  380. ifdef ?&r
  381. ?rp&i=?&r
  382. endif
  383. if ??? or (?cpd eq 0) or (?rp&i eq 0)
  384. ??error <invalid parmR encountered: &n,&r>
  385. exitm
  386. endif
  387. n equ (word ptr [ebp-o])
  388. ?t&n=2
  389. irp x,<bh,ch,dh,bl,cl,dl,ah,al>
  390. if ?&&x eq ?&r
  391. n equ (byte ptr [ebp-o])
  392. ?t&n=1
  393. exitm
  394. endif
  395. endm
  396. ?ia=?ia+2
  397. ?rp=?rp+1
  398. endif
  399. .cref
  400. endm
  401. endif
  402. endif
  403. .xcref
  404. .xcref localB,localW,localD,localQ,localT,localCP,localDP,localV
  405. .cref
  406. localB macro n
  407. ?aloc <n>,<byte ptr>,1,1,0
  408. endm
  409. localW macro n
  410. ?aloc <n>,<word ptr>,2,2,1
  411. endm
  412. localD macro n
  413. irp x,<n>
  414. ?aloc <seg_&&x>,<word ptr>,2,2,1
  415. ?aloc <off_&&x>,<word ptr>,2,2,1
  416. ?aloc <&&x>,<dword ptr>,0,4,1
  417. endm
  418. endm
  419. localQ macro n
  420. ?aloc <n>,<qword ptr>,8,8,1
  421. endm
  422. localT macro n
  423. ?aloc <n>,<tbyte ptr>,10,10,1
  424. endm
  425. if sizec
  426. localCP macro n
  427. localD <n>
  428. endm
  429. else
  430. localCP macro n
  431. localW <n>
  432. endm
  433. endif
  434. if sized
  435. localDP macro n
  436. localD <n>
  437. endm
  438. else
  439. localDP macro n
  440. localW <n>
  441. endm
  442. endif
  443. localV macro n,a
  444. ?aloc <n>,,%(a),0,1
  445. endm
  446. ?aloc macro n,t,l,s,a
  447. if ?cpd
  448. .xcref
  449. irp x,<n>
  450. ???=???+l
  451. if a
  452. ???=((??? + 1) and 0fffeh)
  453. endif
  454. ?al1 x,<t>,%(???+?ia)
  455. .xcref ?t&&x
  456. ?t&&x=s
  457. endm
  458. .cref
  459. else
  460. ??error <locals "&n" declared outside procedure def>
  461. endif
  462. endm
  463. ?al1 macro n,t,o
  464. n equ (t [ebp-o])
  465. endm
  466. ?gcc macro s,i,cc
  467. s = i
  468. ifnb <cc>
  469. ifidn <cc>,<C>
  470. s=0
  471. endif
  472. ifidn <cc>,<PLM>
  473. s=1
  474. endif
  475. ifidn <cc>,<PASCAL>
  476. s=1
  477. endif
  478. endif
  479. endm
  480. ifndef ?NOGLOBAL
  481. .xcref
  482. .xcref globalB,globalW,globalD,globalQ,globalT,globalCP,globalDP
  483. .cref
  484. globalB macro n,i,s,c
  485. ?ad <n>,1
  486. ?dd n,1,<byte>,<db>,<i>,<s>,<c>
  487. endm
  488. globalW macro n,i,s,c
  489. ?ad <n>,2
  490. ?dd n,1,<word>,<dw>,<i>,<s>,<c>
  491. endm
  492. globalD macro n,i,s,c
  493. ?ad <n>,4
  494. ?dd n,1,<dword>,<dd>,<i>,<s>,<c>
  495. off_&n equ n
  496. seg_&n equ n[2]
  497. endm
  498. globalQ macro n,i,s,c
  499. ?ad <n>,8
  500. ?dd n,1,<qword>,<dq>,<i>,<s>,<c>
  501. endm
  502. globalT macro n,i,s,c
  503. ?ad <n>,10
  504. ?dd n,1,<tbyte>,<dt>,<i>,<s>,<c>
  505. endm
  506. if sizec
  507. globalCP macro n,i,s,c
  508. globalD n,<i>,<s>,<c>
  509. endm
  510. else
  511. globalCP macro n,i,s,c
  512. globalW n,<i>,<s>,<c>
  513. endm
  514. endif
  515. if sized
  516. globalDP macro n,i,s,c
  517. globalD n,<i>,<s>,<c>
  518. endm
  519. else
  520. globalDP macro n,i,s,c
  521. globalW n,<i>,<s>,<c>
  522. endm
  523. endif
  524. endif
  525. ifndef ?NOSTATIC
  526. .xcref
  527. .xcref staticB,staticW,staticD,staticQ,staticT,staticCP,staticDP
  528. .cref
  529. staticB macro n,i,s
  530. ?ad <n>,1
  531. ?dd n,0,<byte>,<db>,<i>,<s>,<PLM>
  532. endm
  533. staticW macro n,i,s
  534. ?ad <n>,2
  535. ?dd n,0,<word>,<dw>,<i>,<s>,<PLM>
  536. endm
  537. staticD macro n,i,s
  538. ?ad <n>,4
  539. ?dd n,0,<dword>,<dd>,<i>,<s>,<PLM>
  540. endm
  541. staticQ macro n,i,s
  542. ?ad <n>,8
  543. ?dd n,0,<qword>,<dq>,<i>,<s>,<PLM>
  544. endm
  545. staticT macro n,i,s
  546. ?ad <n>,10
  547. ?dd n,0,<tbyte>,<dt>,<i>,<s>,<PLM>
  548. endm
  549. if sizec
  550. staticCP macro n,i,s
  551. staticD n,<i>,<s>
  552. endm
  553. else
  554. staticCP macro n,i,s
  555. staticW n,<i>,<s>
  556. endm
  557. endif
  558. if sized
  559. staticDP macro n,i,s
  560. staticD n,<i>,<s>
  561. endm
  562. else
  563. staticDP macro n,i,s
  564. staticW n,<i>,<s>
  565. endm
  566. endif
  567. endif
  568. ?dd macro n,p,t,d,i,s,c
  569. ?gcc ?dd2,%?PLM,<c>
  570. ife ?dd2
  571. n label t
  572. ?dd1 _&n,p,<d>,<i>,<s>
  573. else
  574. ?dd1 n,p,<d>,<i>,<s>
  575. endif
  576. endm
  577. ?dd1 macro n,p,d,i,s
  578. if p
  579. public n
  580. endif
  581. ifb <s>
  582. n d i
  583. else
  584. ifb <i>
  585. n d s dup (?)
  586. else
  587. n d s dup (i)
  588. endif
  589. endif
  590. endm
  591. ifndef ?NOEXTERN
  592. .xcref
  593. .xcref ?ex1,?ex2,externB,externW,externD,externQ,externT
  594. .xcref externNP,externFP,externP,externCP,externDP,externA
  595. .cref
  596. ?ex2 = 0
  597. externA macro n,c
  598. ?ex1 <n>,40h,<abs>,<c>,<>
  599. endm
  600. externB macro n,c
  601. ?ex1 <n>,1,<byte>,<c>,<>
  602. endm
  603. externW macro n,c
  604. ?ex1 <n>,2,<word>,<c>,<>
  605. endm
  606. externD macro n,c
  607. ?ex1 <n>,4,<dword>,<c>,<>
  608. endm
  609. externQ macro n,c
  610. ?ex1 <n>,8,<qword>,<c>,<>
  611. endm
  612. externT macro n,c
  613. ?ex1 <n>,10,<tbyte>,<c>,<>
  614. endm
  615. externNP macro n,c
  616. ?ex1 <n>,2,<near>,<c>,<cc>
  617. endm
  618. externFP macro n,c
  619. ?ex1 <n>,4,<far>,<c>,<cc>
  620. endm
  621. if sizec
  622. externP macro n,c
  623. ?ex1 <n>,4,<far>,<c>,<cc>
  624. endm
  625. else
  626. externP macro n,c
  627. ?ex1 <n>,2,<near>,<c>,<cc>
  628. endm
  629. endif
  630. if sizec
  631. externCP macro n,c
  632. ?ex1 <n>,4,<dword>,<c>,<>
  633. endm
  634. else
  635. externCP macro n,c
  636. ?ex1 <n>,2,<word>,<c>,<>
  637. endm
  638. endif
  639. if sized
  640. externDP macro n,c
  641. ?ex1 <n>,4,<dword>,<c>,<>
  642. endm
  643. else
  644. externDP macro n,c
  645. ?ex1 <n>,2,<word>,<c>,<>
  646. endm
  647. endif
  648. ?ex1 macro n,s,d,c,scv
  649. ?gcc ?ex2,%?PLM,<c>
  650. irp x,<n>
  651. .xcref
  652. .xcref ?t&&x
  653. .cref
  654. ?t&&x=s
  655. ife ?ex2
  656. extrn _&&x:&d
  657. x equ _&&x
  658. else
  659. extrn x:&d
  660. endif
  661. ifidn <scv>,<cc>
  662. .xcref
  663. .xcref ?CC&&x
  664. .cref
  665. ?CC&&x=?ex2
  666. endif
  667. endm
  668. endm
  669. endif
  670. ifndef ?NOLABEL
  671. .xcref
  672. .xcref ?lb1,?lblpu,?lb2
  673. .xcref labelB,labelW,labelD,labelQ,labelT
  674. .xcref labelNP,labelFP,labelP,labelCP,labelDP
  675. .cref
  676. ?lblpu = 0
  677. ?lb2 = 0
  678. labelB macro n,c
  679. ?lb1 <n>,1,<byte>,<c>
  680. endm
  681. labelW macro n,c
  682. ?lb1 <n>,2,<word>,<c>
  683. endm
  684. labelD macro n,c
  685. ?lb1 <n>,4,<dword>,<c>
  686. endm
  687. labelQ macro n,c
  688. ?lb1 <n>,8,<qword>,<c>
  689. endm
  690. labelT macro n,c
  691. ?lb1 <n>,10,<tbyte>,<c>
  692. endm
  693. labelNP macro n,c
  694. ?lb1 <n>,2,<near>,<c>
  695. endm
  696. labelFP macro n,c
  697. ?lb1 <n>,4,<far>,<c>
  698. endm
  699. if sizec
  700. labelP macro n,c
  701. ?lb1 <n>,4,<far>,<c>
  702. endm
  703. else
  704. labelP macro n,c
  705. ?lb1 <n>,2,<near>,<c>
  706. endm
  707. endif
  708. if sizec
  709. labelCP macro n,c
  710. ?lb1 <n>,4,<dword>,<c>
  711. endm
  712. else
  713. labelCP macro n,c
  714. ?lb1 <n>,2,<word>,<c>
  715. endm
  716. endif
  717. if sized
  718. labelDP macro n,c
  719. ?lb1 <n>,4,<dword>,<c>
  720. endm
  721. else
  722. labelDP macro n,c
  723. ?lb1 <n>,2,<word>,<c>
  724. endm
  725. endif
  726. ?lb1 macro n,s,d,c
  727. ?gcc ?lb2,%?PLM,<c>
  728. ?lblpu=0
  729. irp x,<n>
  730. ifidn <x>,<PUBLIC>
  731. ?lblpu=1
  732. else
  733. .xcref
  734. .xcref ?t&&x
  735. .cref
  736. ?t&&x=s
  737. ife ?lb2
  738. if ?lblpu
  739. public _&&x
  740. endif
  741. _&&x label &d
  742. x equ _&&x
  743. else
  744. if ?lblpu
  745. public x
  746. endif
  747. x label &d
  748. endif
  749. endif
  750. endm
  751. endm
  752. endif
  753. ifndef ?NODEF
  754. .xcref
  755. .xcref defB,defW,defD,defQ,defT,defCP,defDP
  756. .cref
  757. defB macro n
  758. ?ad <n>,1
  759. endm
  760. defW macro n
  761. ?ad <n>,2
  762. endm
  763. defD macro n
  764. ?ad <n>,4
  765. endm
  766. defQ macro n
  767. ?ad <n>,8
  768. endm
  769. defT macro n
  770. ?ad <n>,10
  771. endm
  772. if sizec
  773. defCP macro n
  774. defD <n>
  775. endm
  776. else
  777. defCP macro n
  778. defW <n>
  779. endm
  780. endif
  781. if sized
  782. defDP macro n
  783. defD <n>
  784. endm
  785. else
  786. defDP macro n
  787. defW <n>
  788. endm
  789. endif
  790. endif
  791. ?ad macro n,s
  792. irp x,<n>
  793. .xcref
  794. .xcref ?t&&x
  795. .cref
  796. ?t&&x=s
  797. endm
  798. endm
  799. ifndef ?NOPTR
  800. .xcref
  801. .xcref regPtr,farPtr
  802. .cref
  803. regPtr macro n,s,o
  804. farPtr n,s,o
  805. endm
  806. farPtr macro n,s,o
  807. .xcref
  808. .xcref ?t&n
  809. .cref
  810. n &macro
  811. push s
  812. push o
  813. &endm
  814. ?t&n=80h
  815. endm
  816. endif
  817. arg macro a
  818. irp x,<a>
  819. ?argc=?argc+1
  820. ?atal <x>,%?argc
  821. endm
  822. endm
  823. ?atal macro n,i
  824. .xcref
  825. .xcref ?ali&i
  826. .cref
  827. ?ali&i &macro
  828. ?ap n
  829. &endm
  830. endm
  831. ?ap macro n
  832. ?argl=?argl+2
  833. ifdef ?t&n
  834. ife ?t&n-1
  835. push word ptr (n)
  836. exitm
  837. endif
  838. ife ?t&n-2
  839. push n
  840. exitm
  841. endif
  842. ife ?t&n-4
  843. push word ptr (n)[2]
  844. push word ptr (n)
  845. ?argl=?argl+2
  846. exitm
  847. endif
  848. ife ?t&n-8
  849. push word ptr (n)[6]
  850. push word ptr (n)[4]
  851. push word ptr (n)[2]
  852. push word ptr (n)
  853. ?argl=?argl+6
  854. exitm
  855. endif
  856. if ?t&n and 80h
  857. n
  858. ?argl=?argl+2
  859. exitm
  860. endif
  861. ife ?t&n
  862. push word ptr (n)
  863. exitm
  864. endif
  865. endif
  866. push n
  867. endm
  868. cCall macro n,a,c
  869. ifnb <a>
  870. arg <a>
  871. endif
  872. mpush %?rsl
  873. ifdef ?CC&n
  874. ?cCall1=?CC&n
  875. else
  876. ?cCall1=?PLM
  877. endif
  878. ifnb <c>
  879. ?gcc ?cCall1,%?cCall1,<c>
  880. endif
  881. ?argl=0
  882. ife ?cCall1
  883. ?acb=?argc
  884. else
  885. ?acb=1
  886. endif
  887. rept ?argc
  888. uconcat <?ali>,%?acb
  889. uconcat <purge>,,<?ali>,%?acb
  890. ife ?cCall1
  891. ?acb=?acb-1
  892. else
  893. ?acb=?acb+1
  894. endif
  895. endm
  896. call n
  897. if ((?cCall1 eq 0) and (?argl ne 0))
  898. add sp,?argl
  899. endif
  900. mpop %?rsl
  901. ?rsl=0
  902. ?argc= 0
  903. ?argl= 0
  904. endm
  905. cProc macro n,cf,a
  906. if ?cpd
  907. ?utpe
  908. endif
  909. ?cpd=1
  910. ???=0
  911. ?argc=0
  912. ?ba=0
  913. ?po=0
  914. ?pu=0
  915. ?ia=0
  916. ?adj=4
  917. ?rp=0
  918. ?uf=0
  919. ?wfp=?WIN
  920. ?ff=0
  921. ?pas=0
  922. ?pcc=?PLM
  923. ?lds=0
  924. ?exp=0
  925. ifnb <a>
  926. ?ri ?pas,<a>
  927. endif
  928. ?pc=sizec
  929. ?nd=?nodata1
  930. ?nx=0
  931. irp x,<cf>
  932. ifidn <x>,<FAR>
  933. ?pc=1
  934. endif
  935. ifidn <x>,<NEAR>
  936. ?pc=0
  937. endif
  938. ifidn <x>,<PUBLIC>
  939. ?pu=1
  940. endif
  941. ifidn <x>,<SMALL>
  942. ?uf=1
  943. endif
  944. ifidn <x>,<DATA>
  945. ?nd=0
  946. endif
  947. ifidn <x>,<NODATA>
  948. ?nd=1
  949. endif
  950. ifidn <x>,<ATOMIC>
  951. ?nx=1
  952. endif
  953. ifidn <x>,<C>
  954. ?pcc=0
  955. endif
  956. ifidn <x>,<PLM>
  957. ?pcc=1
  958. endif
  959. ifidn <x>,<PASCAL>
  960. ?pcc=1
  961. endif
  962. ifidn <x>,<WIN>
  963. ?wfp=1
  964. endif
  965. ifidn <x>,<NONWIN>
  966. ?wfp=0
  967. endif
  968. ifidn <x>,<LOADDS>
  969. ?lds=1
  970. endif
  971. ifidn <x>,<EXPORTED>
  972. ?exp=1
  973. endif
  974. endm
  975. if ?pcc
  976. ?PLMPrevParm=0
  977. .xcref
  978. .xcref ?PLMParm0
  979. .cref
  980. ?PLMParm0 &macro
  981. purge ?PLMParm0
  982. &endm
  983. endif
  984. .xcref
  985. .xcref ?CC&n
  986. .cref
  987. ?CC&n=?pcc
  988. if (?nx eq 1) and (?nd eq 0)
  989. ?nx = 0
  990. ??error <ATOMIC specified without NODATA - ATOMIC ignored>
  991. endif
  992. if ?pc
  993. if ?wfp+?exp+?lds
  994. ife ?nx
  995. ife ?pmd
  996. ?ia=2
  997. endif
  998. ?pas = ?pas and (not ?ds)
  999. endif
  1000. endif
  1001. ?adj=?adj+2
  1002. else
  1003. ?wfp=0
  1004. endif
  1005. ife ?386regs
  1006. ?pas = ?pas and (not (?sp+?cs+?ss))
  1007. endif
  1008. if ?uf
  1009. if ?386regs
  1010. ?pas = ?pas and (not (?si+?di))
  1011. else
  1012. ?pas = ?pas and (not (?bp+?si+?di))
  1013. endif
  1014. endif
  1015. ife ?pcc
  1016. ?pg <_&n>,%?pu,%?pc,%?pas,%?wfp,<n>,%?pcc
  1017. else
  1018. ?pg <n>,%?pu,%?pc,%?pas,%?wfp,<n>,%?pcc
  1019. endif
  1020. endm
  1021. ?pg macro n,p,c,a,w,nnu,cc
  1022. .xcref
  1023. if ?uf
  1024. if ?nd
  1025. ??error <NODATA encountered in &n - user frame ignored>
  1026. ?uf=0
  1027. endif
  1028. endif
  1029. .xcref cBegin
  1030. cBegin &macro g
  1031. .xcref
  1032. if cc
  1033. uconcat <?PLMParm>,%?PLMPrevParm,%?po
  1034. endif
  1035. if ?uf
  1036. if ?rp
  1037. ??error <parmR encountered in &n - user frame ignored>
  1038. ?uf=0
  1039. endif
  1040. endif
  1041. ?pg1 <n>,c,a,%?po,w,%?uf,%?nd,%?rp,cc
  1042. ?cpd=0
  1043. ?argc=0
  1044. ?ba=1
  1045. ???=(???+1) and 0fffeh
  1046. if p
  1047. public n
  1048. endif
  1049. ife c
  1050. n proc near
  1051. else
  1052. if ?auto32
  1053. &n&_fix_cs:
  1054. db 057h ; push di
  1055. db 083h,0ECh,008h ; sub sp,8
  1056. db 08Ch,0CBh ; mov bx,cs
  1057. db 08Ch,0D0h ; mov ax,ss
  1058. db 08Eh,0C0h ; mov es,ax
  1059. db 08Bh,0FCh ; mov di,sp
  1060. db 0B8h,00Bh,000h ; mov ax,000Bh
  1061. db 0CDh,031h ; int 31h
  1062. db 026h,080h,04Dh,006h,040h ; or byte ptr es:[di+6],40h
  1063. db 0B8h,00Ch,000h ; mov ax,000Ch
  1064. db 0CDh,031h ; int 31h
  1065. add sp,8 ; db 083h,0C4h,008h
  1066. pop di ; db 05Fh
  1067. align 4
  1068. n proc far
  1069. xor eax,eax
  1070. mov ah,80h
  1071. add eax,eax
  1072. jc short &n&_fix_cs
  1073. else
  1074. n proc far
  1075. endif
  1076. endif
  1077. ife cc
  1078. nnu equ n
  1079. endif
  1080. ifidn <g>,<nogen>
  1081. if ???+?po+a+?rp
  1082. ??_out <cBegin - possible invalid use of nogen>
  1083. endif
  1084. else
  1085. if ?uf
  1086. ?mf c,%???,%?po
  1087. mpush a
  1088. else
  1089. if w+?exp+?lds
  1090. if ?pmd
  1091. ife ?nd
  1092. if ?lds
  1093. mov ax,_DATA
  1094. else
  1095. if ?exp
  1096. mov ax,ds
  1097. nop
  1098. endif
  1099. endif
  1100. endif
  1101. ife ?nx
  1102. if ???+?po
  1103. if ?chkstk1
  1104. push bp
  1105. movzx ebp,sp
  1106. else
  1107. if ???
  1108. push bp
  1109. movzx ebp, sp
  1110. sub sp, ???
  1111. ;;;;;enter ???,0
  1112. ;;;;;movzx bp,bp
  1113. else
  1114. push bp
  1115. movzx ebp,sp
  1116. endif
  1117. endif
  1118. endif
  1119. push ds
  1120. if ?lds+?exp
  1121. mov ds,ax
  1122. endif
  1123. else
  1124. if ?ff+???+?po+?rp
  1125. push bp
  1126. movzx ebp,sp
  1127. endif
  1128. endif
  1129. else
  1130. ife ?nd
  1131. mov ax,ds
  1132. nop
  1133. endif
  1134. ife ?nx
  1135. ife ?DOS5
  1136. inc bp
  1137. endif
  1138. push bp
  1139. movzx ebp,sp
  1140. push ds
  1141. else
  1142. if ?ff+???+?po+?rp
  1143. push bp
  1144. movzx ebp,sp
  1145. endif
  1146. endif
  1147. ife ?nd
  1148. mov ds,ax
  1149. endif
  1150. endif
  1151. else
  1152. if ?pmd
  1153. if ?exp
  1154. mov ax,ds
  1155. nop
  1156. else
  1157. if ?lds
  1158. mov ax,_DATA
  1159. endif
  1160. endif
  1161. if ?ff+???+?po+?rp
  1162. if ?chkstk1
  1163. push bp
  1164. movzx ebp,sp
  1165. else
  1166. if ???
  1167. push bp
  1168. movzx ebp, sp
  1169. sub sp, ???
  1170. ;;;;enter ???,0
  1171. ;;;;movzx ebp,bp
  1172. else
  1173. push bp
  1174. movzx ebp,sp
  1175. endif
  1176. endif
  1177. endif
  1178. if ?exp+?lds
  1179. push ds
  1180. mov ds,ax
  1181. endif
  1182. else
  1183. if ?ff+???+?po+?rp
  1184. push bp
  1185. movzx ebp,sp
  1186. endif
  1187. endif
  1188. endif
  1189. if ?rp
  1190. ?uf=0
  1191. rept ?rp
  1192. uconcat mpush,,?rp,%?uf
  1193. ?uf=?uf+1
  1194. endm
  1195. endif
  1196. if ???
  1197. if ?chkstk1
  1198. ifdef ?CHKSTKPROC
  1199. ?CHKSTKPROC %???
  1200. else
  1201. mov ax,???
  1202. ife cc
  1203. call _chkstk
  1204. else
  1205. call chkstk
  1206. endif
  1207. endif
  1208. else
  1209. ife ?pmd
  1210. sub sp,???
  1211. endif
  1212. endif
  1213. endif
  1214. mpush a
  1215. endif
  1216. ifdef ?PROFILE
  1217. if c
  1218. call StartNMeas
  1219. endif
  1220. endif
  1221. endif
  1222. .cref
  1223. purge cBegin
  1224. &endm
  1225. .xcref ?utpe
  1226. ?utpe &macro
  1227. ??error <unterminated procedure definition: "&n">
  1228. &endm
  1229. .cref
  1230. endm
  1231. ?pg1 macro n,c,a,o,w,f,d,r,cc
  1232. .xcref
  1233. .xcref cEnd
  1234. cEnd &macro g
  1235. .xcref
  1236. ?ba=0
  1237. ifidn <g>,<nogen>
  1238. if o+a+r
  1239. ??_out <cEnd - possible invalid use of nogen>
  1240. endif
  1241. else
  1242. ifdef ?PROFILE
  1243. if c
  1244. call StopNMeas
  1245. endif
  1246. endif
  1247. mpop a
  1248. if f
  1249. db 0c3h
  1250. else
  1251. if w+?exp+?lds
  1252. if ?pmd
  1253. ife ?nx
  1254. pop ds
  1255. endif
  1256. ife ?nx
  1257. if ?chkstk1+???+?po
  1258. ;;;;lea sp,-4[bp]
  1259. if ???
  1260. add sp, ???
  1261. endif
  1262. pop bp
  1263. ;;;;leave
  1264. endif
  1265. else
  1266. if ?ff+???+?po+?rp
  1267. ;;;;lea sp,-4[bp]
  1268. if ???
  1269. add sp, ???
  1270. endif
  1271. pop bp
  1272. ;;;;;;;;;;;;;;;;;;;leave
  1273. endif
  1274. endif
  1275. else
  1276. ife ?nx
  1277. if (?TF eq 0) or (???+?rp)
  1278. lea sp,-2[bp]
  1279. endif
  1280. pop ds
  1281. pop bp
  1282. ife ?DOS5
  1283. dec bp
  1284. endif
  1285. else
  1286. if (?TF eq 0) or (???+?rp)
  1287. mov sp,bp
  1288. endif
  1289. if ???+?po+?rp
  1290. pop bp
  1291. endif
  1292. endif
  1293. endif
  1294. else
  1295. if ?pmd
  1296. if ?ff+???+?po+?rp
  1297. ;;;;lea sp,-4[bp]
  1298. if ???
  1299. add sp, ???
  1300. endif
  1301. pop bp
  1302. ;;;;;;;;;;;;;;;;;;;;;;;;leave
  1303. endif
  1304. else
  1305. if ?ff+???+?po+?rp
  1306. if (?TF eq 0) or (???+?rp)
  1307. mov sp,bp
  1308. endif
  1309. pop bp
  1310. endif
  1311. endif
  1312. endif
  1313. ife cc
  1314. db 66h
  1315. retf
  1316. else
  1317. db 66h
  1318. retf o
  1319. endif
  1320. endif
  1321. endif
  1322. n endp
  1323. .cref
  1324. purge cEnd
  1325. &endm
  1326. .cref
  1327. endm
  1328. assumes macro s,ln
  1329. ifndef ln&_assumes
  1330. assume s:ln
  1331. else
  1332. ln&_assumes s
  1333. endif
  1334. endm
  1335. createSeg macro n,ln,a,co,cl,grp
  1336. ifnb <grp>
  1337. addseg grp,n
  1338. else
  1339. ln&OFFSET equ offset n:
  1340. ln&BASE equ n
  1341. ?cs3 <ln>,<n>
  1342. endif
  1343. ifnb <cl>
  1344. n segment a co '&cl'
  1345. else
  1346. n segment a co
  1347. endif
  1348. n ends
  1349. ?cs1 <ln>,<n>
  1350. endm
  1351. addseg macro grp,seg
  1352. .xcref
  1353. .xcref grp&_def
  1354. .cref
  1355. ifndef grp&_def
  1356. grp&_def=0
  1357. endif
  1358. if grp&_def ne ASMpass
  1359. .xcref
  1360. .xcref grp&_add
  1361. .cref
  1362. grp&_add &macro s
  1363. grp&_in <seg>,s
  1364. &endm
  1365. .xcref
  1366. .xcref grp&_in
  1367. .cref
  1368. grp&_in &macro sl,s
  1369. ifb <s>
  1370. grp group sl
  1371. else
  1372. grp&_add &macro ns
  1373. grp&_in <sl,s>,ns
  1374. &endm
  1375. endif
  1376. &endm
  1377. grp&_def=ASMpass
  1378. else
  1379. grp&_add seg
  1380. endif
  1381. endm
  1382. defgrp macro grp,ln
  1383. addseg grp
  1384. ifnb <ln>
  1385. irp x,<ln>
  1386. ?cs3 <&x>,<grp>
  1387. x&&OFFSET equ offset grp:
  1388. x&&BASE equ grp
  1389. endm
  1390. endif
  1391. endm
  1392. ?cs1 macro ln,n
  1393. .xcref
  1394. .xcref ln&_sbegin
  1395. .cref
  1396. ln&_sbegin &macro
  1397. .xcref
  1398. .xcref ?mf
  1399. .cref
  1400. ?mf &&macro c,l,p
  1401. if c
  1402. extrn n&_FARFRAME:near
  1403. call n&_FARFRAME
  1404. else
  1405. extrn n&_NEARFRAME:near
  1406. call n&_NEARFRAME
  1407. endif
  1408. db l shr 1
  1409. db p shr 1
  1410. &&endm
  1411. ?cs2 <ln>,<n>
  1412. n segment
  1413. &endm
  1414. endm
  1415. ?cs2 macro ln,n
  1416. .xcref
  1417. .xcref sEnd
  1418. .cref
  1419. sEnd &macro
  1420. n ends
  1421. purge ?mf
  1422. purge sEnd
  1423. &endm
  1424. endm
  1425. ?cs3 macro ln,n
  1426. .xcref
  1427. .xcref ln&_assumes
  1428. .cref
  1429. ln&_assumes &macro s
  1430. assume s:&n
  1431. &endm
  1432. endm
  1433. .xcref
  1434. .xcref sBegin
  1435. .cref
  1436. sBegin macro ln
  1437. ln&_sbegin
  1438. endm
  1439. ife ?DF
  1440. ;.286p
  1441. ;createSeg _TEXT,Code,word,public,CODE
  1442. ;.386p
  1443. ;;;;;;;;;createSeg _TEXT32,Code32,word,use32,CODE
  1444. ife ?nodata1
  1445. .286p
  1446. createSeg _DATA,Data,word,public,DATA,DGROUP
  1447. .386p
  1448. defgrp DGROUP,Data
  1449. endif
  1450. if ?chkstk1
  1451. ifndef ?CHKSTKPROC
  1452. externp <chkstk>
  1453. endif
  1454. endif
  1455. endif
  1456. errnz macro x
  1457. if2
  1458. if x
  1459. errnz1 <x>,%(x)
  1460. endif
  1461. endif
  1462. endm
  1463. errnz1 macro x1,x2
  1464. = *errnz* x1 = x2
  1465. .err
  1466. endm
  1467. errn$ macro l,x
  1468. errnz <offset $ - offset l x>
  1469. endm
  1470. ifdef ?PROFILE
  1471. externFP <StartNMeas,StopNMeas>
  1472. endif