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.

1236 lines
16 KiB

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