home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / 22rsx / rxmd.ark.2 / RXMD05.MAC < prev    next >
Encoding:
Text File  |  1985-12-07  |  7.3 KB  |  333 lines

  1. ;
  2. ; index words.  hl := hl + 2*a (max a =127)
  3. ; a,f,h,l
  4. indexw:    add    a
  5. ;    "    "
  6. ; index bytes.  hl := hl + a
  7. ; a,f,h,l
  8. indexb:    add    l
  9.     mov    l,a
  10.     rnc
  11.     inr    h
  12.     ret
  13. ;
  14. ; -----------------------------------------------
  15. ;         multi-file access routine
  16. ;
  17. ; Multi-file access subroutine.  Allows processing of multiple files
  18. ; (i.e., *.ASM) from disk.  Builds the correct name in the FCB each
  19. ; time it is called.  The command is used in programs to process
  20. ; single or multiple files.  The FCB is set up with the next name,
  21. ; ready to do normal processing (open, read, etc.) when routine is
  22. ; called. The initial call (mfirst flag = 0) sets the sub-system up
  23. ; from the name in FCB. Carry is set if no more names are found.
  24. ; Tbuf is used and dma is set to it.
  25. ; a,f,d,e,h,l
  26. mfnam:    call    rsdma;        set default dma addr.
  27.     xra    a
  28.     sta    fcbext
  29.     lda    mfirst
  30.     ora    a
  31.     jnz    mfnam1
  32.     mvi    a,1
  33.     sta    mfirst;        Flag system started
  34.     lxi    h,fcb
  35.     lxi    d,mfbase
  36.     call    move12;        save the pattern
  37.     lda    fcb
  38.     sta    mflast;        Save disk in current FCB
  39.     mvi    a,srchf
  40.     jmp    mfnam2
  41. ;
  42. mfnam1:    lxi    h,mflast
  43.     lxi    d,fcb
  44.     call    move12;        copy last filename
  45.     mvi    a,srchf;    reset dos pointers to it
  46.     call    fileop
  47.     lxi    h,mfbase
  48.     lxi    d,fcb
  49.     call    move12;        set to the base pattern
  50.     mvi    a,srchn
  51. mfnam2:    call    fileop;        search first or search next
  52.     inr    a
  53.     jz    mfnam3;        none-found, exit sub-system
  54.     dcr    a;        correct for inr above
  55.     ani    3
  56.     add    a;        *2
  57.     add    a;        *4
  58.     add    a;        *8
  59.     add    a;        *16 words = 32 bytes
  60.     lxi    h,tbuf+1
  61.     call    indexw;        to dir entry found
  62.     push    h;        Save name pointer
  63.     lxi    d,mflast+1
  64.     mvi    b,11
  65.     call    move;        record the found file name
  66.     pop    h
  67.     lxi    d,fcb+1
  68.     mvi    b,11
  69.     call    move;        revise fcb to the found file
  70.     xra    a
  71.     sta    fcbext;        set up for opening
  72.     sta    fcbrno
  73.     ret
  74. mfnam3:    sta    mfirst;        0. reset flag to re-initialize
  75.     stc;            signal no more files
  76.     ret
  77. ;
  78. ;     end of multi-file access routine
  79. ; ---------------------------------------------
  80. ;
  81. ; Loads a command line addressed by 'DE' registers (max # characters
  82. ; in line in DE^, number of characters in line in DE+1^, line starts
  83. ; at DE+2^) into FCBs addressed by HL^ registers.  The FCB should be
  84. ; at least 33 bytes in length.  The command line buffer must have a
  85. ; maximum length at least one more than the greatest number of
  86. ; characters that will be needed.  Regs. preserved
  87. cmdln:    push    psw
  88.     push    b
  89.     push    d
  90.     push    h;        init 2 half FCBs at hl^ with nulls
  91.     mvi    m,0;        blanks in name/type areas
  92.     inx    h
  93.     mvi    b,11
  94.     mvi    a,' '
  95.     call    fill;        blank fill
  96.     mvi    b,5
  97.     call    fillz;        zero fill
  98.     mvi    b,11
  99.     mvi    a,' '
  100.     call    fill;        blank fill
  101.     mvi    b,4
  102.     call    fillz;        zero fill
  103.     pop    h
  104.     push    h
  105.     xchg;            Get start of command line in HL
  106.     inx    h;        Address # bytes in command line
  107.     mov    e,m;        Load DE pair with # bytes
  108.     mvi    d,0
  109.     inx    h
  110.     dad    d;        Point to byte after last character
  111.     mvi    m,cr;        In command line and store delimiter
  112.     pop    h;        Restore HL and DE
  113.     pop    d
  114.     push    d
  115.     push    h
  116.     inx    d;        Address start of command
  117.     inx    d
  118.     call    drivx;        extract any drive info
  119.     mvi    c,8;        Transfer first filename to FCB
  120.     call    trans
  121.     cpi    cr
  122.     jz    cmdln3
  123.     cpi    ' ';        If space, then start of 2nd filename
  124.     jz    cmdln1
  125.     pop    h;        Filetype starts after 8th byte
  126.     push    h
  127.     lxi    b,9
  128.     dad    b
  129.     mvi    c,3;        Transfer type of first file
  130.     call    trans
  131.     cpi    cr
  132.     jz    cmdln3
  133. cmdln1:    ldax    d;        Eat multiple spaces between names
  134.     cpi    ' '
  135.     jnz    cmdln2
  136.     inx    d
  137.     jmp    cmdln1
  138. cmdln2:    pop    h;        2nd name starts in 16th byte
  139.     push    h;        Point HL to this byte
  140.     lxi    b,16
  141.     dad    b
  142.     call    drivx;        extract any drive info
  143.     mvi    c,8
  144.     call    trans
  145.     cpi    cr
  146.     jz    cmdln3
  147.     pop    h;        2nd file type starts in 25th byte
  148.     push    h
  149.     lxi    b,25
  150.     dad    b
  151.     mvi    c,3
  152.     call    trans
  153. cmdln3:    pop    h
  154.     push    h
  155.     inx    h;        Point to 1st char of 1st name in FCB
  156.     call    scanl;        Check for * (ambiguous names)
  157.     pop    h
  158.     push    h
  159.     lxi    b,17;        To 1st char of 2nd name in FCB
  160.     dad    b
  161.     call    scanl
  162.     pop    h
  163.     pop    d
  164.     pop    b
  165.     pop    psw
  166.     ret
  167. ;
  168. ; transfer up to (c) chars from de^ to hl^.  Stop at hl^ a delimiter
  169. ; advance hl and de.  Scan to hl^ a delimiter, absorb excess chars.
  170. ; a,f,c,d,e,h,l
  171. trans:    ldax    d
  172.     inx    d
  173.     call    ucase;        upshift for CCPLUS command line
  174.     cpi    cr
  175.     rz;            delimiter
  176.     cpi    '.'
  177.     rz;            delimiter
  178.     cpi    ' '
  179.     rz;            delimiter
  180.     dcr    c
  181.     jm    trans;        field full, scan w/o transfer
  182.     mov    m,a
  183.     inx    h;        Transfer to FCB.
  184.     jmp    trans
  185. ;
  186. ; Extract drive id (if any) from string de^ to fcb hl^.
  187. ; advance hl^ past drive specifier.
  188. ; a,f,d,e,h,l
  189. drivx:    inx    d;        Check 2nd byte of filename.  if it..
  190.     ldax    d;        Is a ":", then drive was specified..
  191.     dcx    d
  192.     cpi    ':'
  193.     jnz    drivxx;        Else zero for default drive
  194.     ldax    d;        ('INIT' put zero)
  195.     ani    5fh
  196.     sui    '@';        Calculate drive (A=1, B=2,...)
  197.     mov    m,a;        Place it in FCB
  198.     inx    d;        Address first byte in command line
  199.     inx    d
  200. drivxx:    inx    h;        And name field in FCB
  201.     ret
  202. ;
  203. ; scan fcb name hl^, converting * to '?' fields
  204. ; a,f,b,h,l
  205. scanl:    mvi    b,8;        Size of name field
  206.     call    scanl1;        Scan & fill name field
  207.     mvi    b,3;        Size of type field
  208. scanl1:    mov    a,m;        Scan & fill
  209.     cpi    '*'
  210.     mvi    a,'?';        in case fill here
  211.     jz    fill
  212.     inx    h
  213.     dcr    b
  214.     jnz    scanl1
  215.     ret
  216. ;
  217. ; Clears the FCB hl^ area, except the drive specifier
  218. ; a,f,b,h,l
  219. initfcb:
  220.     inx    h;        advance over drive specifier
  221.     mvi    b,11;        Clears the filename/type area
  222.     mvi    a,' '
  223.     call    fill
  224.     mvi    b,21;        zero the rest
  225. ;    "    "
  226. ; fill hl^ for b with zero
  227. ; a,f,b,h,l
  228. fillz:    xra    a
  229. ;    "    "
  230. ; fill hl^ for b with a
  231. ; f,b,h,l
  232. fill:    mov    m,a
  233.     inx    h
  234.     dcr    b
  235.     jnz    fill
  236.     ret
  237. ;
  238. ; Copies TBUF to CMDBUF, scans CMDBUF counting names
  239. ; and putting delimiter (space) after last name
  240. ;
  241. scan:    lxi    d,cmdbuf;    Save orig TBUF contents in cmdbuf
  242.     push    d
  243.     lxi    h,tbuf
  244.     mvi    b,128
  245.     call    move
  246.     pop    h
  247.     push    h
  248.     mov    a,m
  249.     call    indexb
  250.     inx    h;        Now pointing at space after last char
  251.     mvi    m,' ';        Put in the space
  252.     pop    h;        Get cmdbuf count again
  253.     mov    b,m
  254.     inx    h;        Skip the first space
  255.     inr    b
  256. scan1:    inx    h;        On first entry HL points to 1st char
  257.     dcr    b;        1st go-thru B is count to last space
  258.     jz    scan5
  259.     mov    a,m;        Look for the first space
  260.     cpi    ' '
  261.     jnz    scan1
  262. scan2:    inx    h;        Eat extra spaces
  263.     dcr    b
  264.     jz    scan5
  265.     mov    a,m
  266.     cpi    ' '
  267.     jz    scan2
  268.     shld    bgnms;        Save start of names in cmdbuf
  269.     inr    b
  270.     dcx    h
  271. scan3:    inx    h
  272.     dcr    b
  273.     jz    scan5
  274.     mov    a,m
  275.     cpi    ' '
  276.     jnz    scan3
  277.     lda    namect;        Counts names
  278.     inr    a
  279.     sta    namect;        and repeat test, next line
  280. scan4:    mov    a,m
  281.     cpi    ' '
  282.     jnz    scan3
  283.     inx    h;        Eat spaces
  284.     dcr    b
  285.     jnz    scan4
  286. scan5:    lda    namect;        Were there any names?
  287.     ora    a
  288.     rnz;            Yes
  289.     pop    h;        Remove calls from stack
  290.     pop    h
  291.     jmp    opterr;        Bail out to avoid BDOS error
  292. ;
  293. ;
  294. ; -------------------------------------------------------------------
  295. ;
  296. ; Show the file name as stored in the FCB but in CP/M format
  297. ;
  298. showfil:
  299.     mvi    a,1;        Show on local CRT only
  300.     sta    remoff
  301.     call    ilprt
  302.  db    'File name: ',0
  303.     lxi    h,fcb+1
  304.     xra    a
  305.     sta    ftycnt
  306.     mvi    c,11
  307. ;    "    "
  308. prnam:    call    ftytst
  309.     inx    h
  310.     dcr    c
  311.     jnz    prnam
  312.     ret
  313. ;
  314. ftytst:    lda    ftycnt
  315.     inr    a
  316.     sta    ftycnt
  317.     cpi    9;        Are we at the file type?
  318.     jz    spctst;        Go if so
  319. ;    "    "
  320. endspt:    mov    a,m
  321.     cpi    ' ';        Test for space
  322.     cnz    ctype;        Type if not
  323.     ret
  324. ;
  325. spctst:    mov    a,m
  326.     cpi    ' ';        Test for space in 1st file type byte
  327.     rz;            Do not output period if space
  328.     mvi    a,'.'
  329.     call    ctype
  330.     jmp    endspt;        Output 1st file type byte
  331. ;
  332. ; --------------------------------------------------
  333. ):