home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / commercial-software / programming / Z80TOOLS.ZIP / DISK1.ZIP / ENVIRON.LIB < prev    next >
Text File  |  1998-07-30  |  23KB  |  1,394 lines

  1. CpmLevel equ 22h
  2. true equ 0ffffh
  3. false equ 00000h
  4. WarmStart equ 0000h
  5. BdosJump equ 0005h
  6. BdosAddress equ 0006h
  7. CpmPass1 equ 0051h
  8. CpmPass1Len equ 0053h
  9. CpmPass2 equ 0054h
  10. CpmPass2Len equ 0056h
  11. CpmFcb equ 005Ch
  12. CpmFcb2 equ CpmFcb+10h
  13. CpmBuffer equ 0080h
  14. CpmTailLen equ CpmBuffer
  15. CpmTail equ CpmBuffer+1
  16. TransientArea equ 0100h
  17. AsciiBEL equ 07h
  18. AsciiBS equ 08h
  19. AsciiTAB equ 09h
  20. AsciiLF equ 0Ah
  21. AsciiFF equ 0Ch
  22. AsciiCR equ 0Dh
  23. AsciiSO equ 0Eh
  24. AsciiSI equ 0Fh
  25. AsciiDC1 equ 11h
  26. AsciiDC2 equ 12h
  27. AsciiDC3 equ 13h
  28. AsciiDC4 equ 14h
  29. CpmEof equ 1Ah
  30. AsciiESC equ 1Bh
  31. AsciiBlank equ 20h
  32. AsciiDEL equ 7Fh
  33. FcrLen equ 40h
  34. FilePMread equ 80h
  35. FilePMwrite equ 40h
  36. FilePMdelete equ 20h
  37. FileAttF1 equ 40h
  38. FileAttF2 equ 20h
  39. FileAttF3 equ 10h
  40. FileAttF4 equ 08h
  41. FileAttRO equ 04h
  42. FileAttSY equ 02h
  43. FileAttAR equ 01h
  44. ckdisp macro ?disp
  45.  if (?disp gt 7fh) and (?disp lt 0ff80h)
  46.  ++ displacement &disp too large
  47.  endif
  48.  endm
  49. lxix macro addr
  50.  db 0ddh,21h
  51.  dw addr
  52.  endm
  53. lded macro addr
  54.  db 0edh,5bh
  55.  dw addr
  56.  endm
  57. lbcd macro addr
  58.  db 0edh,4bh
  59.  dw addr
  60.  endm
  61. lspd macro addr
  62.  db 0edh,07bh
  63.  dw addr
  64.  endm
  65. lixd macro addr
  66.  db 0ddh,2ah
  67.  dw addr
  68.  endm
  69. sbcd macro addr
  70.  db 0edh,43h
  71.  dw addr
  72.  endm
  73. sded macro addr
  74.  db 0edh,53h
  75.  dw addr
  76.  endm
  77. sspd macro addr
  78.  db 0edh,73h
  79.  dw addr
  80.  endm
  81. sixd macro addr
  82.  db 0ddh,22h
  83.  dw addr
  84.  endm
  85. pushix macro
  86.  db 0ddh,0e5h
  87.  endm
  88. popix macro
  89.  db 0ddh,0e1h
  90.  endm
  91. xtix macro
  92.  db 0ddh,0e3h
  93.  endm
  94. ldi macro
  95.  db 0edh,0a0h
  96.  endm
  97. ldir macro
  98.  db 0edh,0b0h
  99.  endm
  100. ldd macro
  101.  db 0edh,0a8h
  102.  endm
  103. lddr macro
  104.  db 0edh,0b8h
  105.  endm
  106. cmpi macro
  107.  db 0edh,0a1h
  108.  endm
  109. cpir macro
  110.  db 0edh,0b1h
  111.  endm
  112. ldx macro reg,disp
  113.  ckdisp disp
  114.  db 0ddh,reg*8+46h,disp
  115.  endm
  116. stx macro reg,disp
  117.  ckdisp disp
  118.  db 0ddh,70h+reg,disp
  119.  endm
  120. mvix macro byte,disp
  121.  ckdisp disp
  122.  db 0ddh,36h,disp,byte
  123.  endm
  124. addx macro disp
  125.  ckdisp disp
  126.  db 0ddh,86h,disp
  127.  endm
  128. adcx macro disp
  129.  ckdisp disp
  130.  db 0ddh,8eh,disp
  131.  endm
  132. subx macro disp
  133.  ckdisp disp
  134.  db 0ddh,96h,disp
  135.  endm
  136. sbcx macro disp
  137.  ckdisp disp
  138.  db 0ddh,9eh,disp
  139.  endm
  140. andx macro disp
  141.  ckdisp disp
  142.  db 0ddh,0a6h,disp
  143.  endm
  144. xorx macro disp
  145.  ckdisp disp
  146.  db 0ddh,0aeh,disp
  147.  endm
  148. orx macro disp
  149.  ckdisp disp
  150.  db 0ddh,0b6h,disp
  151.  endm
  152. cmpx macro disp
  153.  ckdisp disp
  154.  db 0ddh,0beh,disp
  155.  endm
  156. inrx macro disp
  157.  ckdisp disp
  158.  db 0ddh,34h,disp
  159.  endm
  160. dcrx macro disp
  161.  ckdisp disp
  162.  db 0ddh,035h,disp
  163.  endm
  164. neg macro
  165.  db 0edh,44h
  166.  endm
  167. dadc macro dreg
  168.  db 0edh,dreg*8+4ah
  169.  endm
  170. dsbc macro dreg
  171.  db 0edh,dreg*8+42h
  172.  endm
  173. dadx macro dreg
  174.  db 0ddh,dreg*8+09h
  175.  endm
  176. inxix macro
  177.  db 0ddh,23h
  178.  endm
  179. dcxix macro
  180.  db 0ddh,2bh
  181.  endm
  182. ldbwx macro dreg,disp
  183.  ckdisp disp+1
  184.  db 0ddh,(dreg+1)*8+46h,disp
  185.  db 0ddh,dreg*8+46h,disp+1
  186.  endm
  187. stbwx macro dreg,disp
  188.  ckdisp disp+1
  189.  db 0ddh,70h+dreg+1,disp
  190.  db 0ddh,70h+dreg,disp+1
  191.  endm
  192. BIT7 EQU 7
  193. BIT6 EQU 6
  194. BIT5 EQU 5
  195. BIT4 EQU 4
  196. BIT3 EQU 3
  197. BIT2 EQU 2
  198. BIT1 EQU 1
  199. BIT0 EQU 0
  200. bit macro bit,reg
  201.  db 0cbh,bit*8+reg+40h
  202.  endm
  203. bset macro bit,reg
  204.  db 0cbh,bit*8+reg+0c0h
  205.  endm
  206. bres macro bit,reg
  207.  db 0cbh,bit*8+reg+80h
  208.  endm
  209. bitx macro bit,disp
  210.  ckdisp disp
  211.  db 0ddh,0cbh,disp,bit*8+46h
  212.  endm
  213. bsetx macro bit,disp
  214.  ckdisp disp
  215.  db 0ddh,0cbh,disp,bit*8+0c6h
  216.  endm
  217. bresx macro bit,disp
  218.  ckdisp disp
  219.  db 0ddh,0cbh,disp,bit*8+86h
  220.  endm
  221. @jr macro label,op
  222.  local disp
  223. disp set label-$-2
  224.  ckdisp disp
  225.  db op,disp
  226.  endm
  227. jr macro label
  228.  @jr label,18h
  229.  endm
  230. jrc macro label
  231.  @jr label,38h
  232.  endm
  233. jrnc macro label
  234.  @jr label,30h
  235.  endm
  236. jrz macro label
  237.  @jr label,28h
  238.  endm
  239. jrnz macro label
  240.  @jr label,20h
  241.  endm
  242. djnz macro label
  243.  @jr label,10h
  244.  endm
  245. rlcr macro reg
  246.  db 0cbh,00h+reg
  247.  endm
  248. rlcx macro disp
  249.  ckdisp disp
  250.  db 0ddh,0cbh,disp,06h
  251.  endm
  252. ralr macro reg
  253.  db 0cbh, 10h+reg
  254.  endm
  255. ralx macro disp
  256.  ckdisp disp
  257.  db 0ddh,0cbh,disp,16h
  258.  endm
  259. rrcr macro reg
  260.  db 0cbh,08h+reg
  261.  endm
  262. rrcx macro disp
  263.  ckdisp disp
  264.  db 0ddh,0cbh,disp,0eh
  265.  endm
  266. rarr macro reg
  267.  db 0cbh,18h+reg
  268.  endm
  269. rarx macro disp
  270.  ckdisp disp
  271.  db 0ddh,0cbh,disp,1eh
  272.  endm
  273. slar macro reg
  274.  db 0cbh,20h+reg
  275.  endm
  276. slax macro disp
  277.  ckdisp disp
  278.  db 0ddh,0cbh,disp,26h
  279.  endm
  280. srar macro reg
  281.  db 0cbh,28h+reg
  282.  endm
  283. srax macro disp
  284.  ckdisp disp
  285.  db 0ddh,0cbh,disp,2eh
  286.  endm
  287. srlr macro reg
  288.  db 0cbh,38h+reg
  289.  endm
  290. srlx macro disp
  291.  ckdisp disp
  292.  db 0ddh,0cbh,disp,3eh
  293.  endm
  294. rld macro
  295.  db 0edh,6fh
  296.  endm
  297. rrd macro
  298.  db 0edh,67h
  299.  endm
  300. @A equ 0ffffh
  301. @H equ 0fffeh
  302. @Hupdate equ 0fffdh
  303. @D equ 0fffch
  304. @Dupdate equ 0fffbh
  305. @B equ 0fffah
  306. @@UNREL macro anything
  307. @unrel set anything
  308.  endm
  309. @baka set false
  310. @bakb set false
  311. @bakd set false
  312. @bakh set false
  313. @opwr macro op,reg,msg,save?
  314.  if not nul op
  315.  @@unrel %op
  316.  if @unrel ne @®
  317.  if save?
  318. @bak® set true
  319.  push reg
  320.  endif
  321.  lxi reg,op
  322.  endif
  323.  else
  324.  +++ operand required as MSG or '@®&'
  325.  endif
  326.  endm
  327. @opwu macro op,reg,msg
  328.  if not nul op
  329.  @@unrel %op
  330.  if @unrel ne @®&update
  331. @bak® set true
  332.  push reg
  333.  if @unrel ne @®
  334.  lxi reg,op
  335.  endif
  336.  endif
  337.  else
  338.  +++ operand required as MSG, '@®&', or '@®&update'
  339.  endif
  340.  endm
  341. @opca macro op,msg,save?
  342.  if not nul op
  343.  if op ne @A
  344.  if save?
  345. @baka set true
  346.  push psw
  347.  endif
  348.  mvi a,op
  349.  endif
  350.  else
  351.  +++ operand required as MSG or '@A'
  352.  endif
  353.  endm
  354. @bakem macro list
  355.  irp r,<list>
  356.  if @bak&r
  357.  if r ne a
  358.  pop r
  359.  else
  360.  pop psw
  361.  endif
  362. @bak&r set false
  363.  endif
  364.  endm
  365.  endm
  366. PROLOG macro
  367.  local Start,SetRet
  368.  extrn @ZZPRG
  369.  extrn @RAMAA
  370.  lhld BdosAddress
  371.  mvi l,0
  372.  sphl
  373.  dcr h
  374.  lxi d,@ZZPRG
  375.  call @RAMAA
  376.  call Start
  377.  if CpmLevel gt 22h
  378.  lxi d,0
  379. SetRet equ $
  380.  mvi c,108
  381.  call BdosJump
  382.  endif
  383.  jmp WarmStart
  384.  public @ERROR
  385. @ERROR: nop
  386.  pop h
  387.  pop d
  388.  mov a,d! ora e
  389.  mvi c,9
  390.  cnz BdosJump
  391.  if CpmLevel gt 22h
  392.  lxi d,0fff0h
  393.  jmp SetRet
  394.  else
  395.  jmp WarmStart
  396.  endif
  397.  public @BDOS
  398. @BDOS: push b
  399.  push d
  400.  db 0ddh
  401.  push h
  402.  db 0fdh
  403.  push h
  404.  call BdosJump
  405.  db 0fdh
  406.  pop h
  407.  db 0ddh
  408.  pop h
  409.  pop d
  410.  pop b
  411.  ret
  412. Start equ $
  413.  endm
  414. ENTERSUB MACRO
  415.  extrn @ERROR
  416.  extrn @BDOS
  417.  endm
  418. ABORT macro ?cond,?msg
  419.  local do,dont
  420.  if not nul ?cond
  421.  j&?cond do
  422.  jr dont
  423. do equ $
  424.  endif
  425.  if not nul ?msg
  426.  @@unrel %?msg
  427.  if @unrel eq @D
  428.  push d
  429.  else
  430.  push h
  431.  lxi h,?msg
  432.  xthl
  433.  endif
  434.  else
  435.  push h
  436.  lxi h,0
  437.  xthl
  438.  endif
  439.  call @ERROR
  440.  if not nul ?cond
  441. dont equ $
  442.  endif
  443.  endm
  444. SAVETAIL macro
  445.  extrn @CMSAV
  446.  call @CMSAV
  447.  endm
  448. TAILTOKN macro ?number
  449.  @opca ?number,<token number>,true
  450.  extrn @CMTOK
  451.  call @CMTOK
  452.  @bakem <A>
  453.  endm
  454. FILLBLOK macro ?adr,?len,?byte
  455.  @opwu ?adr,D,<block address>
  456.  @opwr ?len,B,length,true
  457.  @opca ?byte,<fill byte>,true
  458.  extrn @RAMFL
  459.  call @RAMFL
  460.  @bakem <A,B,D>
  461.  endm
  462. COPYBLOK macro ?to,?frm,?len
  463.  @opwu ?to,D,target
  464.  @opwu ?frm,H,source
  465.  @opwr ?len,B,length,true
  466.  ldir
  467.  @bakem <B,H,D>
  468.  endm
  469. TESTCON macro
  470.  push h
  471.  push psw
  472.  mvi c,11
  473.  call @BDOS
  474.  ora a
  475.  pop h
  476.  mov a,h
  477.  pop h
  478.  endm
  479. DSLOW macro ?size
  480.  @opwr ?size,B,length,true
  481.  extrn @RAMLO
  482.  call @RAMLO
  483.  @bakem <B>
  484.  endm
  485. DSHIGH macro ?size
  486.  @opwr ?size,B,length,true
  487.  extrn @RAMHI
  488.  call @RAMHI
  489.  @bakem <B>
  490.  endm
  491. SPACE? macro ?size
  492.  @opwr ?size,B,length,true
  493.  extrn @RAMCK
  494.  call @RAMCK
  495.  endm
  496. DSLOCK macro
  497.  extrn @RAMLK
  498.  call @RAMLK
  499.  endm
  500. DSUNLOCK macro ?low,?high
  501.  @opwr ?low,D,<low boundary>,true
  502.  @opwr ?high,H,<high boundary>,true
  503.  extrn @RAMAA
  504.  call @RAMAA
  505.  @bakem <H,D>
  506.  endm
  507. FILEDEF macro ?size,?drive,?name,?type,?pass
  508.  local here,size,there,drive
  509.  if not nul ?size
  510.  if ?size lt 128
  511.  +++ buffer size set to 128
  512.  size set 128
  513.  else
  514.  if ?size gt 07F80h
  515.  +++ buffer size is limited to 32,640
  516.  size set 32640
  517.  else
  518.  size set (?size+127) and 07F80h
  519.  endif
  520.  endif
  521.  else
  522.  size set 128
  523.  +++ buffer size assumed as 128
  524.  endif
  525. here equ $
  526.  db 0
  527.  db '        '
  528.  db '   '
  529.  db 0,0,0,0
  530.  dw 0,0,0,0,0,0,0,0
  531.  db 0,0,0,0
  532.  db 0,0
  533.  dw size
  534.  dw 0,0,0
  535.  dw 128
  536.  ds 4
  537.  db '        '
  538.  ds 4
  539. there equ $
  540.  if not nul ?drive
  541.  drive set '&?drive'
  542.  if (drive ge 'A') and (drive le 'P')
  543.  org here
  544.  db drive-'A'+1
  545.  else
  546.  +++ drive must be single letter between A and P
  547.  exitm
  548.  endif
  549.  endif
  550.  if not nul ?name
  551.  org here+1
  552.  db '&?name'
  553.  endif
  554.  if not nul ?type
  555.  org here+9
  556.  db '&?type'
  557.  endif
  558.  if not nul ?pass
  559.  org here+38h
  560.  db '&?pass'
  561.  endif
  562.  org there
  563.  endm
  564. CONFILE macro
  565.  local here,there
  566. here set $
  567.  filedef 128,,CON:
  568. there set $
  569.  org here+24h
  570.  db 11000100b
  571.  org here+28h
  572.  dw there
  573.  org here+30h
  574.  db 1,2
  575.  org there
  576.  ds 128
  577.  endm
  578. MSGFILE macro
  579.  local here,there
  580. here set $
  581.  filedef 128,,CON:
  582. there set $
  583.  org here+24h
  584.  db 01000100b
  585.  org here+30h
  586.  db 1,2
  587.  org there
  588.  endm
  589. LSTFILE macro
  590.  local here,there
  591. here set $
  592.  filedef 128,,LST:
  593. there set $
  594.  org here+24h
  595.  db 01000010b
  596.  org here+30h
  597.  db 0,5
  598.  org there
  599.  endm
  600. AUXFILE macro
  601.  local here,there
  602. here set $
  603.  filedef 128,,AUX:
  604. there set $
  605.  org here+24h
  606.  db 11000001b
  607.  org here+48
  608.  db 3,4
  609.  endm
  610. FASSIGN macro ?file,?string,?default,?parts
  611.  @opwr ?file,D,file,true
  612.  @opwu ?string,H,string
  613.  if not nul ?default
  614.  @opwr ?default,B,<default file>,true
  615.  else
  616.  @opwr 0,B,,true
  617.  endif
  618.  if not nul ?parts
  619.  @opca ?parts,<bitmask>,false
  620.  else
  621.  mvi a,01111b
  622.  endif
  623.  extrn @FASGN
  624.  call @FASGN
  625.  @bakem <B,H,D>
  626.  endm
  627. FGETSPEC macro ?file,?string,?parts
  628.  @opwr ?file,D,file,true
  629.  @opwu ?string,H,string
  630.  if not nul ?parts
  631.  @opca ?parts,bitmask,true
  632.  else
  633.  @opca 01111b,,true
  634.  endif
  635.  extrn @FSTSP
  636.  call @FSTSP
  637.  @bakem <A,H,D>
  638.  endm
  639. FDIRBEGN macro ?file1,?file2
  640.  @opwr ?file1,D,<comparison file>,true
  641.  @opwr ?file2,H,<target file>,true
  642.  extrn @FDIR1
  643.  call @FDIR1
  644.  @bakem <H,D>
  645.  endm
  646. FDIRCONT macro ?file1,?file2
  647.  @opwr ?file1,D,<comparison file>,true
  648.  @opwr ?file2,H,<target file>,true
  649.  extrn @FDIR2
  650.  call @FDIR2
  651.  @bakem <H,D>
  652.  endm
  653. FGETATTR macro ?file
  654.  @opwr ?file,D,file,true
  655.  extrn @FGATT
  656.  call @FGATT
  657.  @bakem <D>
  658.  endm
  659. FPUTATTR macro ?file,?bits
  660.  @opwr ?file,D,file,true
  661.  @opca ?bits,constant,true
  662.  extrn @FPATT
  663.  call @FPATT
  664.  @bakem <A,D>
  665.  endm
  666. FRESET macro ?file
  667.  @opwr ?file,D,file,true
  668.  extrn @FOPNI
  669.  call @FOPNI
  670.  @bakem <D>
  671.  endm
  672. @openo macro ?file,?fill,?call
  673.  @opwr ?file,D,file,true
  674.  if not nul ?fill
  675.  @opca ?fill,constant,true
  676.  else
  677.  @opca CpmEof,constant,true
  678.  endif
  679.  extrn ?call
  680.  call ?call
  681.  @bakem <A,D>
  682.  endm
  683. FREWRITE macro ?file,?fill
  684.  @openo ?file,?fill,@FOPNO
  685.  endm
  686. FAPPEND macro ?file,?fill
  687.  @openo ?file,?fill,@FOPNA
  688.  endm
  689. FUPDATE macro ?file,?fill
  690.  @openo ?file,?fill,@FOPNU
  691.  endm
  692. FRECLEN macro ?file,?rlen
  693.  @opwr ?file,D,file,true
  694.  @opwr ?rlen,H,<record length>,true
  695.  extrn @FRLEN
  696.  call @FRLEN
  697.  @bakem <H,D>
  698.  endm
  699. FCLOSE macro ?file
  700.  @opwr ?file,D,file,true
  701.  extrn @FCLOS
  702.  call @FCLOS
  703.  @bakem <D>
  704.  endm
  705. FSIZE macro ?file,?lw
  706.  @opwr ?file,D,file,true
  707.  @opwu ?lw,H,<longword address>,true
  708.  extrn @FSIZE
  709.  call @FSIZE
  710.  @bakem <H,D>
  711.  endm
  712. FNOTE macro ?file,?lw
  713.  @opwr ?file,D,file,true
  714.  @opwu ?lw,H,<longword address>,true
  715.  extrn @FNOTE
  716.  call @FNOTE
  717.  @bakem <H,D>
  718.  endm
  719. FSEEK macro ?file,?lw
  720.  @opwr ?file,D,file,true
  721.  @opwu ?lw,H,<longword address>,true
  722.  extrn @FSEEK
  723.  call @FSEEK
  724.  @bakem <H,D>
  725.  endm
  726. FRECSEEK macro ?file,?rnum
  727.  @opwr ?file,D,file,true
  728.  @opwr ?rnum,H,<record number>,true
  729.  extrn @FRSEK
  730.  call @FRSEK
  731.  @bakem <H,D>
  732.  endm
  733. FREWIND macro ?file
  734.  @opwr ?file,D,file,true
  735.  extrn @FCKPT
  736.  call @FCKPT
  737.  extrn @FRWND
  738.  call @FRWND
  739.  @bakem <D>
  740.  endm
  741. FEOF? macro ?file
  742.  @opwr ?file,D,file,true
  743.  extrn @FQEOF
  744.  call @FQEOF
  745.  @bakem <H,D>
  746.  endm
  747. @bitst macro ?file,?bit
  748.  @opwr ?file,D,file,true
  749.  push h
  750.  lxi h,36
  751.  dad d
  752.  mov a,m
  753.  ani ?bit
  754.  pop h
  755.  @bakem <D>
  756.  endm
  757. FRDONLY? macro ?file
  758.  @bitst ?file,20h
  759.  endm
  760. FDEVICE? macro ?file
  761.  @bitst ?file,40h
  762.  endm
  763. FCHECKPT macro ?file
  764.  @opwr ?file,D,file,true
  765.  extrn @FCKPT
  766.  call @FCKPT
  767.  @bakem <D>
  768.  endm
  769. FGETBYTE macro ?file
  770.  @opwr ?file,D,file,true
  771.  extrn @FSGBB
  772.  call @FSGBB
  773.  @bakem <D>
  774.  endm
  775. FPUTBYTE macro ?file,?byte
  776.  @opwr ?file,D,file,true
  777.  @opca ?byte,constant,true
  778.  extrn @FSPBB
  779.  call @FSPBB
  780.  @bakem <A,D>
  781.  endm
  782. FGETWORD macro ?file
  783.  @opwr ?file,D,file,true
  784.  extrn @FSG2B
  785.  call @FSG2B
  786.  @bakem <D>
  787.  endm
  788. FPUTWORD macro ?file,?word
  789.  @opwr ?file,D,file,true
  790.  @opwr ?word,H,constant,true
  791.  extrn @FSP2B
  792.  call @FSP2B
  793.  @bakem <H,D>
  794.  endm
  795. FGETLW macro ?file,?lw
  796.  @opwr ?file,D,file,true
  797.  @opwu ?lw,H,<longword address>,true
  798.  extrn @FSG4B
  799.  call @FSG4B
  800.  @bakem <H,D>
  801.  endm
  802. FPUTLW macro ?file,?lw
  803.  @opwr ?file,D,file,true
  804.  @opwr ?lw,H,<longword address>,true
  805.  extrn @FSP4B
  806.  call @FSP4B
  807.  @bakem <H,D>
  808.  endm
  809. FGETBLOK macro ?file,?adr,?len
  810.  @opwr ?file,D,file,true
  811.  @opwu ?adr,H,<target block>
  812.  @opwr ?len,B,blocksize,false
  813.  extrn @FSGBK
  814.  call @FSGBK
  815.  @bakem <H,D>
  816.  endm
  817. FPUTBLOK macro ?file,?adr,?len
  818.  @opwr ?file,D,file,true
  819.  @opwu ?adr,H,<source block>
  820.  @opwr ?len,B,blocksize,true
  821.  extrn @FSPBK
  822.  call @FSPBK
  823.  @bakem <B,H,D>
  824.  endm
  825. FGETCHAR macro ?file
  826.  @opwr ?file,D,file,true
  827.  extrn @FSGAC
  828.  call @FSGAC
  829.  @bakem <D>
  830.  endm
  831. FPUTCHAR macro ?file,?byte
  832.  @opwr ?file,D,file,true
  833.  @opca ?byte,constant,true
  834.  extrn @FSPAC
  835.  call @FSPAC
  836.  @bakem <A,D>
  837.  endm
  838. FGETSTR macro ?file,?str,?len
  839.  @opwr ?file,D,file,true
  840.  @opwu ?str,H,<target string>
  841.  @opwr ?len,B,<max length>,false
  842.  extrn @FSGST
  843.  call @FSGST
  844.  @bakem <H,D>
  845.  endm
  846. FPUTSTR macro ?file,?str
  847.  @opwr ?file,D,file,true
  848.  @opwu ?str,H,<source string>
  849.  extrn @FSPST
  850.  call @FSPST
  851.  @bakem <H,D>
  852.  endm
  853. FPUTLINE macro ?file,?str
  854.  @opwr ?file,D,file,true
  855.  @opwu ?str,H,<source string>
  856.  extrn @FSPST
  857.  call @FSPST
  858.  push psw
  859.  mvi a,13
  860.  extrn @FSPAC
  861.  call @FSPAC
  862.  pop psw
  863.  @bakem <H,D>
  864.  endm
  865. FSKIP macro ?file
  866.  @opwr ?file,D,file,true
  867.  extrn @FSKIP
  868.  call @FSKIP
  869.  @bakem <D>
  870.  endm
  871. FGETAXBW macro ?file
  872.  @opwr ?file,D,file,true
  873.  extrn @FSGXW
  874.  call @FSGXW
  875.  @bakem <D>
  876.  endm
  877. FGETADBW macro ?file
  878.  @opwr ?file,D,file,true
  879.  extrn @FSGBW
  880.  call @FSGBW
  881.  @bakem <D>
  882.  endm
  883. FGETADSW macro ?file
  884.  @opwr ?file,D,file,true
  885.  extrn @FSGSW
  886.  call @FSGSW
  887.  @bakem <D>
  888.  endm
  889. FPUTBBAX macro ?file,?byte
  890.  @opwr ?file,D,file,true
  891.  @opca ?byte,constant,true
  892.  extrn @FSPBX
  893.  call @FSPBX
  894.  @bakem <A,D>
  895.  endm
  896. FPUTBBAD macro ?file,?byte
  897.  @opwr ?file,D,file,true
  898.  @opca ?byte,constant,true
  899.  extrn @FSPBD
  900.  call @FSPBD
  901.  @bakem <A,D>
  902.  endm
  903. FPUTBWAX macro ?file,?word
  904.  @opwr ?file,D,file,true
  905.  @opwr ?word,H,constant,true
  906.  extrn @FSPWX
  907.  call @FSPWX
  908.  @bakem <H,D>
  909.  endm
  910. FPUTBWAD macro ?file,?word,?width
  911.  @opwr ?file,D,file,true
  912.  @opwr ?word,H,constant,true
  913.  @opca ?width,<field width>,true
  914.  extrn @FSPBW
  915.  call @FSPBW
  916.  @bakem <A,H,D>
  917.  endm
  918. FPUTSWAD macro ?file,?word,?width
  919.  @opwr ?file,D,file,true
  920.  @opwr ?word,H,constant,true
  921.  @opca ?width,<field width>,true
  922.  extrn @FSPSW
  923.  call @FSPSW
  924.  @bakem <A,H,D>
  925.  endm
  926. FPUTLWAX macro ?file,?lw
  927.  @opwr ?file,D,file,true
  928.  @opwu ?lw,H,<longword address>,true
  929.  extrn @FSPLX
  930.  call @FSPLX
  931.  @bakem <H,D>
  932.  endm
  933. FPUTLWAD macro ?file,?lw,?width
  934.  @opwr ?file,D,file,true
  935.  @opwu ?lw,H,<longword address>,true
  936.  @opca ?width,<field width>,true
  937.  extrn @FSPLD
  938.  call @FSPLD
  939.  @bakem <A,H,D>
  940.  endm
  941. STRSPACE macro ?len
  942.  db 0
  943.  ds ?len
  944.  endm
  945. STRCONST macro ?literal,?len
  946.  local here
  947. here set $
  948.  db ?literal
  949.  db 0
  950.  if not nul ?len
  951.  org here+?len
  952.  endif
  953.  endm
  954. STRTABLE macro ?count
  955.  local tabend
  956. tabend set $+(2*?count+1)
  957.  db ?count
  958. @tabnxt set $
  959.  rept ?count
  960.  dw tabend
  961.  endm
  962.  db 0
  963.  endm
  964. STRENTRY macro ?literal
  965.  local here
  966. here set $
  967.  org @tabnxt
  968.  dw here
  969. @tabnxt set $
  970.  org here
  971.  db ?literal
  972.  db 0
  973.  endm
  974. STRNULL macro ?str
  975.  if not nul ?str
  976.  @@unrel %?str
  977.  if (@unrel eq @D) or (@unrel eq @Dupdate)
  978.  xchg
  979.  mvi m,0
  980.  xchg
  981.  else
  982.  push h
  983.  lxi h,?str
  984.  mvi m,0
  985.  pop h
  986.  endif
  987.  else
  988.  +++ string required as label or '@D'
  989.  endif
  990.  endm
  991. STREND macro ?str
  992.  if not nul ?str
  993.  @@unrel %?str
  994.  if @unrel eq @Dupdate
  995.  extrn @STEND
  996.  call @STEND
  997.  else
  998.  +++ operand must be '@Dupdate'
  999.  endif
  1000.  else
  1001.  +++ operand required as '@Dupdate'
  1002.  endif
  1003.  endm
  1004. STRSKIP macro ?str
  1005.  if not nul ?str
  1006.  @@unrel %?str
  1007.  if @unrel eq @Dupdate
  1008.  extrn @STSKP
  1009.  call @STSKP
  1010.  else
  1011.  +++ operand must be '@Dupdate'
  1012.  endif
  1013.  else
  1014.  +++ operand required as '@Dupdate'
  1015.  endif
  1016.  endm
  1017. STRLEN macro ?str
  1018.  @opwu ?str,D,address
  1019.  extrn @STLEN
  1020.  call @STLEN
  1021.  @bakem <D>
  1022.  endm
  1023. STRLOOK macro ?str,?tab
  1024.  @opwu ?str,D,<string address>
  1025.  @opwu ?tab,H,<table address>
  1026.  extrn @STLOK
  1027.  call @STLOK
  1028.  @bakem <H,D>
  1029.  endm
  1030. STRAPPND macro ?st1,?st2
  1031.  @opwu ?st1,D,<target string>
  1032.  @opwu ?st2,H,<source string>
  1033.  extrn @STAPP
  1034.  call @STAPP
  1035.  @bakem <H,D>
  1036.  endm
  1037. STRCOPY macro ?st1,?st2
  1038.  @opwu ?st1,D,<target string>
  1039.  @opwu ?st2,H,<source string>
  1040.  xchg
  1041.  mvi m,0
  1042.  xchg
  1043.  extrn @STAPP
  1044.  call @STAPP
  1045.  @bakem <H,D>
  1046.  endm
  1047. STRTAKE macro ?st1,?st2,?len,?pad
  1048.  @opwu ?st1,D,<target string>
  1049.  if not nul ?st2
  1050.  @opwu ?st2,H,
  1051.  else
  1052.  local nulbyte
  1053. nulbyte: nop
  1054.  @opwu nulbyte,H,
  1055.  endif
  1056.  @opwr ?len,B,<output length>,true
  1057.  if not nul ?pad
  1058.  @opca ?pad,,true
  1059.  else
  1060.  @opca 020h,,true
  1061.  endif
  1062.  extrn @STAKE
  1063.  call @STAKE
  1064.  @bakem <A,B,H,D>
  1065.  endm
  1066. STRAPTXT macro ?str,?txt
  1067.  @opwu ?str,D,<target string>
  1068.  @opwu ?txt,H,<source text>
  1069.  extrn @STTXT
  1070.  call @STTXT
  1071.  @bakem <H,D>
  1072.  endm
  1073. STRCMP macro ?st1,?st2
  1074.  @opwu ?st1,D,<first string>
  1075.  @opwu ?st2,H,<second string>
  1076.  extrn @STCMP
  1077.  call @STCMP
  1078.  @bakem <H,D>
  1079.  endm
  1080. STRPUT macro ?st1,?byte
  1081.  @opwu ?st1,D,<target string>
  1082.  @opca ?byte,constant,true
  1083.  extrn @STPUT
  1084.  call @STPUT
  1085.  @bakem <A,D>
  1086.  endm
  1087. STRAXBW macro ?str
  1088.  @opwu ?str,D,<numeric string>
  1089.  extrn @STGXW
  1090.  call @STGXW
  1091.  @bakem <D>
  1092.  endm
  1093. STRADBW macro ?str
  1094.  @opwu ?str,D,<numeric string>
  1095.  extrn @STGBW
  1096.  call @STGBW
  1097.  @bakem <D>
  1098.  endm
  1099. STRADSW macro ?str
  1100.  @opwu ?str,D,<numeric string>
  1101.  extrn @STGSW
  1102.  call @STGSW
  1103.  @bakem <D>
  1104.  endm
  1105. STRBBAX macro ?str,?byte
  1106.  @opwu ?str,D,<target string>
  1107.  @opca ?byte,constant,true
  1108.  extrn @STPBX
  1109.  call @STPBX
  1110.  @bakem <A,D>
  1111.  endm
  1112. STRBWAX macro ?str,?wrd
  1113.  @opwu ?str,D,<target string>
  1114.  @opwr ?wrd,H,constant,true
  1115.  extrn @STPWX
  1116.  call @STPWX
  1117.  @bakem <H,D>
  1118.  endm
  1119. STRLWAX macro ?str,?lw
  1120.  @opwu ?str,D,<target string>
  1121.  @opwu ?lw,H,<longword address>,true
  1122.  extrn @STPLX
  1123.  call @STPLX
  1124.  @bakem <H,D>
  1125.  endm
  1126. STRBBAD macro ?str,?val
  1127.  @opwu ?str,D,<target string>
  1128.  @opca ?val,constant,true
  1129.  extrn @STPBB
  1130.  call @STPBB
  1131.  @bakem <A,D>
  1132.  endm
  1133. STRBWAD macro ?str,?wrd,?len
  1134.  @opwu ?str,D,<target string>
  1135.  @opwr ?wrd,H,constant,true
  1136.  @opca ?len,fieldsize,true
  1137.  extrn @STPBW
  1138.  call @STPBW
  1139.  @bakem <A,H,D>
  1140.  endm
  1141. STRSWAD macro ?str,?wrd,?len
  1142.  @opwu ?str,D,<target string>
  1143.  @opwr ?wrd,H,constant,true
  1144.  @opca ?len,fieldsize,true
  1145.  extrn @STPSW
  1146.  call @STPSW
  1147.  @bakem <A,H,D>
  1148.  endm
  1149. STRLWAD macro ?str,?lw,?len
  1150.  @opwu ?str,D,<target string>
  1151.  @opwu ?lw,H,<longword address>,true
  1152.  @opca ?len,fieldsize,true
  1153.  extrn @STPLW
  1154.  call @STPLW
  1155.  @bakem <A,H,D>
  1156.  endm
  1157. @loada macro ?arg
  1158.  if ?arg ne @A
  1159.  if ?arg ne @D
  1160.  if ?arg ne @H
  1161.  +++ operand of '@A', '@D', or '@H' required
  1162.  exitm
  1163.  else
  1164.  mov a,m
  1165.  endif
  1166.  else
  1167.  ldax d
  1168.  endif
  1169.  endif
  1170.  endm
  1171. toupper macro ?arg
  1172.  @loada ?arg
  1173.  extrn @TOUPR
  1174.  call @TOUPR
  1175.  endm
  1176. graphic? macro ?arg
  1177.  @loada ?arg
  1178.  extrn @CKGRP
  1179.  call @CKGRP
  1180.  endm
  1181. control? macro ?arg
  1182.  @loada ?arg
  1183.  extrn @CKCTL
  1184.  call @CKCTL
  1185.  endm
  1186. white? macro ?arg
  1187.  @loada ?arg
  1188.  extrn @CKWHT
  1189.  call @CKWHT
  1190.  endm
  1191. alnum? macro ?arg
  1192.  @loada ?arg
  1193.  extrn @CKALN
  1194.  call @CKALN
  1195.  endm
  1196. alpha? macro ?arg
  1197.  @loada ?arg
  1198.  extrn @CKALF
  1199.  call @CKALF
  1200.  endm
  1201. upper? macro ?arg
  1202.  @loada ?arg
  1203.  extrn @CKUPR
  1204.  call @CKUPR
  1205.  endm
  1206. lower? macro ?arg
  1207.  @loada ?arg
  1208.  extrn @CKLWR
  1209.  call @CKLWR
  1210.  endm
  1211. hdigit? macro ?arg
  1212.  @loada ?arg
  1213.  extrn @CKHEX
  1214.  call @CKHEX
  1215.  endm
  1216. digit? macro ?arg
  1217.  @loada ?arg
  1218.  extrn @CKDIG
  1219.  call @CKDIG
  1220.  endm
  1221. delim? macro ?arg
  1222.  @loada ?arg
  1223.  extrn @CKDLM
  1224.  call @CKDLM
  1225.  endm
  1226. fdelim? macro ?arg
  1227.  @loada ?arg
  1228.  extrn @CKFLM
  1229.  call @CKFLM
  1230.  endm
  1231. ADDHLA macro
  1232.  extrn @ADDAH
  1233.  call @ADDAH
  1234.  endm
  1235. ADDHL2A macro
  1236.  extrn @ADD2A
  1237.  call @ADD2A
  1238.  endm
  1239. MPY816 macro ?op1,?op2
  1240.  @opwr ?op1,H,constant,false
  1241.  @opca ?op2,constant,true
  1242.  extrn @MPYBB
  1243.  call @MPYBB
  1244.  @bakem <A>
  1245.  endm
  1246. DIV816 macro ?op1,?op2
  1247.  @opwr ?op1,H,constant,false
  1248.  @opca ?op2,constant,false
  1249.  extrn @DIVBB
  1250.  call @DIVBB
  1251.  endm
  1252. CPLBW macro ?op1
  1253.  @opwr ?op1,H,constant,false
  1254.  extrn @CPLBW
  1255.  call @CPLBW
  1256.  endm
  1257. CMPBW macro ?op1,?op2
  1258.  @opwr ?op1,H,constant,true
  1259.  @opwr ?op2,D,constant,true
  1260.  ora a
  1261.  if not @bakh
  1262.  push h
  1263.  endif
  1264.  dsbc d
  1265.  if not @bakh
  1266.  pop h
  1267.  endif
  1268.  @bakem <D,H>
  1269.  endm
  1270. CMPSW macro ?op1,?op2
  1271.  @opwr ?op1,H,constant,true
  1272.  @opwr ?op2,D,constant,true
  1273.  extrn @CMPSW
  1274.  call @CMPSW
  1275.  @bakem <D,H>
  1276.  endm
  1277. @arith macro ?op1,?op2,?mod
  1278.  @opwr ?op1,H,constant,false
  1279.  @opwr ?op2,D,constant,false
  1280.  extrn ?mod
  1281.  call ?mod
  1282.  endm
  1283. MPYBW macro ?op1,?op2
  1284.  @arith ?op1,?op2,@MPYBW
  1285.  endm
  1286. MPYSW macro ?op1,?op2
  1287.  @arith ?op1,?op2,@MPYSW
  1288.  endm
  1289. DIVBW macro ?op1,?op2
  1290.  @arith ?op1,?op2,@DIVBW
  1291.  endm
  1292. DIVSW macro ?op1,?op2
  1293.  @arith ?op1,?op2,@DIVSW
  1294.  endm
  1295. STORELW macro ?where
  1296.  @opwr ?where,B,<target address>,true
  1297.  extrn @STOLW
  1298.  call @STOLW
  1299.  @bakem <B>
  1300.  endm
  1301. LOADLW macro ?where
  1302.  @opwr ?where,B,<source address>,true
  1303.  extrn @LODLW
  1304.  call @LODLW
  1305.  @bakem <B>
  1306.  endm
  1307. SRLLW macro
  1308.  srlr d
  1309.  rarr e
  1310.  rarr h
  1311.  rarr l
  1312.  endm
  1313. SLLLW macro
  1314.  dad h
  1315.  xchg
  1316.  dadc h
  1317.  xchg
  1318.  endm
  1319. CPLLW macro
  1320.  extrn @CPLLW
  1321.  call @CPLLW
  1322.  endm
  1323. DIVLWBW macro ?dvsr
  1324.  @opwr ?dvsr,B,divisor,true
  1325.  extrn @DIVLW
  1326.  call @DIVLW
  1327.  @bakem <B>
  1328.  endm
  1329. ADDLWBW macro ?value
  1330.  local skip
  1331.  @opwr ?value,B,<added word>,true
  1332.  dad b
  1333.  jrnc skip
  1334.  inx d
  1335. skip equ $
  1336.  @bakem <B>
  1337.  endm
  1338. SUBLWBW macro ?value
  1339.  local skip
  1340.  @opwr ?value,B,<subtracted word>,true
  1341.  ora a
  1342.  dsbc b
  1343.  jrnc skip
  1344.  dcx d
  1345. skip equ $
  1346.  @bakem <B>
  1347.  endm
  1348. ADDLW macro ?lw
  1349.  @opwr ?lw,B,<storage longword>,true
  1350.  extrn @ADDLW
  1351.  call @ADDLW
  1352.  @bakem <B>
  1353.  endm
  1354. SUBLW macro ?lw
  1355.  @opwr ?lw,B,<storage longword>,true
  1356.  extrn @SUBLW
  1357.  call @SUBLW
  1358.  @bakem <B>
  1359.  endm
  1360. CMPLW macro ?lw
  1361.  @opwr ?lw,B,<storage longword>,true
  1362.  extrn @CMPLW
  1363.  call @CMPLW
  1364.  @bakem <B>
  1365.  endm
  1366. RANDBW macro
  1367.  extrn @PRIBW
  1368.  call @PRIBW
  1369.  endm
  1370. RANDMOD macro ?mod
  1371.  @opwr ?mod,D,<modulus value>,true
  1372.  extrn @PRIMD
  1373.  call @PRIMD
  1374.  @bakem <D>
  1375.  endm
  1376. RANDLW macro
  1377.  extrn @PRILW
  1378.  call @PRILW
  1379.  endm
  1380. RANDSDLW macro
  1381.  extrn @PRSDL
  1382.  call @PRSDL
  1383.  endm
  1384. RANDSDBW macro ?seed
  1385.  @opwr ?seed,H,<seed value>,true
  1386.  extrn @PRSDW
  1387.  call @PRSDW
  1388.  @bakem <H>
  1389.  endm
  1390. 
  1391.  call @PRSDL
  1392.  endm
  1393. RANDSDBW macro ?seed
  1394.  @opwr ?seed,H,<seed va