home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk11 / tk5 / include / cmacros.inc next >
Encoding:
Text File  |  1989-02-20  |  20.8 KB  |  1,484 lines

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