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.

1054 lines
14 KiB

  1. comment $
  2. cmacros - assembly macros for interfacing to HHLs
  3. (C)Copyright Microsoft Corp. 1984, 1985, 1986
  4. $
  5. if1
  6. ASMpass=1
  7. outif MACRO name,defval,onmsg,offmsg
  8. ifndef name
  9. ifb <defval>
  10. name=0
  11. else
  12. name=defval
  13. endif
  14. endif
  15. if name
  16. name=1
  17. ifnb <onmsg>
  18. %out ! onmsg
  19. endif
  20. else
  21. ifnb <offmsg>
  22. %out ! offmsg
  23. endif
  24. endif
  25. endm
  26. ??error macro msg
  27. E r r o r ----- msg
  28. endm
  29. %out cMacros Version 2.03 - 3/06/86
  30. %out Copyright (C) Microsoft Corp. 1984, 1985, 1986. All rights reserved.
  31. outif memS,0,<Small Model>
  32. outif memM,0,<Medium Model>
  33. outif memL,0,<Large Model>
  34. outif memC,0,<Compact Model>
  35. outif memH,0,<Huge Model>
  36. memMOD= memS + memM + memL + memC + memH
  37. if memMOD ne 1
  38. if memMOD eq 0
  39. memS= 1
  40. outif memS,0,<Small Model>
  41. else
  42. ??error <Must have only 1 memory model selected>
  43. endif
  44. endif
  45. sizeC= memM + memL + memH
  46. sizeD= memL + memC + (memH*2)
  47. outif ?DF,0,<No segments or groups will be defined>
  48. outif ?TF,0,<Windows far epilogs assume valid SP>
  49. outif ?WIN,1,<Windows Support>
  50. outif ?PLM,1,<PLM calling convention>
  51. ifndef ?NODATA
  52. ?NODATA1=0
  53. else
  54. ?NODATA1=1
  55. %out ! NODATA module
  56. endif
  57. ifndef ?CHKSTK
  58. ?CHKSTK1=0
  59. else
  60. ?CHKSTK1=1
  61. %out ! Stack checking enabled
  62. endif
  63. ifndef ?CPDOS
  64. ?CPDOS1=0
  65. else
  66. ?CPDOS1=1
  67. %out ! CPDOS module
  68. endif
  69. else
  70. ASMpass=2
  71. endif
  72. .XCREF
  73. .XCREF ?N,?AX,?AH,?AL,?BX,?BH
  74. .XCREF ?BL,?CX,?CH,?CL,?DX,?DH
  75. .XCREF ?DL,?SI,?DI,?ES,?DS,?BP
  76. .XCREF ?SP,?SS,?CS
  77. .XCREF ?RSL,?CPD,?argl,?argc,?BA
  78. .XCREF ?ACB,???,?PO
  79. .XCREF ?PAS,?PC
  80. .XCREF Uconcat,mPush,mPop
  81. .XCREF ?RI,?pp,?pp1,?al1
  82. .XCREF ?aD,?AP,?Atal,?dd,?dd1
  83. .XCREF ?pg,?pg1,?aloc,?cs1,?cs2
  84. .XCREF ?DF,?TF,?PLM,?WIN,?IA,?PU,?ADJ
  85. .XCREF ?UF,?RP,?NX,?ND,?NODATA1,?CHKSTK1,?CPDOS1
  86. ?RSL = 0
  87. ?CPD = 0
  88. ?ArgL = 0
  89. ?ArgC = 0
  90. ?BA = 0
  91. ?ACB = 0
  92. ??? = 0
  93. ?PO = 0
  94. ?PAS = 0
  95. ?PC = 0
  96. ?IA = 0
  97. ?PU = 0
  98. ?ADJ = 0
  99. ?RP = 0
  100. ?UF = 0
  101. ?ND = 0
  102. ?NX = 0
  103. ?N = 0000000000000000B
  104. ?AX = 0000000000000011B
  105. ?AH = 0000000000000001B
  106. ?AL = 0000000000000010B
  107. ?BX = 0000000000001100B
  108. ?BH = 0000000000000100B
  109. ?BL = 0000000000001000B
  110. ?CX = 0000000000110000B
  111. ?CH = 0000000000010000B
  112. ?CL = 0000000000100000B
  113. ?DX = 0000000011000000B
  114. ?DH = 0000000001000000B
  115. ?DL = 0000000010000000B
  116. ?SI = 0000000100000000B
  117. ?DI = 0000001000000000B
  118. ?ES = 0000010000000000B
  119. ?DS = 0000100000000000B
  120. ?BP = 0001000000000000B
  121. ?SP = 0010000000000000B
  122. ?SS = 0100000000000000B
  123. ?CS = 1000000000000000B
  124. .CREF
  125. uconcat macro a,b,c,d,e,f
  126. a&b c&d e&f
  127. endm
  128. mpush macro r
  129. irp x,<ax,bx,cx,dx,si,di,es,ds,bp,sp,ss,cs>
  130. if r AND ?&&x
  131. push x
  132. endif
  133. endm
  134. endm
  135. mpop macro r
  136. irp x,<cs,ss,sp,bp,ds,es,di,si,dx,cx,bx,ax>
  137. if r AND ?&&x
  138. pop x
  139. endif
  140. endm
  141. endm
  142. save macro r
  143. ?RSL=0
  144. ?RI ?RSL,<r>
  145. endm
  146. ?RI macro n,r
  147. irp x,<r>
  148. ifdef ?&&x
  149. n=n OR ?&&x
  150. endif
  151. endm
  152. endm
  153. parmB macro n
  154. ?pp <n>,<byte>,2,1
  155. endm
  156. parmW macro n
  157. ?pp <n>,<word>,2,2
  158. endm
  159. parmD macro n
  160. ife ?PLM
  161. irp x,<n>
  162. ?pp <&&x>,<DWORD>,0,4
  163. ?pp <Off_&&x>,<WORD>,2,2
  164. ?pp <Seg_&&x>,<WORD>,2,2
  165. endm
  166. else
  167. irp x,<n>
  168. ?pp <Seg_&&x>,<WORD>,2,2
  169. ?pp <Off_&&x>,<WORD>,2,2
  170. ?pp <&&x>,<DWORD>,0,4
  171. endm
  172. endif
  173. endm
  174. parmQ macro n
  175. ?pp <n>,<QWORD>,8,8
  176. endm
  177. parmT macro n
  178. ?pp <n>,<TBYTE>,10,10
  179. endm
  180. if sizeC
  181. parmCP macro n
  182. parmD <n>
  183. endm
  184. else
  185. parmCP macro n
  186. parmW <n>
  187. endm
  188. endif
  189. if sizeD
  190. parmDP macro n
  191. parmD <n>
  192. endm
  193. else
  194. parmDP macro n
  195. parmW <n>
  196. endm
  197. endif
  198. ?pp macro n,t,l,s
  199. if ?CPD
  200. .xcref
  201. irp x,<n>
  202. .xcref ?T&&x
  203. ?T&&x=s
  204. ife ?PLM
  205. ?pp1 x,<t>,,,%(?PO+?adj)
  206. ?PO=?PO+l
  207. else
  208. ?PO=?PO+l
  209. ?pp1 x,<t>,%?PO,%?adj
  210. endif
  211. endm
  212. .cref
  213. else
  214. ??error <Parm(s) "&n" declared outside proc def>
  215. endif
  216. endm
  217. ?pp1 macro n,t,o,a,b
  218. ife ?PLM
  219. n equ t ptr [bp+b]
  220. else
  221. n equ t ptr [bp+a+?PO-o]
  222. endif
  223. endm
  224. ifndef ?NOPARMR
  225. .XCREF
  226. .XCREF ?pr
  227. .CREF
  228. parmR macro n,r,r2
  229. ?pr n,r,r2,%?RP,%(?IA+2)
  230. endm
  231. ?pr macro n,r,r2,i,o
  232. .xcref
  233. ifnb <r2>
  234. parmR SEG_&n,r
  235. parmR OFF_&n,r2
  236. n equ dword ptr [bp-o-2]
  237. .xcref ?T&n
  238. ?T&n=4
  239. else
  240. .xcref ?RP&i
  241. ?RP&i=0
  242. ifdef ?&r
  243. ?RP&i=?&r
  244. endif
  245. if ??? OR (?CPD EQ 0) OR (?RP&i EQ 0)
  246. ??error <invalid parmR encountered: &n,&r>
  247. exitm
  248. endif
  249. n equ word ptr [bp-o]
  250. ?T&n=2
  251. irp x,<bh,ch,dh,bl,cl,dl,ah,al>
  252. if ?&&x EQ ?&r
  253. n equ byte ptr [bp-o]
  254. ?T&n=1
  255. exitm
  256. endif
  257. endm
  258. ?IA=?IA+2
  259. ?RP=?RP+1
  260. endif
  261. .cref
  262. endm
  263. endif
  264. localB macro n
  265. ?aLoc <n>,<BYTE ptr>,1,1,0
  266. endm
  267. localW macro n
  268. ?aLoc <n>,<WORD PTR>,2,2,1
  269. endm
  270. localD macro n
  271. irp x,<n>
  272. ?aLoc <Seg_&&x>,<WORD PTR>,2,2,1
  273. ?aLoc <Off_&&x>,<WORD PTR>,2,2,1
  274. ?aLoc <&&x>,<DWORD PTR>,0,4,1
  275. endm
  276. endm
  277. localQ macro n
  278. ?aLoc <n>,<QWORD PTR>,8,8,1
  279. endm
  280. localT macro n
  281. ?aLoc <n>,<TBYTE PTR>,10,10,1
  282. endm
  283. if sizeC
  284. localCP macro n
  285. localD <n>
  286. endm
  287. else
  288. localCP macro n
  289. localW <n>
  290. endm
  291. endif
  292. if sizeD
  293. localDP macro n
  294. localD <n>
  295. endm
  296. else
  297. localDP macro n
  298. localW <n>
  299. endm
  300. endif
  301. localV macro n,a
  302. ?aLoc <n>,,%(a),0,1
  303. endm
  304. ?aLoc macro n,t,l,s,a
  305. if ?CPD
  306. .xcref
  307. irp x,<n>
  308. ???=???+l
  309. if a
  310. ???=((??? + 1) AND 0FFFEH)
  311. endif
  312. ?aL1 x,<t>,%(???+?IA)
  313. .xcref ?T&&x
  314. ?T&&x=s
  315. endm
  316. .cref
  317. else
  318. ??error <Locals "&n" declared outside procedure def>
  319. endif
  320. endm
  321. ?aL1 macro n,t,o
  322. n equ t [bp-o]
  323. endm
  324. ifndef ?NOGLOBAL
  325. globalB macro n,i,s
  326. ?aD <n>,1
  327. ?dd n,1,<BYTE>,<DB>,<i>,<s>
  328. endm
  329. globalW macro n,i,s
  330. ?aD <n>,2
  331. ?dd n,1,<WORD>,<DW>,<i>,<s>
  332. endm
  333. globalD macro n,i,s
  334. ?aD <n>,4
  335. ?dd n,1,<DWORD>,<DD>,<i>,<s>
  336. endm
  337. globalQ macro n,i,s
  338. ?aD <n>,8
  339. ?dd n,1,<QWORD>,<DQ>,<i>,<s>
  340. endm
  341. globalT macro n,i,s
  342. ?aD <n>,10
  343. ?dd n,1,<TBYTE>,<DT>,<i>,<s>
  344. endm
  345. if sizeC
  346. globalCP macro n,i,s
  347. globalD n,<i>,<s>
  348. endm
  349. else
  350. globalCP macro n,i,s
  351. globalW n,<i>,<s>
  352. endm
  353. endif
  354. if sizeD
  355. globalDP macro n,i,s
  356. globalD n,<i>,<s>
  357. endm
  358. else
  359. globalDP macro n,i,s
  360. globalW n,<i>,<s>
  361. endm
  362. endif
  363. endif
  364. ifndef ?NOSTATIC
  365. staticB macro n,i,s
  366. ?aD <n>,1
  367. ?dd n,0,<BYTE>,<DB>,<i>,<s>
  368. endm
  369. staticW macro n,i,s
  370. ?aD <n>,2
  371. ?dd n,0,<WORD>,<DW>,<i>,<s>
  372. endm
  373. staticD macro n,i,s
  374. ?aD <n>,4
  375. ?dd n,0,<DWORD>,<DD>,<i>,<s>
  376. endm
  377. staticQ macro n,i,s
  378. ?aD <n>,8
  379. ?dd n,0,<QWORD>,<DQ>,<i>,<s>
  380. endm
  381. staticT macro n,i,s
  382. ?aD <n>,10
  383. ?dd n,0,<TBYTE>,<DT>,<i>,<s>
  384. endm
  385. if sizeC
  386. staticCP macro n,i,s
  387. staticD n,<i>,<s>
  388. endm
  389. else
  390. staticCP macro n,i,s
  391. staticW n,<i>,<s>
  392. endm
  393. endif
  394. if sizeD
  395. staticDP macro n,i,s
  396. staticD n,<i>,<s>
  397. endm
  398. else
  399. staticDP macro n,i,s
  400. staticW n,<i>,<s>
  401. endm
  402. endif
  403. endif
  404. ?dd macro n,p,t,d,i,s
  405. ife ?PLM
  406. n label t
  407. ?dd1 _&n,p,<d>,<i>,<s>
  408. else
  409. ?dd1 n,p,<d>,<i>,<s>
  410. endif
  411. endm
  412. ?dd1 macro n,p,d,i,s
  413. if p
  414. PUBLIC n
  415. endif
  416. ifb <s>
  417. n d i
  418. else
  419. ifb <i>
  420. n d s DUP (?)
  421. else
  422. n d s DUP (i)
  423. endif
  424. endif
  425. endm
  426. ifndef ?NOEXTERN
  427. .XCREF
  428. .XCREF ?ex1
  429. .CREF
  430. externB macro n
  431. ?ex1 <n>,1,<BYTE>
  432. endm
  433. externW macro n
  434. ?ex1 <n>,2,<WORD>
  435. endm
  436. externD macro n
  437. ?ex1 <n>,4,<DWORD>
  438. endm
  439. externQ macro n
  440. ?ex1 <n>,8,<QWORD>
  441. endm
  442. externT macro n
  443. ?ex1 <n>,10,<TBYTE>
  444. endm
  445. externNP macro n
  446. ?ex1 <n>,2,<NEAR>
  447. endm
  448. externFP macro n
  449. ?ex1 <n>,4,<FAR>
  450. endm
  451. if sizeC
  452. externP macro n
  453. ?ex1 <n>,4,<FAR>
  454. endm
  455. else
  456. externP macro n
  457. ?ex1 <n>,2,<NEAR>
  458. endm
  459. endif
  460. if sizeC
  461. externCP macro n
  462. ?ex1 <n>,4,<DWORD>
  463. endm
  464. else
  465. externCP macro n
  466. ?ex1 <n>,2,<WORD>
  467. endm
  468. endif
  469. if sizeD
  470. externDP macro n
  471. ?ex1 <n>,4,<DWORD>
  472. endm
  473. else
  474. externDP macro n
  475. ?ex1 <n>,2,<WORD>
  476. endm
  477. endif
  478. ?ex1 macro n,s,d
  479. irp x,<n>
  480. .xcref
  481. .xcref ?T&&x
  482. .cref
  483. ?T&&x=s
  484. ife ?PLM
  485. extrn _&&x:&d
  486. x equ _&&x
  487. else
  488. extrn x:&d
  489. endif
  490. endm
  491. endm
  492. endif
  493. ifndef ?NOLABEL
  494. .XCREF
  495. ?lblpu = 0
  496. .XCREF ?lb1,?lblpu
  497. .CREF
  498. labelB macro n
  499. ?lb1 <n>,1,<BYTE>
  500. endm
  501. labelW macro n
  502. ?lb1 <n>,2,<WORD>
  503. endm
  504. labelD macro n
  505. ?lb1 <n>,4,<DWORD>
  506. endm
  507. labelQ macro n
  508. ?lb1 <n>,8,<QWORD>
  509. endm
  510. labelT macro n
  511. ?lb1 <n>,10,<TBYTE>
  512. endm
  513. labelNP macro n
  514. ?lb1 <n>,2,<NEAR>
  515. endm
  516. labelFP macro n
  517. ?lb1 <n>,4,<FAR>
  518. endm
  519. if sizeC
  520. labelP macro n
  521. ?lb1 <n>,4,<FAR>
  522. endm
  523. else
  524. labelP macro n
  525. ?lb1 <n>,2,<NEAR>
  526. endm
  527. endif
  528. if sizeC
  529. labelCP macro n
  530. ?lb1 <n>,4,<DWORD>
  531. endm
  532. else
  533. labelCP macro n
  534. ?lb1 <n>,2,<WORD>
  535. endm
  536. endif
  537. if sizeD
  538. labelDP macro n
  539. ?lb1 <n>,4,<DWORD>
  540. endm
  541. else
  542. labelDP macro n
  543. ?lb1 <n>,2,<WORD>
  544. endm
  545. endif
  546. ?lb1 macro n,s,d
  547. ?lblpu=0
  548. irp x,<n>
  549. ifidn <x>,<PUBLIC>
  550. ?lblpu=1
  551. else
  552. .xcref
  553. .xcref ?T&&x
  554. .cref
  555. ?T&&x=s
  556. ife ?PLM
  557. if ?lblpu
  558. public _&&x
  559. endif
  560. _&&x label &d
  561. x equ _&&x
  562. else
  563. if ?lblpu
  564. public x
  565. endif
  566. x label &d
  567. endif
  568. endif
  569. endm
  570. endm
  571. endif
  572. ifndef ?NODEF
  573. defB macro n
  574. ?aD <n>,1
  575. endm
  576. defW macro n
  577. ?aD <n>,2
  578. endm
  579. defD macro n
  580. ?aD <n>,4
  581. endm
  582. defQ macro n
  583. ?aD <n>,8
  584. endm
  585. defT macro n
  586. ?aD <n>,10
  587. endm
  588. if sizeC
  589. defCP macro n
  590. defD <n>
  591. endm
  592. else
  593. defCP macro n
  594. defW <n>
  595. endm
  596. endif
  597. if sizeD
  598. defDP macro n
  599. defD <n>
  600. endm
  601. else
  602. defDP macro n
  603. defW <n>
  604. endm
  605. endif
  606. endif
  607. ?aD macro n,s
  608. irp x,<n>
  609. .xcref
  610. .xcref ?T&&x
  611. .cref
  612. ?T&&x=s
  613. endm
  614. endm
  615. ifndef ?NOPTR
  616. regPtr macro n,S,O
  617. farPtr n,S,O
  618. endm
  619. farptr macro n,S,O
  620. .xcref
  621. .xcref ?T&n
  622. .cref
  623. n &macro
  624. push S
  625. push O
  626. &endm
  627. ?T&n=80h
  628. endm
  629. endif
  630. arg macro a
  631. irp x,<a>
  632. ?argc=?argc+1
  633. ?Atal <x>,%?argc
  634. endm
  635. endm
  636. ?Atal macro n,i
  637. .xcref
  638. .xcref ?ALI&i
  639. .cref
  640. ?ALI&i &macro
  641. ?AP n
  642. &endm
  643. endm
  644. ?AP macro n
  645. ?argl=?argl+2
  646. ifdef ?T&n
  647. ife ?T&n-1
  648. push word ptr (n)
  649. exitm
  650. endif
  651. ife ?T&n-2
  652. push n
  653. exitm
  654. endif
  655. ife ?T&n-4
  656. push word ptr (n)+2
  657. push word ptr (n)
  658. ?argl=?argl+2
  659. exitm
  660. endif
  661. ife ?T&n-8
  662. push word ptr (n)+6
  663. push word ptr (n)+4
  664. push word ptr (n)+2
  665. push word ptr (n)
  666. ?argl=?argl+6
  667. exitm
  668. endif
  669. if ?T&n AND 80h
  670. n
  671. ?argl=?argl+2
  672. exitm
  673. endif
  674. ife ?T&n
  675. push word ptr (n)
  676. exitm
  677. endif
  678. endif
  679. push n
  680. endm
  681. ife ?PLM
  682. ccall macro n,a,sleaze
  683. ifnb <a>
  684. Arg <a>
  685. endif
  686. mpush %?RSL
  687. ?argl=0
  688. ?ACB=?argc
  689. rept ?argc
  690. uconcat <?ALI>,%?ACB
  691. uconcat <purge>,,<?ALI>,%?ACB
  692. ?ACB=?ACB-1
  693. endm
  694. ifb <sleaze>
  695. call _&n
  696. else
  697. call n
  698. endif
  699. if ?argl
  700. add sp,?argl
  701. endif
  702. mpop %?RSL
  703. ?RSL=0
  704. ?argc= 0
  705. ?argl= 0
  706. endm
  707. else
  708. ccall macro n,a
  709. ifnb <a>
  710. Arg <a>
  711. endif
  712. mpush %?RSL
  713. ?argl=0
  714. ?ACB=1
  715. rept ?argc
  716. uconcat <?ALI>,%?ACB
  717. uconcat <purge>,,<?ALI>,%?ACB
  718. ?ACB=?ACB+1
  719. endm
  720. call n
  721. mpop %?RSL
  722. ?RSL=0
  723. ?argc=0
  724. ?argl=0
  725. endm
  726. endif
  727. cProc macro n,c,a,f
  728. if ?CPD
  729. ?UTPE
  730. endif
  731. ?CPD=1
  732. ???=0
  733. ?argc=0
  734. ?BA=0
  735. ?PO=0
  736. ?PU=0
  737. ?IA=0
  738. ?adj=4
  739. ?PC=0
  740. ?RP=0
  741. ?UF=0
  742. ?PAS=0
  743. ifnb <a>
  744. ?RI ?PAS,<a>
  745. endif
  746. ?PC=sizeC
  747. ?ND=?NODATA1
  748. ?NX=0
  749. irp x,<c>
  750. ifidn <x>,<FAR>
  751. ?PC=1
  752. endif
  753. ifidn <x>,<NEAR>
  754. ?PC=0
  755. endif
  756. ifidn <x>,<PUBLIC>
  757. ?PU=1
  758. endif
  759. ifidn <x>,<SMALL>
  760. ?UF=1
  761. endif
  762. ifidn <x>,<DATA>
  763. ?ND=0
  764. endif
  765. ifidn <x>,<NODATA>
  766. ?ND=1
  767. endif
  768. ifidn <x>,<ATOMIC>
  769. ?NX=1
  770. endif
  771. endm
  772. if ?PC
  773. if ?WIN
  774. ife ?NX
  775. ?IA=2
  776. ?PAS = ?PAS AND (NOT ?ds)
  777. endif
  778. endif
  779. ?adj=?adj+2
  780. endif
  781. ?PAS = ?PAS AND (NOT (?sp+?cs+?ss))
  782. if ?UF
  783. ?PAS = ?PAS AND (NOT (?bp+?si+?di))
  784. endif
  785. ife ?PLM
  786. ife ?PC
  787. n label near
  788. else
  789. n label far
  790. endif
  791. ?pg <_&n>,%?PU,%?PC,%?PAS,%?IA
  792. else
  793. ?pg <n>,%?PU,%?PC,%?PAS,%?IA
  794. endif
  795. endm
  796. ?pg macro n,p,c,a,w
  797. .xcref
  798. if ?UF
  799. if ?RP
  800. ??error <parmR encountered in &n - user frame ignored>
  801. ?UF=0
  802. endif
  803. if ?ND
  804. ??error <NODATA encountered in &n - user frame ignored>
  805. ?UF=0
  806. endif
  807. endif
  808. cBegin &macro g
  809. .xcref
  810. ?pg1 <n>,c,a,%?PO,w,%?UF,%?ND,%?RP
  811. ?CPD=0
  812. ?argc=0
  813. ?BA=1
  814. ???=(???+1) AND 0FFFEH
  815. if p
  816. PUBLIC n
  817. endif
  818. ife c
  819. n proc NEAR
  820. else
  821. n proc FAR
  822. endif
  823. ifidn <g>,<nogen>
  824. if ???+?PO+a+?RP
  825. %out <cBegin - possible invalid use of nogen>
  826. endif
  827. else
  828. if ?UF
  829. ?MF c,%???,%?PO
  830. mPush a
  831. else
  832. if w
  833. ife ?ND
  834. mov ax,ds
  835. nop
  836. endif
  837. ife ?NX
  838. ife ?CPDOS1
  839. inc bp
  840. endif
  841. push bp
  842. mov bp,sp
  843. push ds
  844. else
  845. if ???+?PO+?RP
  846. push bp
  847. mov bp,sp
  848. endif
  849. endif
  850. ife ?ND
  851. mov ds,ax
  852. endif
  853. else
  854. if ???+?PO+?RP
  855. push bp
  856. mov bp,sp
  857. endif
  858. endif
  859. if ?RP
  860. ?UF=0
  861. rept ?RP
  862. uconcat mpush,,?RP,%?UF
  863. ?UF=?UF+1
  864. endm
  865. endif
  866. if ???
  867. if ?CHKSTK1
  868. mov ax,???
  869. ife ?PLM
  870. call _chkstk
  871. else
  872. call chkstk
  873. endif
  874. else
  875. sub sp,???
  876. endif
  877. endif
  878. mPush a
  879. endif
  880. endif
  881. .cref
  882. purge cBegin
  883. &endm
  884. ?UTPE &macro
  885. ??error <Unterminated Procedure Definition: "&n">
  886. &endm
  887. endm
  888. ?pg1 macro n,c,a,o,w,f,d,r
  889. .xcref
  890. cEnd &macro g
  891. .xcref
  892. ?BA=0
  893. ifidn <g>,<nogen>
  894. if o+a+r
  895. %out <cEnd - possible invalid use of nogen>
  896. endif
  897. else
  898. if f
  899. mPop a
  900. db 0C3h
  901. else
  902. mPop a
  903. if w
  904. ife ?NX
  905. ife ?TF
  906. lea sp,-2[bp]
  907. else
  908. if ???+?RP
  909. lea sp,-2[bp]
  910. endif
  911. endif
  912. pop ds
  913. pop bp
  914. ife ?CPDOS1
  915. dec bp
  916. endif
  917. else
  918. ife ?TF
  919. mov sp,bp
  920. else
  921. if ???+?RP
  922. sp,bp
  923. endif
  924. endif
  925. if ???+?PO+?RP
  926. pop bp
  927. endif
  928. endif
  929. else
  930. if ???+?PO+?RP
  931. mov sp,bp
  932. pop bp
  933. endif
  934. endif
  935. ife ?PLM
  936. ret
  937. else
  938. ret o
  939. endif
  940. endif
  941. endif
  942. n endp
  943. .cref
  944. purge cEnd
  945. &endm
  946. .cref
  947. endm
  948. assumes macro s,ln
  949. ifndef ln&_assumes
  950. assume s:ln
  951. else
  952. ln&_assumes s
  953. endif
  954. endm
  955. createSeg macro n,ln,a,co,cl,grp
  956. ifnb <grp>
  957. addSeg grp,n
  958. else
  959. ln&OFFSET equ OFFSET n:
  960. ln&BASE equ n
  961. ?cs3 <ln>,<n>
  962. endif
  963. ifnb <cl>
  964. n segment a co '&cl'
  965. else
  966. n segment a co
  967. endif
  968. n ends
  969. ?cs1 <ln>,<n>
  970. endm
  971. addSeg macro grp,seg
  972. ifndef grp&_def
  973. grp&_def=0
  974. endif
  975. if grp&_def ne ASMpass
  976. grp&_add &macro s
  977. grp&_in <seg>,s
  978. &endm
  979. grp&_in &macro sl,s
  980. ifb <s>
  981. grp group sl
  982. else
  983. grp&_add &macro ns
  984. grp&_in <sl,s>,ns
  985. &endm
  986. endif
  987. &endm
  988. grp&_def=ASMpass
  989. else
  990. grp&_add seg
  991. endif
  992. endm
  993. defGrp macro grp,ln
  994. addSeg grp
  995. ifnb <ln>
  996. ?cs3 <ln>,<grp>
  997. ln&OFFSET equ OFFSET grp:
  998. ln&BASE equ grp
  999. endif
  1000. endm
  1001. ?cs1 macro ln,n
  1002. ln&_sBegin &macro
  1003. ?MF &&macro c,l,p
  1004. if c
  1005. extrn n&_FARFRAME:near
  1006. call n&_FARFRAME
  1007. else
  1008. extrn n&_NEARFRAME:near
  1009. call n&_NEARFRAME
  1010. endif
  1011. db l shr 1
  1012. db p shr 1
  1013. &&endm
  1014. ?cs2 <ln>,<n>
  1015. n segment
  1016. &endm
  1017. endm
  1018. ?cs2 macro ln,n
  1019. sEnd &macro
  1020. n ends
  1021. purge ?MF
  1022. &endm
  1023. endm
  1024. ?cs3 macro ln,n
  1025. ln&_assumes &macro s
  1026. assume s:&n
  1027. &endm
  1028. endm
  1029. sBegin macro ln
  1030. ln&_sBegin
  1031. endm
  1032. ife ?DF
  1033. createSeg _TEXT,code,byte,public,CODE
  1034. ife ?NODATA1
  1035. createSeg _DATA,data,word,public,DATA,DGROUP
  1036. defGrp DGROUP,DATA
  1037. endif
  1038. if ?CHKSTK1
  1039. externP <chkstk>
  1040. endif
  1041. endif
  1042. errnz macro x
  1043. if2
  1044. if x
  1045. errnz1 <x>,%(x)
  1046. endif
  1047. endif
  1048. endm
  1049. errnz1 macro x1,x2
  1050. = *ERRNZ* x1 = x2
  1051. endm
  1052. errn$ macro l,x
  1053. errnz <OFFSET $ - OFFSET l x>
  1054. ENDM