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.

1410 lines
19 KiB

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