home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol147 / archive.a86 < prev    next >
Encoding:
Text File  |  1984-04-29  |  18.4 KB  |  845 lines

  1. ;********************************************************
  2. ;*                            *
  3. ;*    CP/M-86 ARCHIVE.A86 File Backup Utility        *
  4. ;*                            *
  5. ;*    See the August 1982 issue of LifeLines        *
  6. ;*    for full documentation on this program.        *
  7. ;*                            *
  8. ;********************************************************
  9. ;
  10. ;    Originally written by Kelly Smith, June 6, 1982
  11. ;
  12. ;    Published in Liflines/The Software Magazine
  13. ;    August 1982
  14. ;
  15. ;VERSION LIST, most recent version first
  16. ;
  17. ;24/Dec/82 Changed msgout routine to strip MSB of characters to
  18. ;       to be displayed, as some 8086 machines accept MSB of
  19. ;       char to display special or graphics characters (i.e.
  20. ;       NEC APC. Further changes to messages.
  21. ;       Version 1.1 Bill Bolton
  22. ;
  23. ;13/Aug/82 Numerous keying errors corrected, VERS and REV equates
  24. ;       added, header reformatted, some messages reformatted
  25. ;       and reworded. XLT86ed from CP/M-80 version. Bill Bolton
  26. ;
  27. ;09/Aug/82 Keyed in from Lifelines. MSGOUT subroutine added.
  28. ;       Steve Engel
  29. ;06/Jun/82 Orginal version. Kelly Smith
  30. ;
  31.     TITLE    'ARCHIVE Version 1.0'
  32. ;
  33. M    EQU    Byte Ptr 0[BX]        ;Xlt86's derived 'M'
  34. ;
  35. vers    EQU    11            ;Version number
  36. rev    EQU    'A'            ;Revision number
  37. ;
  38. true    EQU    -1
  39. false    EQU    not true
  40. mpm    EQU    false            ;conditional for mpm
  41. ;
  42. bdos    EQU    5            ;cpm entry point
  43. exit    EQU    0            ;cpm exit point
  44. dfcb    EQU    05ch            ;cpm default fcb
  45. fcbext    EQU    dfcb+12            ;fcb extent byte
  46. fcbrno    EQU    dfcb+32            ;fcb record number byte
  47. dbuff    EQU    80h            ;default buffer
  48. ;
  49. coninp    EQU    1            ;console input buffer
  50. pchar    EQU    2            ;print character
  51. dircon    EQU    6            ;direct console i/o
  52. pmessg    EQU    9            ;print message
  53. constat    EQU    11            ;console status
  54. version    EQU    12            ;return cp/m version number
  55. rsetdsk    EQU    13            ;reset disk system
  56. seldsk    EQU    14            ;select disk
  57. open    EQU    15            ;open file
  58. close    EQU    16            ;close file
  59. srchfst    EQU    17            ;search first
  60. srchnxt    EQU    18            ;search next
  61. delete    EQU    19            ;delete file
  62. read    EQU    20            ;read record
  63. write    EQU    21            ;write record
  64. make    EQU    22            ;make file
  65. currdsk    EQU    25            ;return current disk
  66. stdma    EQU    26            ;set dma address
  67. attrib    EQU    30            ;set file attribute
  68. ;
  69. tab    EQU    9
  70. lf    EQU    0ah
  71. cr    EQU    0dh
  72. ;
  73.     ORG    0100h
  74. ;
  75.     JMPS    over
  76. ;
  77.     DB    cr,lf,'Archive Version '
  78.     DB    vers/10 +'0','.',vers mod 10 +'0'
  79.     DB    rev
  80.     DB    ', Kelly Smith'
  81.     DB    cr,lf,'Z'-40h
  82. ;
  83. ;get current disk and save it
  84. ;
  85. over:
  86.     MOV    CL,currdsk        ;get function
  87.     INT    224
  88.     MOV    Byte Ptr logdsk,AL    ;save as logged disk
  89. ;
  90. ;reset disk system is case someone swapped a disk
  91. ;
  92.     MOV    CL,rsetdsk        ;get the function
  93.     INT    224
  94. ;
  95. ;now return to original logged disk
  96. ;
  97.     MOV    AL,Byte Ptr logdsk    ;get logged disk
  98.     MOV    DL,AL
  99.     MOV    CL,seldsk
  100.     INT    224
  101. ;
  102. ;announcing, the new improved ARCHIVE.
  103. ;
  104.     MOV    DX,(Offset signon)
  105.     CALL    msgout
  106. ;
  107. ;check for proper environment, we only live for CP/M-86 1.0 or later
  108. ;
  109.     MOV    CL,version
  110.     INT    224
  111.     CMP    AL,22h            ;correct version?
  112.     MOV    DX,(Offset bad@ver@num)
  113.     JZ    L_3            ;yes
  114.     JMP    arcexit            ;no, display error message
  115. L_3:
  116. ;
  117. ;
  118. ;check if filename specified, abort if not
  119. ;
  120.     MOV    AL,Byte Ptr .dfcb+1
  121.     CMP    AL,' '
  122.     JNZ    gotname            ;got a name ?
  123.     MOV    DX,(Offset no@file@nam)    ;inform user no filename
  124.     CALL    msgout
  125.     MOV    DX,(Offset opts)    ;tell 'em wot to do
  126.     JMPS    arcexit            ;bail out now-no name
  127. ;
  128. ;got a name,now check to see which (if any) disk specified
  129. ;
  130. gotname:
  131.     MOV    AL,Byte Ptr .dfcb    ;check for specific drive
  132.     DEC    AL
  133.     MOV    DL,AL            ;set up for select disk call
  134.     MOV    CL,seldsk
  135.     INC    AL            ;if no drive spec, skip call
  136.     MOV    Byte Ptr src@dsk@num,AL    ;save drive specifier for later
  137.     JZ    L_4    
  138.     INT    224
  139. L_4:
  140.     XOR    AL,AL            ;now zap out drive specifier
  141.     MOV    Byte Ptr .dfcb,AL
  142.     MOV    AL,'?'            ;force extent number wild
  143.     MOV    Byte Ptr .dfcb+12,AL
  144.     MOV    AL,Byte Ptr .dfcb+17    ;get option
  145.     MOV    Byte Ptr option,AL    ;and save for later
  146.     CMP    AL,'B'            ;backup ?
  147.     JZ    okopt
  148.     CMP    AL,'S'            ;set archive
  149.     JZ    okopt
  150.     CMP    AL,'R'            ;reset archive
  151.     JZ    okopt
  152.     CMP    AL,'D'            ;display archive
  153.     JZ    okopt
  154. ;
  155. badot:
  156.     MOV    DX,(Offset ilgopt)    ;point to bad option
  157. arcexit:
  158.     CALL    msgout
  159.     MOV    CL,0
  160.     MOV    DL,0
  161.     INT    224
  162. ;
  163. ;findout now, if operator is for backup or general lobotomy
  164. ;
  165. okopt:
  166.     MOV    AL,Byte Ptr option    ;get option back
  167.     CMP    AL,'B'
  168.     JNZ    arc@s@r            ;not backup, something else
  169. dest:
  170.     MOV    DX,(Offset req@dest)    ;ask for destination
  171.     CALL    msgout
  172.     MOV    CL,coninp        ;get console input
  173.     INT    224
  174.     AND    AL,05fh            ;force upper case
  175.     SBB    AL,'A'            ;force binary digit
  176.     CMP    AL,16            ;disk > 16
  177.     JNB    dest            ;must satisfy ourselves
  178.     MOV    BX,(Offset logdsk)    ;is this jerk backing up to
  179.                     ;same disk ?
  180.     AND    AL,0fh            ;strip high nibble
  181.     CMP    AL,M
  182.     LAHF                ;save flags
  183.     XCHG    AL,AH
  184.     PUSH    AX
  185.     XCHG    AL,AH
  186.     INC    AL            ;readjust disk number
  187.     MOV    Byte Ptr dest@dsk@num,AL
  188.     POP    AX
  189.     XCHG    AL,AH
  190.     SAHF
  191.     JZ    dsksame            ;if same, tell em' so now
  192.     INC    BX            ;bump pointer to dest disk
  193.     MOV    AL,M            ;get disk number
  194.     INC    BX            ;bump pointer to source disk
  195.     CMP    AL,M
  196.     JZ    L_5    
  197.     JMP    backup
  198. L_5:
  199. dsksame:
  200.     MOV    DX,(Offset same@dsk)    ;point to same disk messg
  201.     CALL    msgout
  202.     JMPS    dest
  203. ;
  204. ;ready for directory write operations now..do archive set/reset
  205. ;
  206. arc@s@r:
  207.     CALL    crlf
  208.     XOR    AL,AL            ;zero file count
  209.     MOV    Byte Ptr filcnt,AL
  210.     MOV    DX,dfcb
  211.     MOV    CL,srchfst
  212.     INT    224
  213.     INC    AL            ;search successfull ?
  214.     JNZ    gotfile            ;yes, proceed
  215.     MOV    DX,(Offset no@file@fnd)    ;point to error message
  216.     JMP    arcexit            ;print error and exit
  217. ;
  218. gotfile:
  219.     DEC    AL            ;for 'inr' above
  220.     ROR    AL,1
  221.     ROR    AL,1
  222.     ROR    AL,1
  223.     AND    AL,60h
  224.     MOV    BX,dbuff        ;point to base of buffer
  225.     MOV    CL,AL
  226.     MOV    CH,0
  227.     LAHF                ;index file by offset
  228.     ADD    BX,CX
  229.     RCR    SI,1
  230.     SAHF
  231.     RCL    SI,1
  232.     PUSH    BX            ;save dir entry
  233.     MOV    CX,(Offset filetable)    ;point to base of file table
  234.     CALL    filepoint        ;get table pointer into HL
  235.     XCHG    BX,DX            ;put it in DE instead
  236.     MOV    AL,Byte Ptr filcnt    ;keep track of number of files
  237.     INC    AL
  238.     MOV    Byte Ptr filcnt,AL
  239.     POP    BX            ;HL points to dir entry
  240.     MOV    CH,32
  241.     CALL    blkmov
  242. getnext:
  243.     MOV    CL,srchnxt        ;search for next
  244.     MOV    DX,dfcb
  245.     INT    224
  246.     INC    AL            ;returns 0ffh if at end of
  247.                     ;search
  248.     JNZ    gotfile            ;got another-go save it
  249. ;
  250. ;end of directory encountered - process now
  251. ;
  252. tagfile:
  253.     CALL    abort            ;check for user abort
  254.     MOV    CX,(Offset filetable)-32 ;allow for file count +1
  255.     CALL    filepoint
  256.     PUSH    BX
  257.     MOV    DX,dfcb            ;copy name to dfcb
  258.     MOV    CH,32
  259.     CALL    blkmov            ;move it
  260.     XOR    AL,AL
  261.     MOV    Byte Ptr .dfcb,AL    ;clear drive number
  262.     MOV    DX,-20            ;point back to extent field
  263.     LAHF
  264.     ADD    BX,DX
  265.     RCR    SI,1
  266.     SAHF
  267.     RCL    SI,1
  268.     MOV    M,'$'            ;tag end of print here
  269.     POP    DX            ;get back pointer to start
  270.     LAHF                ;bump forward to name
  271.     INC    DX
  272.     SAHF
  273.     CALL    msgout
  274.     MOV    DL,' '            ;space between name and ext
  275.     MOV    CL,pchar
  276.     INT    224
  277.     MOV    AL,Byte Ptr .dfcb+12    ;get extent number
  278.     LAHF                ;save it
  279.     XCHG    AL,AH
  280.     PUSH    AX
  281.     XCHG    AL,AH
  282.     ADD    AL,'0'            ;make ASCII
  283.     MOV    DL,AL
  284.     MOV    CL,pchar
  285.     POP    AX
  286.     INT    224
  287.     MOV    AL,Byte Ptr option    ;get otion back
  288.     CMP    AL,'D'            ;display only ?
  289.     JZ    nextfile
  290.     ROR    AL,1            ;bit 7=0 for B,R,D and 1 for S
  291.     AND    AL,80h
  292.     MOV    CH,AL            ;save mask
  293.     MOV    DX,dfcb+11        ;point to t3
  294.     MOV    SI,DX            ;get it
  295.     MOV    AL,[SI]
  296.     AND    AL,07fh            ;and strip it
  297.     OR    AL,CH            ;set if set option
  298.     MOV    SI,DX            ;and put it back
  299.     MOV    [SI],AL
  300.     MOV    DX,dfcb            ;point to start of fcb
  301.     XOR    AL,AL            ;zap out drive field
  302.     MOV    SI,DX
  303.     MOV    [SI],AL
  304.     MOV    CL,attrib        ;do set file attribute
  305.     INT    224
  306. ;
  307. nextfile:
  308.     MOV    AL,Byte Ptr .dfcb+11    ;get t3
  309.     ROL    AL,1            ;isolate t3
  310.     AND    AL,1
  311.     ADD    AL,'R'            ;make 'R' or 'S'
  312.     MOV    Byte Ptr donmsg+1,AL
  313.     MOV    DX,(Offset donmsg)
  314.     CALL    msgout            ;print completion message
  315. ;    call    crlf
  316.     MOV    BX,(Offset filcnt)    ;point to file counter
  317.     DEC    M            ;count it down
  318.     JNZ    L_6    
  319.     MOV    CL,0            ;exit if done
  320.     MOV    DL,0
  321.     INT    224
  322. L_6:
  323.     JMP    tagfile            ;tag next file
  324. ;
  325. ;backup routine - does mutiple file search and copy
  326. ;
  327. backup:
  328.     CALL    crlf
  329. noback:
  330.     CALL    abort            ;check for abort
  331.     CALL    mfname            ;set up multi-file search
  332.     JNB    movname            ;file found if no carry
  333.     MOV    AL,Byte Ptr mfflg1    ;check if anything ever found..
  334.     OR    AL,AL
  335.     MOV    DX,(Offset bakup@done)    ;set-up backup done message
  336.     JNZ    nofile            ;if not-indicate
  337.     MOV    AL,Byte Ptr got@arc    ;check archive found flag
  338.     OR    AL,AL
  339.     JZ    L_7    
  340.     JMP    arcexit            ;if not zero, must have found 1
  341. L_7:
  342.     MOV    DX,(Offset narcs)    ;indicate no arcive files found
  343.     JMP    arcexit            ;print message and exit
  344. ;
  345. nofile:
  346.     MOV    DX,(Offset no@file@fnd)    ;oops, file not found
  347.     JMP    arcexit
  348. ;
  349. movname:
  350.     MOV    BX,dfcb+11        ;point to t3 in fcb
  351.     MOV    AL,M            ;get it
  352.     ROL    AL,1            ;archive bit set
  353.     JB    noback            ;if so, no backup required
  354.     ROR    AL,1            ;adjust back to normal
  355.     MOV    Byte Ptr got@arc,AL    ;set archive file found flag
  356.     OR    AL,080h            ;set archived flag
  357.     MOV    M,AL            ;put it back
  358.     PUSH    BX            ;save pointer
  359.     MOV    DX,dfcb            ;point fcb
  360.     MOV    CL,attrib        ;make a set attributes
  361.     INT    224
  362.     POP    BX            ;restore pointer
  363.     DEC    BX            ;point to t2 in fcb
  364.     MOV    AL,M            ;get it
  365.     AND    AL,07fh            ;strip off t2
  366.     MOV    M,AL            ;put it back
  367.     DEC    BX            ;point to t1 in filename
  368.     MOV    AL,M            ;get t1 byte
  369.     AND    AL,07fh            ;strip it
  370.     MOV    M,AL            ;save it
  371.     MOV    BX,dfcb+1        ;point to filename for move
  372.     MOV    DX,(Offset fname)    ;display dest for filename
  373.     MOV    CH,8            ;setup 8 for mve
  374.     CALL    blkmov            ;and move it
  375.     MOV    DX,(Offset fname)+9    ;point to ext
  376.     MOV    CH,3
  377.     CALL    blkmov
  378. dspname:
  379.     MOV    DX,(Offset fname)    ;display name and filetype
  380.     CALL    msgout
  381. ;
  382. ;save first fcb for user later as destination filename
  383. ;
  384.     MOV    CH,11            ;number of chars to move
  385.     MOV    BX,dfcb+1        ;from here
  386.     MOV    DX,(Offset destfcb)+1    ;to here
  387.     CALL    blkmov            ;move em'
  388. ;
  389. ;open the source file
  390. ;
  391.     MOV    AL,Byte Ptr logdsk    ;select the disk
  392.     MOV    DL,AL
  393.     MOV    CL,seldsk
  394.     INT    224
  395.     MOV    DX,dfcb
  396.     MOV    CL,open            ;make an open call
  397.     INT    224
  398.     CMP    AL,0ffh            ;file not found ?
  399.     JNZ    openok
  400.     MOV    DX,(Offset src@open@err)    ;oops, source file open error
  401.     JMP    arcexit
  402. ;
  403. ;open the destination file
  404. ;
  405. openok:
  406.     MOV    DX,(Offset destfcb)    ;point to destination fcb
  407.     MOV    AL,Byte Ptr dest@dsk@num    ;get dest disk #
  408.     MOV    SI,DX            ;put it in the fcb
  409.     MOV    [SI],AL
  410.     MOV    CL,delete        ;erase any old file
  411.     INT    224
  412.     MOV    DX,(Offset destfcb)
  413.     MOV    CL,make
  414.     INT    224            ;make the new one
  415.     CMP    AL,0ffh            ;all ok ?
  416.     JNZ    L_8    
  417.     JMP    full
  418. L_8:
  419. ;
  420. ;read source file to buffer, write to destination file
  421. ;
  422. copy:
  423.     MOV    BX,((Offset table@end)-(Offset filetable))/128    ;save buffer size
  424.     MOV    Word Ptr bufmax,BX
  425.     XOR    AL,AL            ;clear eof flag
  426.     MOV    Byte Ptr eof@flg,AL
  427. copy1:
  428.     CALL    abort            ;check for user abort
  429.     MOV    BX,0            ;set current counter to 0
  430.     MOV    Word Ptr bufcnt,BX
  431.     MOV    BX,(Offset filetable)    ;set buffer start pointer
  432.     MOV    Word Ptr bufpnt,BX
  433. ;
  434. ;file source reading loop to read all of buffer full or stop on
  435. ;eof
  436. ;
  437. copy2:
  438.     MOV    BX,Word Ptr bufpnt    ;set dma address to buffer pntr
  439.     XCHG    BX,DX
  440.     MOV    CL,stdma
  441.     INT    224
  442.     MOV    DX,dfcb            ;point at default fcb for reading
  443.     MOV    CL,read            ;make a read
  444.     INT    224
  445.     OR    AL,AL            ;check if read was ok or eof
  446.     JNZ    copy3            ;end of file
  447.     MOV    BX,Word Ptr bufpnt    ;set buffer pntr up 1 sector
  448.     MOV    DX,128
  449.     LAHF
  450.     ADD    BX,DX
  451.     RCR    SI,1
  452.     SAHF
  453.     RCL    SI,1
  454.     MOV    Word Ptr bufpnt,BX
  455.     MOV    BX,Word Ptr bufcnt    ;increase buffer sector count
  456.     LAHF
  457.     INC    BX
  458.     SAHF
  459.     MOV    Word Ptr bufcnt,BX
  460.     XCHG    BX,DX
  461.     MOV    BX,Word Ptr bufmax    ;maximum sector count
  462.     CALL    cdehl            ;compare
  463.     JNZ    copy2
  464.     JMPS    copy4
  465. ;
  466. ;here if read operation indicates file is at end on read
  467. ;
  468. copy3:
  469.     MOV    AL,0ffh            ;set eof flag
  470.     MOV    Byte Ptr eof@flg,AL
  471. ;
  472. ;write operation pro cessing loop to send mem to disk file
  473. ;
  474. copy4:
  475.     MOV    BX,(Offset filetable)    ;point to byffer
  476.     MOV    Word Ptr bufpnt,BX
  477. copy5:
  478.     CALL    abort            ;check for abort
  479.     MOV    BX,Word Ptr bufcnt    ;see if buffer is empty
  480.     MOV    AL,BH
  481.     OR    AL,BL
  482.     JZ    copy6            ;buffer empty so check eof flag
  483.     DEC    BX            ;dec buffer sector count
  484.     MOV    Word Ptr bufcnt,BX
  485.     MOV    BX,Word Ptr bufpnt    ;set up buffer pointer
  486.     PUSH    BX            ;save for size bump
  487.     XCHG    BX,DX
  488.     MOV    CL,stdma
  489.     INT    224
  490.     POP    BX
  491.     MOV    DX,128            ;increase by 1 sector size
  492.     ADD    BX,DX
  493.     MOV    Word Ptr bufpnt,BX
  494.     MOV    DX,(Offset destfcb)    ;point to dstination fcb
  495.     MOV    CL,write        ;make a write record
  496.     INT    224
  497.     OR    AL,AL            ;any errors ?
  498.     JZ    copy5            ;no-continue
  499.     JMPS    full            ;yes-disk maybe full
  500. ;
  501. copy6:
  502.     MOV    AL,Byte Ptr eof@flg    ;buffer all written, go and
  503.                     ;check eof
  504.     OR    AL,AL
  505.     JNZ    L_9
  506.     JMP    copy1
  507. L_9:
  508.     MOV    DX,(Offset destfcb)    ;point to destination fcb
  509.     MOV    CL,close        ;close file
  510.     INT    224
  511.     CMP    AL,0ffh            ;all Ok
  512.     JZ    L_10
  513.     JMP    backup            ;yes-continue
  514. L_10:
  515.     MOV    DX,(Offset src@close@err)    ;no-close error
  516.     JMP    arcexit
  517. ;
  518. ; subroutine to compare [DE] to [HL],  [Z] set if equal
  519.  
  520. cdehl:
  521.     MOV    AL,DH            ;high byte equal ?
  522.     CMP    AL,BH
  523.     JZ    L_11
  524.     RET
  525. L_11:
  526.     MOV    AL,DL            ;yes-how about low byte
  527.     CMP    AL,BL
  528.     RET                ;set zero if equal
  529. ;
  530. ;subroutine to allow disk change, to continue backup proceedure
  531. ;
  532. full:
  533.     MOV    DX,(Offset destfcb)    ;delete partial file
  534.     MOV    CL,delete
  535.     INT    224
  536.     MOV    DX,(Offset dsk@full)    ;indicate disk is full
  537.     CALL    msgout
  538.     MOV    AL,Byte Ptr dest@dsk@num    ;get dest disk number
  539.     ADD    AL,040h            ;make it ASCII
  540.     MOV    DL,AL
  541.     MOV    CL,pchar
  542.     INT    224
  543.     MOV    DX,(Offset now@full)    ;display remainder of message
  544.     CALL    msgout
  545. req@cnt:
  546.     MOV    DX,(Offset enter@ret)    ;tell em' to remove disk and
  547.                     ;hit return
  548.     CALL    msgout
  549.     MOV    CL,coninp
  550.     INT    224
  551.     CMP    AL,cr            ;cr ?
  552.     JNZ    req@cnt            ;if not ask again
  553.     CALL    crlf
  554.     MOV    CL,rsetdsk        ;make a reset disk system
  555.     INT    224
  556.     CALL    reset@fcb        ;also reset the fcb
  557.     JMP    dspname            ;continue on new disk, with
  558.                     ;last file
  559. ;
  560. ;Multi-file access subroutine. Allows processing of multiple
  561. ;files (i.e. *.*) from disk. This routine builds the proper
  562. ;name in the fcb each time it is called. Carry is set if no
  563. ;more names can be found.
  564. ;
  565. mfname:
  566.     MOV    CL,stdma        ;set dma address
  567.     MOV    DX,dbuff
  568.     INT    224
  569.     XOR    AL,AL            ;clear fcb extention and rec #
  570.     MOV    Byte Ptr .fcbext,AL
  571.     MOV    Byte Ptr .fcbrno,AL
  572.     MOV    AL,Byte Ptr mfflg1    ;get multi-file flag
  573.     OR    AL,AL
  574.     JZ    mfile1            ;if zero, not first time flag
  575.     MOV    BX,dfcb            ;save filename as requestd name
  576.     MOV    DX,(Offset mfreq)
  577.     MOV    CH,12
  578.     CALL    blkmov
  579.     MOV    AL,Byte Ptr .dfcb
  580.     MOV    Byte Ptr mfcur,AL    ;save disk in current fcb
  581.     MOV    BX,(Offset mfreq)    ;set-up for filename search
  582.     MOV    DX,dfcb
  583.     MOV    CH,12
  584.     CALL    blkmov
  585.     MOV    CL,srchfst        ;search for 1st match
  586.     MOV    DX,dfcb
  587.     INT    224
  588.     JMPS    mfile2            ;check if file found
  589. ;
  590. mfile1:
  591.     MOV    BX,(Offset mfcur)    ;search first on current name
  592.     MOV    DX,dfcb
  593.     MOV    CH,12
  594.     CALL    blkmov
  595.     MOV    CL,srchfst
  596.     MOV    DX,dfcb
  597.     INT    224
  598.     MOV    BX,(Offset mfreq)    ;do search on filename
  599.     MOV    DX,dfcb
  600.     MOV    CH,12
  601.     CALL    blkmov
  602.     MOV    CL,srchnxt        ;make a search next
  603.     MOV    DX,dfcb
  604.     INT    224
  605. mfile2:
  606.     INC    AL            ;return carry set if file not
  607.     STC                ;found
  608.     JNZ    L_12
  609.     RET
  610. L_12:
  611. ;
  612. ;move name found to current filename
  613. ;
  614.     DEC    AL            ;adjust location found
  615.     AND    AL,3
  616.     ADD    AL,AL
  617.     ADD    AL,AL
  618.     ADD    AL,AL
  619.     ADD    AL,AL
  620.     ADD    AL,AL
  621.     ADD    AL,81h
  622.     MOV    BL,AL            ;make filename pointer
  623.     MOV    BH,0
  624.     PUSH    BX            ;save pointer
  625.     MOV    DX,(Offset mfcur)+1
  626.     MOV    CH,11
  627.     CALL    blkmov            ;move name to current filename
  628. ;
  629. ;move filename found to fcb
  630. ;
  631.     POP    BX            ;restore filename pointer
  632.     MOV    DX,dfcb+1
  633.     MOV    CH,11
  634.     CALL    blkmov
  635. ;
  636. ;setup fcb for subsequent file write operation
  637. ;
  638. reset@fcb:
  639.     MOV    DX,dfcb            ;point to source fcb
  640.     MOV    AL,Byte Ptr src@dsk@num    ;force disk #, in case not
  641.     MOV    SI,DX            ;logged disk
  642.     MOV    [SI],AL
  643.     XOR    AL,AL            ;clean up for new file backup
  644.     MOV    Byte Ptr .fcbext,AL
  645.     MOV    Byte Ptr .fcbrno,AL
  646.     MOV    Byte Ptr destfcb,AL
  647.     MOV    Byte Ptr destfcb+12,AL
  648.     MOV    Byte Ptr destfcb+32,AL
  649.     MOV    Byte Ptr mfflg1,AL    ;turn off 1st time flag
  650.     RET
  651. ;
  652. ;subroutine to perform a block move (aahh for a Z-80)
  653. ;
  654. blkmov:
  655.     MOV    AL,M            ;copy byte from [HL] to [DE]
  656.     MOV    SI,DX
  657.     MOV    [SI],AL
  658.     LAHF
  659.     INC    BX
  660.     SAHF
  661.     LAHF
  662.     INC    DX
  663.     SAHF
  664.     DEC    CH
  665.     JNZ    blkmov            ;continue for B bytes
  666.     RET
  667. ;
  668. ;subroutine to index [BC] by file counter
  669. ;
  670. filepoint:
  671.     MOV    BX,Word Ptr filcnt    ;get file counter
  672.     MOV    BH,0            ;force high order to 0
  673.     SHL    BX,1            ;multiply by 32
  674.     SHL    BX,1
  675.     SHL    BX,1
  676.     SHL    BX,1
  677.     SHL    BX,1
  678.     LAHF                ;use as index to file table
  679.     ADD    BX,CX
  680.     RCR    SI,1
  681.     SAHF
  682.     RCL    SI,1
  683.     RET
  684. ;
  685. ;subroutine to check for user abort (control C)
  686. ;
  687. abort:
  688.     PUSH    BX            ;save all regs
  689.     PUSH    DX
  690.     PUSH    CX
  691.     LAHF
  692.     XCHG    AL,AH
  693.     PUSH    AX
  694.     XCHG    AL,AH
  695.     MOV    CL,dircon        ;make a direct console I/O
  696.     MOV    DL,0ffh            ;input only
  697.     INT    224
  698.     OR    AL,AL            ;set flags
  699.     JZ    abortx            ;return if zero result
  700.     CMP    AL,'C'-040h        ;control-c ?
  701.     JNZ    abortx            ;no-return
  702.     MOV    DX,(Offset abort@process)    ;point to proper message
  703.     CALL    msgout
  704.     MOV    CL,0
  705.     MOV    DL,0
  706.     INT    224
  707. ;
  708. abortx:
  709.     POP    AX
  710.     XCHG    AL,AH
  711.     SAHF
  712.     POP    CX
  713.     POP    DX
  714.     POP    BX
  715.     RET
  716. ;
  717. ;subroutine to print a crlf
  718. ;
  719. crlf:
  720.     MOV    DX,(Offset crlf@msg)
  721. ;
  722. ;subroutine to print out a message pointed to by DX
  723. ;
  724. msgout:
  725.     PUSH    DX            ;might need pointer again
  726.     MOV    SI,DX
  727. mloop:
  728.     MOV    AL,[SI]            ;get char from string
  729.     AND    AL,07fh            ;strip off high bit
  730.     CMP    AL,'$'            ;string terminator?
  731.     JZ    mdone            ;Yes, exit
  732.     MOV    DL,AL
  733.     MOV    CL,pchar        ;No, display it
  734.     INT    224
  735.     INC    SI            ;point to next char in string
  736.     JMP    mloop
  737. ;
  738. mdone:
  739.     POP    DX
  740.     RET
  741. ;
  742. ;
  743. signon        DB    cr,lf,'Archive Version '
  744.         DB    vers/10 + '0','.',vers mod 10 + '0'
  745.         DB    rev
  746.         DB    cr,lf
  747.         DB    'CP/M-86 File BACK UP utility.'
  748.         DB    cr,lf,cr,lf,'$'
  749. ;
  750. ilgopt        DB    'Invalid or Unspecified option - must be'
  751.         DB    ' specified as:',cr,lf,cr,lf
  752. opts        DB    tab,'B - Backup file(s) with Archive flag set or,'
  753.         DB    cr,lf
  754.         DB    tab,'S - Set Archive flag on file(s) or,'
  755.         DB    cr,lf
  756.         DB    tab,'R - Reset Archive flag on file(s) or,'
  757.         DB    cr,lf
  758.         DB    tab,'D - Display state of Archive flag on file(s)'
  759.         DB    cr,lf,'$'
  760. ;
  761. no@file@fnd    DB    cr,lf,'File not found, aborting$'
  762. ;
  763. donmsg        DB    ' $'
  764. ;
  765. crlf@msg    DB    cr,lf,'$'
  766. ;
  767. bad@ver@num    DB    'Sorry, you MUST have CP/M-86 Version 1.0 or later to use ARCHIVE.$'
  768. ;
  769. req@dest    DB    'Destination disk for files to be BACKED UP (A to P)? $'
  770. ;
  771. same@dsk    DB    cr,lf,'You can''t BACK UP files to the Source disk!'
  772.         DB    cr,lf,'$'
  773. ;
  774. abort@process    DB    cr,lf,'User abort of BACK UP process$'
  775. ;
  776. narcs        DB    cr,lf,'No files with Archive flag set were found to BACK UP$'
  777. ;
  778. no@file@nam    DB    'No filename or Option specified - '
  779.         DB    'ARCHIVE must be invoked as:'
  780.         DB    cr,lf,cr,lf
  781.         DB    tab,'ARCHIVE FN.FT OPTION <CR>'
  782.         DB    cr,lf,cr,lf
  783.         DB    'Where:',tab,'FN.FT is the filename'
  784.         DB    ' and filetype'
  785.         DB    cr,lf,cr,lf
  786.         DB    'And:',tab,'OPTION is specified as:'
  787.         DB    cr,lf,cr,lf,'$'
  788. ;
  789. src@open@err    DB    cr,lf,'Oops, Can''t open file on'
  790.         DB    ' Source disk$'
  791. ;
  792. dsk@full    DB    cr,lf,'Destination BACK UP disk $'
  793. ;
  794. now@full    DB    ': is now full - Remove and insert new Disk$'
  795. ;
  796. enter@ret    DB    cr,lf,'Enter RETURN when ready to continue'
  797.         DB    ' BACK UP process: $'
  798. ;
  799. src@read@err    DB    cr,lf,'CP/M-86 File Read ERROR on Source disk$'
  800. ;
  801. src@close@err    DB    cr,lf,'CP/M-86 File Close ERROR on Destination disk$'
  802. ;
  803. bakup@done:
  804.     DB    cr,lf,'BACK UP Complete, Exiting to CP/M-86',cr,lf,'$'
  805. ;
  806. fname    DB    '            $'        ;for filename.typ
  807. ;
  808. got@arc        DB    0        ;archive file found flag
  809. ;
  810. mfflg1        DB    1        ;1st time flag for mf access
  811. ;
  812. mfreq        RS    12        ;mf requested filename
  813. ;
  814. mfcur        RS    12        ;mf current filename
  815. ;
  816. arch@addr    RS    2        ;archive patch address
  817. ;
  818. logdsk        RS    1        ;current logged disk
  819. ;
  820. dest@dsk@num    RS    1        ;dest disk number
  821. ;
  822. src@dsk@num    RS    1        ;source disk number
  823. ;
  824. filcnt        RS    1        ;count of files in filetable
  825. ;
  826. option        RS    1        ;option storage location
  827. ;
  828. destfcb        RS    33        ;destination fcb
  829. ;
  830. bufmax        RS    2        ;maximum buffer size
  831. ;
  832. bufcnt        RS    2        ;buffer sector count
  833. ;
  834. bufpnt        RS    2        ;buffer pointer
  835. ;
  836. eof@flg        RS    1        ;end-of-file flag
  837. ;
  838. filetable EQU    (Offset $)        ;file buffer space
  839.         RS    4*4096        ;buffer-up 16k
  840. ;
  841. table@end    DB    0        ;filetable end address
  842. ;
  843.     END
  844.