Source code of Windows XP (NT5)
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.

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