home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BDOS / DOSPLSOR.ARK / INITDIR.MAC < prev    next >
Text File  |  1986-10-28  |  14KB  |  921 lines

  1. ; This program creates a directory structure suitable for
  2. ; time-stamping with DOS+.  Any previous time-stamps are
  3. ; lost, and the directory is sorted.
  4. ;
  5. ; Usage:
  6. ;    INITDIR d        (to initialize drive d:)
  7. ; or
  8. ;    INITDIR d X        (to remove old time stamps)
  9. ;
  10. ; (If the disk is already time stamped INITDIR will abort unless
  11. ;  the "x" parameter is supplied.  Similarly, INITDIR will abort
  12. ;  when too many directory entries are already used)
  13. ;
  14. ; It may be necessary to patch the "sec1st" value to 1 at location
  15. ; 0103h, if the bios system expects sectors from 1 up prior to
  16. ; sector translation.
  17. ;
  18. ; 1.0    86/10/28.  Initial release.        C.B. Falconer
  19. ;
  20. ver    equ    10
  21. ;
  22. boot    equ    0
  23. bdos    equ    5
  24. ;
  25. cr    equ    0dh
  26. lf    equ    0ah
  27. ;
  28. ; bdos calls
  29. coute    equ    2
  30. putmsg    equ    9
  31. dosver    equ    12
  32. seldsk    equ    14
  33. galloc    equ    27
  34. getdpbp    equ    31
  35.  
  36. offset    equ    13;        of "off" in dpblk
  37. ;
  38. ; offsets for bios entries (from COLD boot entry)
  39. bdrvsel    equ    001Bh
  40. bsetrk    equ    001Eh
  41. bsetsec    equ    0021h
  42. bsetdma    equ    0024h
  43. bread    equ    0027h
  44. bwrite    equ    002Ah
  45. bsecxlt    equ    0030h
  46. ;
  47. tbuf    equ    0080h;        default DMA buffer & cmd line
  48. ;
  49. vacant    equ    00E5h;        empty dir entries marked
  50. timark    equ    021h;        marker for time-stamp entry
  51. dentsiz    equ    32;        size of a directory entry (coded in)
  52. ;
  53.     jmp    begin
  54. ;
  55. sec1st:    db    0;        Patch if sectors do not
  56. ;                start at zero (to secxlate)
  57. begin:    lxi    sp,stack
  58.     lxi    d,signon
  59.     call    tstr
  60.     mvi    c,dosver
  61.     call    bdos;        to get hl value
  62.     lxi    d,badvermsg;    DOS+ returns 23 up.
  63.     inr    h
  64.     dcr    h
  65.     jnz    exeunt;        maybe MPM?
  66.     cpi    20h
  67.     jc    exeunt;        maybe 1.4
  68.     cpi    30h
  69.     jnc    exeunt;        maybe 3.0
  70.     lxi    h,tbuf
  71.     mov    a,m
  72.     ora    a
  73.     lxi    d,help
  74.     jz    exeunt;        empty line
  75. bgn1:    inx    h
  76.     mov    a,m;        skip blanks
  77.     ora    a
  78.     jz    exeunt;        eol, empty line
  79.     cpi    ' '
  80.     jz    bgn1
  81.     ani    05fh;        upshift
  82.     sui    'A'
  83.     cpi    16
  84.     jnc    exeunt
  85.     sta    drive    
  86.     mov    e,a
  87. bgn2:    inx    h
  88.     mov    a,m
  89.     ora    a
  90.     jz    bgn4;        eol
  91.     cpi    ' '
  92.     jnz    bgn2;        skip to next field
  93.     dcx    h
  94. bgn3:    inx    h
  95.     mov    a,m;        now skip blanks
  96.     ora    a
  97.     jz    bgn4
  98.     cpi    ' '
  99.     jz    bgn3
  100.     ani    05fh;        upshift
  101.     sui    'X'
  102.     mvi    a,0
  103.     jnz    bgn4
  104.     mvi    a,0ffh
  105. bgn4:    sta    killmk;        any non-zero does the kill
  106.     mvi    a,seldsk
  107.     call    dos;        aborts on invalid drive
  108. ;
  109.     lxi    d,loading
  110.     call    tstr
  111.     mvi    c,getdpbp
  112.     call    bdos;        Not dos, need HL
  113.     mov    a,m
  114.     sta    spt    
  115.     inx    h
  116.     inx    h;        +2
  117.     mov    a,m
  118.     sta    bsh    
  119.     inx    h
  120.     inx    h
  121.     inx    h;        +5
  122.     mov    e,m
  123.     inx    h
  124.     mov    d,m;        get dsm
  125.     push    d
  126.     inx    h;        +7
  127.     mov    e,m
  128.     inx    h
  129.     mov    d,m;        get drm
  130.     inx    h
  131.     mov    b,m;        get al0
  132.     inx    h;        +10
  133.     mov    c,m;        get al1
  134.     inx    h
  135.     inx    h
  136.     inx    h;        +13, point to off
  137.     mov    a,m
  138.     inx    h
  139.     mov    h,m
  140.     mov    l,a
  141.     shld    firstk;        1st storage track
  142.     xchg    
  143.     inx    h
  144.     shld    dirmaxplus1    
  145.     push    h
  146.     call    shlrt
  147.     call    shlrt
  148.     shld    dirsectors;    := (dirmax+1)/4
  149.     pop    h
  150.     pop    d
  151. ;a=bsh, bc=diralloc bits, de=dsm, hl=dirmax+1
  152.     call    setup;        preserves af, hl:=dsm
  153.     inx    h
  154.     shld    dsmplus1    
  155.     lda    drive
  156.     mov    c,a
  157.     mvi    a,bdrvsel
  158.     call    callbios
  159.     mov    e,m
  160.     inx    h
  161.     mov    d,m
  162.     xchg    
  163.     shld    secxltptr    
  164.     lhld    dirsectors
  165.     mov    b,h
  166.     mov    c,l
  167.     lda    sec1st
  168.     mov    e,a
  169.     lhld    firstk;        1st user track
  170.     shld    track    
  171.     lxi    h,buffer
  172.     mvi    d,bread
  173.     call    rwdir;        into buffer
  174.     jnz    rdwrterror
  175.     lxi    d,sortdirmsg
  176.     call    tstr
  177. ;
  178.     call    chkmk;        look for old marks
  179.     call    sort
  180.     call    addstamps;    add in time marker entries
  181. ;
  182.     lxi    d,wrtdirmsg
  183.     call    tstr
  184.     lhld    dirsectors
  185.     mov    b,h
  186.     mov    c,l
  187.     lda    sec1st
  188.     mov    e,a
  189.     lhld    firstk
  190.     shld    track    
  191.     lxi    h,buffer
  192.     mvi    d,bwrite
  193.     call    rwdir;        write dir. back
  194.     jnz    rdwrterror
  195.     lxi    d,statsmsg
  196.     call    tstr
  197.     lhld    dirmaxplus1
  198.     shld    dircounter
  199.     mov    e,l
  200.     mov    d,h;        * 3/4 for entries remaining
  201.     dad    d
  202.     dad    d;        * 3
  203.     call    shlrt
  204.     call    shlrt;        /4
  205.     mov    a,l
  206.     ora    a
  207.     lxi    d,toomanymsg
  208.     jz    exeunt
  209.     call    tdhlzs
  210.     lxi    d,entriesmsg
  211.     call    tstr
  212.     lxi    h,buffer
  213.     lxi    d,0;        entries vacant
  214.     mov    b,d;        entries used
  215.     mov    c,e
  216. ;
  217. L02BC:    mov    a,m;        count entries used/vacant
  218.     cpi    timark
  219.     jz    L02C7
  220.     cpi    vacant
  221.     jz    L02C6
  222.     inx    b
  223.     jmp    L02C7
  224. L02C6:    inx    d
  225. L02C7:    push    d
  226.     lxi    d,dentsiz
  227.     dad    d
  228.     pop    d
  229.     push    h
  230.     lhld    dircounter
  231.     dcx    h
  232.     shld    dircounter    
  233.     mov    a,l
  234.     ora    h
  235.     pop    h
  236.     jnz    L02BC
  237.     push    d
  238.     call    tdbczs
  239.     lxi    d,delentriesmsg
  240.     call    tstr
  241.     pop    h
  242.     call    tdhlzs
  243.     lxi    d,usrsactivemsg
  244.     call    tstr
  245.     mvi    e,0ffh
  246.     lhld    dirmaxplus1
  247.     shld    dircounter    
  248.     lxi    h,buffer
  249. L02FA:    mov    a,m
  250.     cpi    timark
  251.     jz    L0314
  252.     push    h
  253.     cpi    vacant
  254.     jz    L0312
  255.     cmp    e
  256.     jz    L0312
  257.     mov    l,a
  258.     mvi    h,0
  259.     call    tdhlzs
  260.     mvi    a,' '
  261.     call    couta
  262. L0312:    pop    h
  263.     mov    e,m
  264. L0314:    push    d
  265.     lxi    d,dentsiz
  266.     dad    d
  267.     push    h
  268.     lhld    dircounter
  269.     dcx    h
  270.     shld    dircounter    
  271.     mov    a,l
  272.     ora    h
  273.     pop    h
  274.     pop    d
  275.     jnz    L02FA
  276.     lhld    dsmplus1
  277.     lda    blksused
  278.     cma
  279.     mov    e,a
  280.     mvi    d,0ffh
  281.     inx    d
  282.     xchg    
  283.     dad    d
  284.     push    h
  285.     push    d
  286.     mvi    c,galloc
  287.     call    bdos;        get allocation map. Not DOS here
  288.     pop    d
  289.     push    h
  290.     call    L0456
  291.     pop    h
  292.     pop    d
  293.     lxi    b,0
  294. L0346:    push    psw
  295.     push    d
  296.     push    h
  297.     inx    b
  298.     ana    m
  299.     jz    L034F
  300.     dcx    b
  301. L034F:    pop    h
  302.     pop    d
  303.     dcx    d
  304.     mov    a,d
  305.     ora    e
  306.     jz    L035E
  307.     pop    psw
  308.     call    rsha_cnt_in_hl
  309.     jmp    L0346
  310.  
  311. L035E:    pop    psw
  312.     lda    bsh
  313.     mov    d,b
  314.     mov    e,c
  315.     xchg    
  316.     sui    3
  317.     jz    L0382
  318. L036A:    dad    h
  319.     push    h
  320.     lhld    dsmplus1
  321.     dad    h
  322.     shld    dsmplus1    
  323.     pop    h
  324.     dcr    a
  325.     jnz    L036A
  326. ;
  327. L0382:    xchg    
  328.     lxi    h,0
  329. L0389:    mov    a,d
  330.     ora    e
  331.     jz    L0393
  332.     inx    h
  333.     dcx    d
  334.     jmp    L0389
  335.  
  336. L0393:    xchg
  337.     lhld    dsmplus1
  338.     xchg    
  339.     push    h
  340.     mov    a,e
  341.     sub    l
  342.     mov    e,a
  343.     mov    a,d
  344.     sbb    h
  345.     mov    d,a
  346.     lda    kbused
  347.     cma
  348.     mov    l,a
  349.     mvi    h,0ffh
  350.     inx    h
  351.     dad    d
  352.     lxi    d,spaceusedmsg
  353.     call    tstr
  354.     push    h;        save used
  355.     call    tdhlzs
  356.     mvi    a,'K'
  357.     call    couta
  358.     lxi    d,spacefreemsg
  359.     call    tstr
  360.     pop    d;        used
  361.     pop    h;        free
  362.     push    d;        save used
  363.     call    tdhlzs
  364.     mvi    a,'K'
  365.     call    couta
  366.     pop    h;        bc := used; hl := used
  367.     mov    b,h
  368.     mov    c,l
  369.     mvi    e,0;        extend used
  370.     call    lshftehl;    multiply by 100
  371.     inx    h
  372.     call    ehlplusbc
  373.     call    lshftehl
  374.     call    lshftehl
  375.     call    lshftehl
  376.     call    ehlplusbc
  377.     call    lshftehl
  378.     call    lshftehl
  379.     push    h
  380.     lhld    dsmplus1
  381.     mov    b,h
  382.     mov    c,l
  383.     pop    h
  384.     mov    a,c;        bc := -dsmplus1
  385.     cma
  386.     mov    c,a
  387.     mov    a,b
  388.     cma
  389.     mov    b,a
  390.     inx    b
  391.     mvi    d,-1
  392. L03FD:    inr    d;        d := ehl/bc
  393.     dad    b
  394.     mov    a,e
  395.     aci    0ffh
  396.     mov    e,a
  397.     jc    L03FD
  398.     mov    l,d
  399.     mvi    h,0
  400.     lxi    d,pctfullmsg
  401.     call    tstr
  402.     call    tdhlzs
  403.     lxi    d,percent
  404. ;    "    "
  405. exeunt:    call    tstr
  406.     jmp    boot
  407. ;
  408. ; console output from a
  409. ; a,f
  410. couta:    push    d
  411.     mov    e,a
  412.     mvi    a,coute
  413.     call    dos
  414.     pop    d
  415.     ret
  416. ;
  417. ; string from de^ to console
  418. tstr:    mvi    a,putmsg
  419. ;    "    "
  420. ; dos call (a), preserving regs
  421. ; a,f
  422. dos:    push    h
  423.     push    d
  424.     push    b
  425.     mov    c,a
  426.     call    bdos
  427.     pop    b
  428.     pop    d
  429.     pop    h
  430.     ret
  431. ;
  432. lshftehl:
  433.     dad    h
  434.     mov    a,e
  435.     ral
  436.     mov    e,a
  437.     ret
  438. ;
  439. ehlplusbc:
  440.     dad    b
  441.     rnc    
  442.     inr    e
  443.     ret
  444. ;
  445. setup:
  446. ;a=bsh, bc=dirallocbits, de=dsm, hl=dirmax+1
  447.     push    psw
  448.     mov    h,b
  449.     mov    l,c
  450.     mvi    b,16
  451.     mvi    c,0
  452. setup1:    dad    h
  453.     jnc    setup2
  454.     inr    c
  455. setup2:    dcr    b
  456.     jnz    setup1
  457.     mov    a,c
  458.     sta    blksused    
  459.     xchg    
  460.     pop    psw
  461.     push    psw
  462.     push    h
  463.     sui    3
  464.     mov    c,a
  465.     lda    blksused
  466.     mov    b,a
  467.     jz    setup4
  468. setup3:    add    a
  469.     mov    b,a
  470.     dcr    c
  471.     jnz    setup3
  472.     mov    a,b
  473. setup4:    sta    kbused    
  474.     pop    h
  475.     pop    psw
  476.     ret
  477.  
  478. L0456:    lda    blksused
  479.     mov    c,a
  480.     mvi    b,080h
  481. L045C:    mov    a,b
  482.     call    rsha_cnt_in_hl
  483.     mov    b,a
  484.     dcr    c
  485.     jnz    L045C
  486.     mov    a,b
  487.     ret
  488.  
  489. rsha_cnt_in_hl:
  490.     ora    a
  491.     rar
  492.     rnc    
  493.     rar
  494.     inx    h
  495.     ret
  496. ;
  497. ; read or write directory (complete). NZ for error.
  498. ; bc=sectors to rd/wrt, d=r/w opn, e=1st sector, hl=buff ptr
  499. ; a,f,b,c,d,e,h,l
  500. rwdir:    push    b
  501.     push    d
  502.     mov    b,h
  503.     mov    c,l
  504.     push    h;        stk = buff, sect, ct
  505.     lhld    secxltptr;    
  506.     xchg;            l=logical sector
  507.     mvi    h,0
  508.     mvi    a,bsecxlt
  509.     call    callbioshl;    hl=physical sector
  510.     mvi    a,bsetsec
  511.     call    callbioshl;    set sector
  512.     lhld    track
  513.     mvi    a,bsetrk
  514.     call    callbioshl;    set track
  515.     pop    b;        buff address
  516.     lxi    h,080h;        advance for next rd/wrt if any
  517.     dad    b
  518.     push    h
  519.     mvi    a,bsetdma;    setdma to bc, not advanced
  520.     call    callbios
  521.     pop    h
  522.     pop    d
  523.     inr    e;        advance sector for next time
  524.     lda    spt
  525.     cmp    e
  526.     jnz    rwdir1;        more on this track
  527.     push    h
  528.     lhld    track;        advance track for next time
  529.     inx    h
  530.     shld    track    
  531.     pop    h
  532.     lda    sec1st;        and reset sector
  533.     mov    e,a
  534. rwdir1:    pop    b
  535.     push    b
  536.     dcx    b
  537.     mov    a,b
  538.     ora    c;        check for writing last sector
  539.     push    d;        save advanced sect/opn
  540.     push    h;        save advanced address
  541.     mov    a,d;        read or write
  542.     lxi    b,0;        for writes
  543.     jnz    rwdir2;        not last write
  544.     inx    b;        make it a directory write (flush)
  545. rwdir2:    call    callbios;    DO IT
  546.     pop    h
  547.     pop    d
  548.     pop    b
  549.     ora    a
  550.     rnz;            i/o error occured
  551.     dcx    b
  552.     mov    a,b
  553.     ora    c
  554.     jnz    rwdir;        more to read/write
  555.     ret
  556. ;
  557. ; call bios with argument hl, operation (a)
  558. ; a,f,b,c,d,e,h,l
  559. callbioshl:
  560.     mov    b,h
  561.     mov    c,l
  562.     "    "
  563. ; 0th is cold boot entry.  0,3,.. in (a)
  564. ; a,f,b,c,d,e,h,l
  565. callbios:
  566.     push    h
  567.     push    d
  568.     lhld    boot+1
  569.     dcx    h
  570.     dcx    h
  571.     dcx    h
  572.     mov    e,a
  573.     mvi    d,0
  574.     dad    d
  575.     pop    d
  576.     xthl    
  577.     ret
  578. ;
  579. rdwrterror:
  580.     lxi    d,rdwrterrmsg
  581.     mvi    c,putmsg
  582.     call    bdos
  583.     jmp    exeunt
  584. ;
  585. ; write bc in decimal, zero suppress
  586. ; a,f,h,l
  587. tdbczs:    mov    h,b
  588.     mov    l,c
  589. ;    "    "
  590. ; write hl in decimal, zero suppress
  591. ; a,f
  592. tdhlzs:    push    h
  593.     call    dten
  594.     push    psw
  595.     mov    a,h
  596.     ora    l
  597.     cnz    tdhlzs;        recursive, next digit
  598.     pop    psw
  599.     pop    h
  600.     adi    '0'
  601.     call    couta
  602.     ret
  603. ;
  604. ; divide hl by 10, remainder to a
  605. ; a,f,h,l
  606. dten:    push    b
  607.     lxi    b,0f00ah;    c=divisor=10; b=iter.cnt=-16
  608.     xra    a;        clear
  609. dten1:    dad    h
  610.     ral;            shift off into a
  611.     cmp    c
  612.     jc    dten2;        no bit
  613.     sub    c;        bit=1
  614.     inx    h
  615. dten2:    inr    b
  616.     jm    dten1;        not done
  617.     pop    b
  618.     ret
  619. ;
  620. sort:    lhld    dirmaxplus1
  621.     shld    window
  622. sort1:    lhld    window
  623.     call    shlrt
  624.     shld    window;        window := window DIV 2
  625.     ora    h
  626.     rz
  627.     xchg
  628.     lhld    dirmaxplus1
  629.     dcx    h
  630.     mov    a,l
  631.     sub    e
  632.     mov    l,a
  633.     mov    a,h
  634.     sbb    d
  635.     mov    h,a
  636.     shld    top;        := n-1 - window
  637.     lxi    h,0
  638.     shld    bottom
  639. sort2:    shld    current
  640. sort3:    xchg
  641.     lhld    window
  642.     dad    d;        window+current
  643.     call    compare;    de=current, hl=window+current
  644.     jnc    sort4
  645.     call    trade
  646.     lhld    window
  647.     xchg
  648.     lhld    current
  649.     mov    a,l
  650.     sub    e
  651.     mov    l,a
  652.     mov    a,h
  653.     sbb    d
  654.     mov    h,a
  655.     shld    current;    := current - window
  656.     jm    sort4
  657.     ora    l
  658.     jnz    sort3
  659. sort4:    lhld    bottom
  660.     inx    h
  661.     shld    bottom
  662.     xchg
  663.     lhld    top
  664.     call    cmphlde
  665.     xchg
  666.     jnc    sort2
  667.     jmp    sort1
  668. ;
  669. cmphlde:
  670.     mov    a,h
  671.     cmp    d
  672.     rnz
  673.     mov    a,l
  674.     cmp    e
  675.     ret
  676. ;
  677. ; de=current, hl=window+current
  678. ; a,f,b,c,d,e,h,l
  679. compare:
  680.     dad    h
  681.     dad    h
  682.     dad    h
  683.     dad    h
  684.     dad    h
  685.     lxi    b,buffer
  686.     dad    b
  687.     xchg
  688.     dad    h
  689.     dad    h
  690.     dad    h
  691.     dad    h
  692.     dad    h
  693.     dad    b
  694.     mvi    b,15
  695.     push    d
  696.     push    h
  697. cp1:    ldax    d
  698.     cmp    m
  699.     jnz    cp2
  700.     inx    h
  701.     inx    d
  702.     dcr    b
  703.     jnz    cp1
  704. cp2:    pop    h;        rightentry
  705.     pop    d;        leftentry
  706.     ret;            for possible trade
  707.  
  708. trade:    mvi    c,dentsiz
  709. trade1:    mov    b,m
  710.     ldax    d
  711.     mov    m,a
  712.     mov    a,b
  713.     stax    d
  714.     inx    d
  715.     inx    h
  716.     dcr    c
  717.     jnz    trade1
  718.     ret
  719. ;
  720. ; right shift hl one place
  721. shlrt:    xra    a
  722.     mov    a,h
  723.     rar
  724.     mov    h,a
  725.     mov    a,l
  726.     rar
  727.     mov    l,a
  728.     ret
  729. ;
  730. ; Add time-stamping entries to directory image.  Every fourth entry
  731. ; becomes 021h, 0, .. 0 (32 total bytes).
  732. addstamps:
  733.     lhld    dirmaxplus1
  734.     mov    c,l
  735.     mov    b,h
  736.     lxi    h,buffer
  737. ; Move entries up and inject time stamp operation.
  738. addst1:    dcx    b
  739.     dcx    b
  740.     dcx    b;        3 entries
  741.     lxi    d,3 * dentsiz
  742.     dad    d;        point to entry to inject
  743. ; now move (bc) entries up by 32 bytes
  744.     xchg
  745.     lxi    h,dentsiz
  746.     dad    d
  747.     xchg;            hl = source, de = destination
  748.     dcx    b;        move 1 less entry
  749.     mov    a,b
  750.     ora    c
  751.     mov    a,m;        in case last entry
  752.     cnz    moveup;        leaves hl pointing to time entry
  753.     cpi    vacant
  754.     jnz    toomany;    discarding real entry, abort
  755.     call    inject;        a timestamp entry, blank
  756.     mov    a,b
  757.     ora    c
  758.     jnz    addst1;        do next entry
  759.     ret
  760. ;
  761. ; inject timestamp entry at hl^.  Advance hl past entry
  762. inject:    push    b
  763.     mvi    b,31
  764.     mvi    m,timark
  765. inj1:    inx    h
  766.     mvi    m,0
  767.     dcr    b
  768.     jnz    inj1
  769.     inx    h
  770.     pop    b
  771.     ret
  772. ;
  773. ; moveup hl^ to de^ for bc 32 byte entries
  774. moveup:    push    h
  775.     push    d
  776.     push    b
  777.     push    h
  778.     mov    l,c
  779.     mov    h,b
  780.     dad    h
  781.     dad    h
  782.     dad    h
  783.     dad    h
  784.     dad    h;        *32 = dentsiz
  785.     mov    c,l
  786.     mov    b,h;        bc is bytes to move
  787.     xchg
  788.     dad    b;        top + 1 destination
  789.     xchg
  790.     pop    h
  791.     dad    b;        top + 1 source
  792.     mov    a,m;        keep the discarded 1st byte
  793.     push    psw
  794. movup1:    dcx    h
  795.     dcx    d
  796.     mov    a,m
  797.     stax    d
  798.     dcx    b
  799.     mov    a,b
  800.     ora    c
  801.     jnz    movup1
  802.     pop    psw;        the discarded 1st byte
  803.     pop    b
  804.     pop    d
  805.     pop    h
  806.     ret
  807. ;
  808. ; check bc entries from hl^ up for existing time marks
  809. chkmk:    lhld    dirmaxplus1
  810.     mov    c,l
  811.     mov    b,h
  812.     lxi    h,buffer
  813. chkmk1:    mov    a,m
  814.     cpi    timark
  815.     jnz    chkmk4;        not a mark
  816.     lda    killmk
  817.     ora    a
  818.     lxi    d,oldmkmsg
  819.     jz    exeunt
  820.     mvi    m,vacant;    erase this entry
  821.     inx    h
  822.     mvi    m,vacant;    so sorts to high end
  823.     dcx    h
  824. chkmk4:    lxi    d,dentsiz
  825.     dad    d
  826.     dcx    b
  827.     mov    a,b
  828.     ora    c
  829.     jnz    chkmk1;        more
  830.     ret
  831. ;
  832. ; abort, too many directory entries to add timestamps
  833. toomany:
  834.     lxi    d,toomanymsg
  835.     jmp    exeunt
  836. ;
  837. help:
  838.     db    'usage: INITDIR d: [x:]'
  839.     db    cr,lf,
  840.     db    '(d is drive to sort/timestamp, '
  841.     db    'optional x: removes old timestamps)$'
  842. badvermsg:
  843.     db    cr,lf
  844.     db    'Run under DOS+ or CPM2.2 only$'
  845. toomanymsg:
  846.     db    cr,lf
  847.     db    'Too many files to add time-stamps, aborted$'
  848. oldmkmsg:
  849.     db    cr,lf
  850.     db    'Time stamps already present, aborted$'
  851. rdwrterrmsg:
  852.     db    cr,lf
  853.     db    'Read/Write Error!$'
  854. loading:
  855.     db    cr,lf
  856.     db    'Loading directory.$'
  857. sortdirmsg:
  858.     db    cr,lf
  859.     db    'Sorting directory.$'
  860. wrtdirmsg:
  861.     db    cr,lf
  862.     db    'Writing directory.$'
  863. statsmsg:
  864.     db    cr,lf,cr,lf
  865.     db    '  Disk Statistics'
  866.     db    cr,lf
  867.     db    'Possible entries : $'
  868. entriesmsg:
  869.     db    cr,lf
  870.     db    'Active entries   : $'
  871. delentriesmsg:
  872.     db    cr,lf
  873.     db    'Deleted entries  : $'
  874. usrsactivemsg:
  875.     db    cr,lf
  876.     db    'User area active : $'
  877. spaceusedmsg:
  878.     db    cr,lf
  879.     db    'Disk space used  : $'
  880. spacefreemsg:
  881.     db    cr,lf
  882.     db    'Disk space free  : $'
  883. pctfullmsg:
  884.     db    cr,lf
  885.     db    'Percent full     : $'
  886. percent:
  887.     db    '%$'
  888. signon:
  889.     db    cr,lf
  890.     db    'INITDIR (DOS+ time-stamps) Ver. '
  891.     db    ver / 10 + '0', '.', ver mod 10 + '0'
  892.     db    ' (c) 1986 C.B. Falconer'
  893.     db    cr,lf
  894.     db    '$'
  895. ;
  896. killmk:        ds    1;        flag remove old stamps
  897. ;
  898. drive:        ds    1
  899. secxltptr:    ds    2
  900. firstk:        ds    2;        1st storage track
  901. spt:        ds    2;        sectors per track
  902. dirmaxplus1:    ds    2;        dir entries available
  903. dirsectors:    ds    2;        sectors in whole directory
  904. ;
  905. ; sort vars
  906. top:        ds    2
  907. bottom:        ds    2
  908. window:        ds    2
  909. current:    ds    2
  910. ;
  911. track:        ds    2
  912. dircounter:    ds    2
  913. bsh:        ds    1
  914. blksused:    ds    1
  915. kbused:        ds    1
  916. dsmplus1:    ds    2
  917.         ds    100
  918. stack:        
  919. buffer:        ds    0;        the rest
  920.         end
  921. ╗╣