home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol050 / stscopy < prev    next >
Encoding:
Text File  |  1984-04-29  |  18.8 KB  |  1,013 lines

  1. ;Stscopy - Data Technology Corporation CP/M 2.2 Stscopy.
  2. ;
  3. ;    +-----------------------+
  4. ;    |            |
  5. ;    |     S T S C O P Y     |
  6. ;    |            |
  7. ;    +-----------------------+
  8. ;
  9. ;
  10. ;    Version number:    2.1
  11. ;    Version date:    April 16, 1981
  12. ;
  13. ;    Update date:    May 26, 1981
  14. ;            Clear FCB before OPEN for verify.
  15.  
  16. ;    Update date:    June 16, 1981
  17. ;            Initialize DTCBIOS.
  18. ;
  19. ;    The following code is supplied to customers who
  20. ;    purchase a hard/floppy disk system from DTC.
  21. ;    Type STSCOPY HELP cr for instructions on usage.
  22. ;
  23.  
  24.  
  25.  
  26.  
  27. VERS:    EQU    21
  28.  
  29. CR:    EQU    0Dh        ;ASCII carrriage return
  30. LF:    EQU    0Ah        ;ASCII line feed
  31. TAB:    EQU    9        ;ASCII HORIZONTAL TAB
  32. EOS:    EQU    '$'        ;BDOS End of string
  33. ERRCD:    EQU    0FFh        ;BDOS error code
  34.  
  35.  
  36.  
  37. ;    BDOS function equates.
  38.  
  39. PRTSTR:    EQU    09    ;Print String    DE = buffer address.
  40. RDCB:    EQU    10    ;Read console buffer   DE = buffer address.
  41. INIT:    EQU    13    ;Initialize BDOS
  42. SELECT:    EQU    14    ;Select disk drive,    DE = drive number
  43. OPEN:    EQU    15    ;Open file   DE = FCB address.
  44. CLOSE:    EQU    16    ;Close file,    DE = FCB
  45. SFIRST:    EQU    17    ;Search for first occurrence,    DE = FCB
  46. SNEXT:    EQU    18    ;Search for next occurrence,    DE = FCB
  47. DELETE:    EQU    19    ;Delete file,    DE = FCB
  48. READS:    EQU    20    ;Read sequential file    DE = FCB.
  49. WRITES:    EQU    21    ;Write sequential file,    DE = FCB.
  50. CREATE:    EQU    22    ;Create file,    DE = FCB.
  51. RENAME:    EQU    23    ;Rename file,    DE = FCB.
  52. IDRIVE:    EQU    25    ;Interrogate drive
  53. SETDMA:    EQU    26    ;Set DMA address    DE = DMA address.
  54.  
  55. ;    Page zero locations.
  56.  
  57. WBOOT:    EQU    0    ;Warm boot jump address.
  58. BDOSV:    EQU    5    ;BDOS jump address.
  59. CPMFCB:    EQU    005Ch    ;Default FCB address.
  60. DBUF:    EQU    0080h    ;Default DMA buffer.
  61.  
  62.  
  63.  
  64.     
  65.  
  66.  
  67.  
  68.  
  69.     ORG    100h
  70.  
  71. STSCOPY:
  72.     PUSH    PSW
  73.     PUSH    B
  74.     PUSH    D
  75.     PUSH    H
  76.     LXI    H,0
  77.     DAD    SP
  78.     SHLD    SYSTK        ;save system stack
  79.  
  80.  
  81.     LXI    SP,STACK
  82.     MVI    C,IDRIVE    ;Save original drive number
  83.     CALL    BDOSV
  84.     STA    ODRIVE
  85.     CALL    HELPCK        ;Check for user help request.
  86.     CALL    GFILEN        ;Get file name
  87.     CALL    SKIPF        ;Skip do not care sectors
  88.     CALL    RCPM        ;Read CP/M
  89.     CALL    RBIOS        ;Read BIOS
  90.     CALL    SYSINI        ;Initialize destination system
  91. STSCO1:
  92.     CALL    COMMAND        ;Do keyboard commands
  93.     CALL    COPY        ;Copy files
  94.     JMP    STSCO1
  95.  
  96. ;    Return to system gracefully.
  97.  
  98. SYSRET:
  99.     LDA    ODRIVE        ;Restore original drive selection
  100.     MOV    E,A
  101.     MVI    D,0
  102.     MVI    C,SELECT
  103.     CALL    BDOSV
  104.     LHLD    SYSTK
  105.     SPHL
  106.     POP    H
  107.     POP    D
  108.     POP    B
  109.     POP    PSW
  110.     RET            ;return to system
  111.  
  112.  
  113.  
  114.  
  115.  
  116. ;    GFILEN - Get file name and open the file.
  117. ;
  118. ;    ENTRY    loaction 5C = filename.
  119.  
  120. GFILEN:
  121.     LXI    D,FCB        ;Initialize FCB
  122.     CALL    INIFCB
  123.     LXI    H,CPMFCB
  124.     LXI    D,FCB
  125.     LXI    B,12
  126.     CALL    MOVDTA        ;Move file name to FCB
  127.  
  128.     LXI    D,FCB
  129.     MVI    C,OPEN
  130.     CALL    BDOSV        ;Open the file
  131.     CPI    ERRCD
  132.     RNZ            ;If no error
  133.  
  134.     LXI    D,OPNERR
  135.     MVI    C,PRTSTR
  136.     CALL    BDOSV
  137.     JMP    SYSRET
  138.  
  139. OPNERR:    DB    CR,LF,'Error on file open.',CR,LF,EOS
  140.  
  141.  
  142.  
  143. ;    SKIPF - Skip meaningless sectors and boot sector on file.
  144.  
  145.  
  146. SKIPF:
  147.     LXI    D,DBUF
  148.     MVI    C,SETDMA
  149.     CALL    BDOSV        ;Set DMA address to default buffer
  150.  
  151.     MVI    A,17        ;Skip 17 sectors
  152. SKPF1:    PUSH    PSW
  153.     LXI    D,FCB
  154.     MVI    C,READS
  155.     CALL    BDOSV        ;Read a sector
  156.     CPI    ERRCD
  157.     JZ    SKPF2        ;If error on read
  158.     POP    PSW
  159.     DCR    A
  160.     JNZ    SKPF1        ;If 16 sectors not read
  161.     RET
  162.  
  163. SKPF2:    LXI    D,SKERR
  164.     MVI    C,PRTSTR
  165.     CALL    BDOSV        ;Output error message
  166.     JMP    SYSRET
  167.  
  168. SKERR:    DB    CR,LF,'File read error sectors 0 thru 15.'
  169.     DB    CR,LF,EOS
  170.  
  171.  
  172.  
  173. ;    RCPM - Read CPM sectors.
  174.  
  175. RCPM:
  176.     MVI    A,22*2
  177.     LXI    D,CCP
  178. RCPM1:    PUSH    PSW
  179.     PUSH    D        ;Save buffer address
  180.     MVI    C,SETDMA
  181.     CALL    BDOSV        ;Set DMA address to default buffer
  182.  
  183.     LXI    D,FCB
  184.     MVI    C,READS
  185.     CALL    BDOSV        ;Read a sector
  186.     CPI    ERRCD
  187.     JZ    RCPM2        ;If error on read
  188.     POP    D
  189.     LXI    H,128
  190.     DAD    D
  191.     XCHG
  192.     POP    PSW
  193.     DCR    A
  194.     JNZ    RCPM1        ;If 22*2 sectors not read
  195.     RET
  196.  
  197. RCPM2:    LXI    D,RCERR
  198.     MVI    C,PRTSTR
  199.     CALL    BDOSV        ;Output error message
  200.     JMP    SYSRET
  201.  
  202. RCERR:    DB    CR,LF,'File read error in CPM sectors (17 thru 60).'
  203.     DB    CR,LF,EOS
  204.     RET
  205.  
  206.  
  207.  
  208.  
  209. ;    RBIOS - Read BIOS sectors.
  210.  
  211. RBIOS:
  212.     LXI    D,CBIOS
  213. RBIOS1:    PUSH    D        ;Save buffer address
  214.     MVI    C,SETDMA
  215.     CALL    BDOSV        ;Set DMA address to default buffer
  216.  
  217.     LXI    D,FCB
  218.     MVI    C,READS
  219.     CALL    BDOSV        ;Read a sector
  220.     POP    D
  221.     LXI    H,128
  222.     DAD    D
  223.     XCHG
  224.     ORA    A
  225.     JZ    RBIOS1        ;If no errors
  226.  
  227.     RET
  228.  
  229.  
  230. ;    COMMAND - keyboard command processor
  231. ;
  232. COMMAND:
  233.     LXI    D,PROMPT    ;show prompt
  234. COM1:    CALL    INFCRT
  235.     LXI    H,INBUFX+1    ;Get count
  236.     MOV    C,M
  237.     INX    H        ;Point to first character
  238.     MOV    A,C
  239.     ORA    A
  240.     JZ    SYSRET
  241.     LXI    D,DFCB        ;Parse for destination
  242.     CALL    PARSE
  243.     CPI    ERRCD        ;Valid descriptor?
  244.     JZ    COM2
  245.     MOV    A,B        ;Yes. Save destination drive
  246.     STA    DDRIVE
  247.     MOV    A,C        ;End of command?
  248.     ORA    A
  249.     JZ    COM2
  250.     MVI    A,'='        ;No. Correct format?
  251.     CMP    M
  252.     JNZ    COM2
  253.     INX    H        ;Yes. Skip separator
  254.     DCR    C
  255.     JZ    COM2
  256.     LXI    D,SFCB        ;Parse for source
  257.     CALL    PARSE
  258.     CPI    ERRCD        ;Valid descriptor?
  259.     JZ    COM2
  260.     MOV    A,B        ;Yes. Save source drive
  261.     STA    SDRIVE
  262.     LXI    H,SFCB+1    ;Check for wild cards
  263.     MVI    B,11
  264.     MVI    A,'?'
  265. COM3:
  266.     CMP    M
  267.     JZ    COM4
  268.     INX    H
  269.     DCR    B
  270.     JNZ    COM3
  271. COM4:    MOV    A,B        ;Set wild card flag
  272.     STA    WILD
  273.     RET
  274. COM2:    LXI    D,INVMSG
  275.     JMP    COM1
  276.  
  277.  
  278. INVMSG:    DB    CR,LF,'Invalid command.'
  279. PROMPT:    DB    CR,LF,'*',EOS
  280.  
  281.  
  282.  
  283. ;    COPY - Copy selected source system files to destination system
  284. ;
  285. COPY:
  286.     LXI    D,COPMSG    ;If wild cards, print header.
  287.     MVI    C,PRTSTR
  288.     LDA    WILD
  289.     ORA    A
  290.     CNZ    BDOSV
  291.     LDA    SDRIVE        ;Select source drive
  292.     CPI    ERRCD        ;  if specified.
  293.     JZ    COPY1
  294.     MOV    E,A
  295.     MVI    D,0
  296.     MVI    C,SELECT
  297.     CALL    BDOSV
  298.     CPI    ERRCD
  299.     JNZ    COPY1
  300.  
  301.     LXI    D,COPYM1    ;Select error
  302. COPYER:    MVI    C,PRTSTR    ;Print error message
  303.     CALL    BDOSV
  304.     MVI    A,ERRCD        ;Return error code
  305.     RET
  306.  
  307. COPY1:                ;Search for source file
  308.     XRA    A        ;Initialize search occurrence
  309.     STA    SRCOCC
  310.  
  311. COPYS:    MVI    B,0        ;Clear search count
  312.     LDA    SRCOCC
  313.     MOV    C,A
  314.     INR    A        ;Increment occurrence count
  315.     STA    SRCOCC
  316.     PUSH    B        ;Save counts
  317.     LXI    D,SFCB        ;Search for first occurrence
  318.     MVI    C,SFIRST
  319.     CALL    BDOSV
  320.     POP    B        ;Restore counts
  321.     CPI    ERRCD
  322.     JNZ    COPYS1
  323.     LXI    D,COPYM2    ;File not found.
  324.     JMP    COPYER
  325.  
  326. COPYS1:    MOV    A,B        ;This occurrence?
  327.     CMP    C
  328.     JZ    COPYS2
  329.     INR    B        ;No. increment search count
  330.     PUSH    B        ;Save counts
  331.     LXI    D,SFCB        ;Search for next occurrence
  332.     MVI    C,SNEXT
  333.     CALL    BDOSV
  334.     POP    B        ;Restore counts
  335.     CPI    ERRCD
  336.     MVI    A,0
  337.     RZ            ;Found all occurrences.
  338.     JMP    COPYS1
  339.  
  340. COPYS2:    DAD    H        ;HL=entry number, DE=end of dir. buffer
  341.     DAD    H        ;*32 for entry offset
  342.     DAD    H
  343.     DAD    H
  344.     DAD    H
  345.     DAD    D        ;Add directory pointer
  346.     LXI    D,-128        ;relative to beginning of dir. buffer
  347.     DAD    D
  348.     LXI    D,SFFCB
  349.     LXI    B,32
  350.     CALL    MOVDTA
  351.     XRA    A        ;Clear next record number
  352.     STAX    D
  353.     LDA    WILD        ;If wild cards, print file name.
  354.     ORA    A
  355.     JZ    COPYS3
  356.     LXI    H,SFFCB+1
  357.     LXI    D,FN
  358.     LXI    B,8
  359.     CALL    MOVDTA
  360.     INX    D        ;Skip '.'
  361.     LXI    B,3
  362.     CALL    MOVDTA
  363.     LXI    D,FNMSG
  364.     MVI    C,PRTSTR
  365.     CALL    BDOSV
  366. COPYS3:
  367.     LXI    D,SFFCB        ;Open source file
  368.     MVI    C,OPEN
  369.     CALL    BDOSV
  370.     LXI    D,COPYM3
  371.     CPI    ERRCD
  372.     JZ    COPYER
  373.  
  374. COPYR:    XRA    A        ;clear continuation flag
  375.     STA    CFLAG
  376.     LXI    D,BUFFER    ;Set buffer pointer
  377.     LXI    B,0        ;Clear file record count.
  378.  
  379. COPYR1:    PUSH    B        ;Read a record
  380.     PUSH    D
  381.     MVI    C,SETDMA
  382.     CALL    BDOSV
  383.     LXI    D,SFFCB
  384.     MVI    C,READS
  385.     CALL    BDOSV
  386.     POP    D        ;Restore buffer pointer
  387.     POP    B        ;Restore record count
  388.     CPI    0        ;Done?
  389.     JNZ    COPYR2
  390.     INX    B        ;No. Increment record count
  391.     LXI    H,128        ;Increment buffer pointer
  392.     DAD    D
  393.     XCHG
  394.     LXI    H,-BUFEND    ;Buffer full?
  395.     DAD    D
  396.     MOV    A,H
  397.     ORA    L
  398.     JNZ    COPYR1
  399.     LXI    H,CFLAG        ;Yes. Set continuation flag.
  400.     INR    M
  401. COPYR2:
  402.     PUSH    B        ;Save file record count
  403.     POP    H
  404.     SHLD    FCNT
  405.     MOV    A,H        ;Empty file?
  406.     ORA    L
  407.     JZ    COPYS
  408.  
  409.     CALL    SWSD        ;No. Switch to destination system.
  410.     LDA    CFLAG        ;On a continuation?
  411.     CPI    2
  412.     JNC    COPYW
  413.     LDA    DDRIVE        ;No. Select destination drive
  414.     CPI    ERRCD        ;  if specified
  415.     JZ    COPYD
  416.     MOV    E,A
  417.     MVI    D,0
  418.     PUSH    D        ;Save selection
  419.     MVI    C,INIT        ;Initialize CP/M
  420.     CALL    BDOSV
  421.     POP    D
  422.     MVI    C,SELECT
  423.     CALL    BDOSV
  424.     CPI    ERRCD
  425.     LXI    D,COPYM4
  426.     JZ    COPYED
  427. COPYD:                ;Initialize destination file.
  428.     LXI    D,DFFCB
  429.     CALL    INIFCB
  430.     LXI    D,DFFCB+1    ;Move file name
  431.     LDA    WILD        ;If wild cards, use source name
  432.     ORA    A
  433.     JNZ    COPYD0
  434.     LXI    H,DFCB+1    ;Was file name specified?
  435.     MVI    A,' '
  436.     CMP    M
  437.     JNZ    COPYD1
  438. COPYD0:
  439.     LXI    H,SFFCB+1    ;No. Use source file name.
  440. COPYD1:
  441.     LXI    B,8
  442.     CALL    MOVDTA
  443.     LXI    H,DOLLAR    ;Set file type to $$$.
  444.     LXI    B,3
  445.     CALL    MOVDTA
  446.     LXI    D,DFFCB        ;Delete any temporary file of same name
  447.     MVI    C,DELETE
  448.     CALL    BDOSV
  449.     LXI    D,DFFCB        ;Create temporary file
  450.     MVI    C,CREATE
  451.     CALL    BDOSV
  452.     LXI    D,COPYM5
  453.     CPI    ERRCD
  454.     JZ    COPYED
  455.     LXI    D,DFFCB        ;Open destination file
  456.     MVI    C,OPEN
  457.     CALL    BDOSV
  458.     LXI    D,COPYM6
  459.     CPI    ERRCD
  460.     JZ    COPYED
  461.  
  462. COPYW:                ;Write buffer.
  463.     LXI    D,BUFFER
  464.     LHLD    FCNT        ;Initialize record count
  465.     PUSH    H        ;Save record count
  466. COPYW1:
  467.     PUSH    D        ;Save buffer pointer
  468.     MVI    C,SETDMA    ;Set dma address
  469.     CALL    BDOSV
  470.     LXI    D,DFFCB
  471.     MVI    C,WRITES    ;Write a record
  472.     CALL    BDOSV
  473.     POP    D        ;Restore buffer pointer
  474.     POP    H        ;Restore record count
  475.     CPI    0
  476.     JNZ    COPYW2        ;If write error.
  477.     DCX    H        ;Decrement record count
  478.     MOV    A,H
  479.     ORA    L
  480.     JZ    COPYW3
  481.     PUSH    H        ;Save record count
  482.     LXI    H,128        ;Increment buffer pointer
  483.     DAD    D
  484.     XCHG
  485.     JMP    COPYW1
  486.  
  487. COPYW2:                ;Write error
  488.     LXI    D,COPYM7
  489.     CPI    1
  490.     JZ    COPYED
  491.     LXI    D,COPYM8
  492.     CPI    2
  493.     JZ    COPYED
  494.     LXI    D,COPYM5
  495.  
  496. COPYED:                ;Error on destination system
  497.     PUSH    D        ;Save message pointer
  498.     CALL    SWDS        ;Switch to source system
  499.     POP    D        ;Restore message pointer
  500.     JMP    COPYER        ;Print error and return
  501.  
  502. COPYW3:                ;Close destination and verify.
  503.     LXI    D,DFFCB
  504.     MVI    C,CLOSE
  505.     CALL    BDOSV
  506.     LXI    D,COPYM9
  507.     CPI    ERRCD
  508.     JZ    COPYED
  509.     LXI    H,DFFCB+12    ;CLEAR FCB
  510.     MVI    B,33-12
  511.     XRA    A
  512. COPYV0:
  513.     MOV    M,A
  514.     INX    H
  515.     DCR    B
  516.     JNZ    COPYV0
  517.     LXI    D,DFFCB        ;Verify
  518.     MVI    C,OPEN
  519.     CALL    BDOSV
  520.     LXI    D,COPYM6
  521.     CPI    ERRCD
  522.     JZ    COPYED
  523.     LXI    D,VBUFF        ;Set dma address
  524.     MVI    C,SETDMA
  525.     CALL    BDOSV
  526.     LHLD    FCNT        ;Initialize record count
  527.     MOV    B,H
  528.     MOV    C,L
  529.     LXI    H,BUFFER    ;Initialize buffer pointer
  530.  
  531. COPYV:                ;Verify record
  532.     PUSH    H        ;Save buffer pointer
  533.     PUSH    B        ;Save record count
  534.     LXI    D,DFFCB
  535.     MVI    C,READS        ;Get record
  536.     CALL    BDOSV
  537.     POP    B        ;Restore record count
  538.     POP    H        ;Restore buffer pointer
  539.     LXI    D,COPYMA
  540.     CPI    0
  541.     JNZ    COPYED
  542.     PUSH    B        ;Save record count
  543.     MVI    B,128        ;Set compare count
  544.     LXI    D,VBUFF        ;Set compare buffer pointer
  545. COPYV1:
  546.     LDAX    D        ;Get destination byte
  547.     CMP    M        ;Are they equal?
  548.     JZ    COPYV2
  549.     POP    B        ;Remove compare count
  550.     LXI    D,COPYMA
  551.     JMP    COPYED
  552. COPYV2:
  553.     INX    H        ;Yes. Increment buffer pointers
  554.     INX    D
  555.     DCR    B        ;Decrement compare count
  556.     JNZ    COPYV1
  557.     POP    B        ;Restore record count
  558.     DCX    B        ;Decrement record count
  559.     MOV    A,B
  560.     ORA    C
  561.     JNZ    COPYV
  562.     LXI    D,DFFCB        ;Close destination file
  563.     MVI    C,CLOSE
  564.     CALL    BDOSV
  565.     LXI    D,COPYM9
  566.     CPI    ERRCD
  567.     JZ    COPYED
  568.     LXI    D,DFFCB+16    ;Setup FCB for rename
  569.     LXI    H,DFFCB
  570.     LXI    B,9
  571.     CALL    MOVDTA
  572.     LXI    H,DFCB+9    ;Was type specified?
  573.     MVI    A,' '
  574.     CMP    M
  575.     JNZ    COPYN1
  576.     LXI    H,SFFCB+9    ;No. Use source type.
  577. COPYN1:
  578.     LXI    B,3
  579.     CALL    MOVDTA
  580.     LXI    D,DFFCB+16    ;Delete any file of same name & type
  581.     MVI    C,DELETE
  582.     CALL    BDOSV
  583.     LXI    D,DFFCB        ;Rename the destination file
  584.     MVI    C,RENAME
  585.     CALL    BDOSV
  586.     LXI    D,COPYMB
  587.     CPI    ERRCD
  588.     JZ    COPYED
  589.  
  590. COPYL:    CALL    SWDS        ;Switch to source system
  591.     LDA    CFLAG        ;Continuation?
  592.     ORA    A
  593.     JNZ    COPYR        ;Yes
  594.     JMP    COPYS        ;No.  Get next occurrence.
  595.  
  596.  
  597. DOLLAR:    DB    '$$$'
  598.  
  599. COPMSG:    DB    CR,LF,LF,'COPYING -',EOS
  600. COPYM1:    DB    CR,LF,'Source drive not ready.',EOS
  601. COPYM2:    DB    CR,LF,'File not found.',EOS
  602. COPYM3:    DB    CR,LF,'Open error on source file.',EOS
  603. COPYM4:    DB    CR,LF,'Destination drive not ready.',EOS
  604. COPYM5:    DB    CR,LF,'Destination drive directory is full.',EOS
  605. COPYM6: DB    CR,LF,'Open error on destination file.',EOS
  606. COPYM7:    DB    CR,LF,'Error in extending destination file.',EOS
  607. COPYM8:    DB    CR,LF,'Destination disk is full.',EOS
  608. COPYM9:    DB    CR,LF,'Close error on destination file.',EOS
  609. COPYMA:    DB    CR,LF,'Verify error.',EOS
  610. COPYMB:    DB    CR,LF,'Rename error.',EOS
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617. ;    INFCRT - Output message and input from console.
  618. ;
  619. ;    ENTRY    DE = message address.
  620. ;
  621. ;    EXIT    A = First character entered (upper case).
  622.  
  623. INFCRT:
  624.     MVI    C,PRTSTR
  625.     CALL    BDOSV        ;Output message
  626.     LXI    D,INBUFX
  627.     MVI    C,RDCB
  628.     CALL    BDOSV
  629.     LDA    INBUFX+1
  630.     ANA    A
  631.     MVI    A,CR
  632.     RZ
  633.     LDA    INBUF
  634.     CPI    'A'+20h
  635.     RC            ;If upper case
  636.     CPI    'Z'+20h+1
  637.     RNC            ;If upper case
  638.     SUI    20h        ;Fold to uppercase
  639.     RET
  640.  
  641. INBUFX:    DB    40,0
  642. INBUF:    DS    40
  643.  
  644.  
  645. ;    PARSE - Parse file descriptor
  646. ;
  647. ;    Entry:    HL = address of string buffer
  648. ;        DE = address of FCB
  649. ;         C = string length
  650. ;    Exit:    A = 0ffh if illegal file descriptor or drive
  651. ;        B = drive code or 0ffh
  652. ;
  653. PARSE:
  654.     CALL    INIFCB        ;Initialize FCB
  655.     INX    D        ;skip entry type
  656.     MVI    B,0FFH        ;initialize drive code
  657.     MOV    A,C        ;empty string?
  658.     ORA    A
  659.     JNZ    PARSE2
  660. PARSE1:    MVI    A,0FFh        ;yes. return error code
  661.     RET
  662.  
  663. PARSE2:    MVI    A,1        ;drive specified?
  664.     CMP    C
  665.     JNC    PARSE3
  666.     INX    H        ;maybe
  667.     MOV    A,M        ;Is second character ':'?
  668.     DCX    H
  669.     CPI    ':'
  670.     JNZ    PARSE3
  671.     CALL    GETFDC        ;Yes. Get drive character
  672.     SUI    'A'        ;Legal drive #?
  673.     JM    PARSE1
  674.     CPI    16
  675.     JNC    PARSE1
  676.     MOV    B,A        ;Yes.  Save drive code.
  677.     INX    H        ;Skip to file name
  678.     DCR    C
  679.     INX    H
  680.     DCR    C
  681.     JNZ    PARSE3
  682.     XRA    A        ;done
  683.     RET
  684. PARSE3:
  685.     PUSH    B        ;Save drive code
  686.     MVI    B,8        ;Set maximum length of file name
  687.     CALL    PARSNT        ;parse file name
  688.     XRA    A        ;done?
  689.     CMP    C
  690.     JZ    PARSE4
  691.     MVI    A,'.'        ;No. file type?
  692.     CMP    M
  693.     JNZ    PARSE4
  694.     INX    H        ;Yes. parse file type
  695.     DCR    C
  696.  
  697.     JZ    PARSE5
  698.     MVI    B,3
  699.     CALL    PARSNT
  700. PARSE4:    MOV    A,C        ;Save count
  701.     POP    B        ;Restore drive code
  702.     MOV    C,A
  703.     XRA    A
  704.     RET
  705. PARSE5:
  706.     MOV    A,C
  707.     POP    B
  708.     MOV    C,A
  709.     MVI    A,0FFh
  710.     RET
  711.  
  712.  
  713. ;    PARSNT - Parse file name or type
  714. ;
  715. PARSNT:    MVI    A,'*'        ;Wild card?
  716.     CMP    M
  717.     JNZ    PARSN3
  718. PARSN1:    INX    H        ;Yes. Skip to terminator.
  719.     DCR    C
  720.     JZ    PARSN2
  721.     CALL    GETFDC
  722.     JNZ    PARSN1
  723. PARSN2:    PUSH    B        ;Save count
  724.     MOV    C,B        ;Fill with '?'
  725.     MVI    B,0
  726.     CALL    PARSEQ
  727.     POP    B        ;Restore count
  728.     RET
  729. PARSN3:
  730.     CALL    GETFDC        ;Get character
  731.     JZ    PARSN5
  732.     STAX    D        ;Store char
  733.     INX    D        ;Incr. FCB pointer
  734.     INX    H        ;Incr. string pointer
  735.     DCR    B        ;Out of space?
  736.     JZ    PARSN4
  737.     DCR    C        ;Decr. string count.
  738.     JNZ    PARSN3
  739.     RET
  740. PARSN4:
  741.     CALL    GETFDC        ;Skip to terminator.
  742.     RZ
  743.     DCR    C
  744.     JNZ    PARSN4
  745.     RET
  746. PARSN5:
  747.     MOV    A,E        ;Adjust FCB pointer to end of field.
  748.     ADD    B
  749.     MOV    E,A
  750.     RNC
  751.     INR    D
  752.     RET
  753.  
  754. ;    PARSEQ - Fill field with '?'
  755. ;
  756. PARSEQ:    PUSH    H        ;Save string pointer
  757.     MOV    H,D
  758.     MOV    L,E
  759.     MVI    A,'?'
  760.     STAX    D
  761.     INX    D
  762.     DCX    B
  763.     CALL    MOVDTA
  764.     POP    H
  765.     RET
  766.  
  767.  
  768.  
  769.  
  770.  
  771. ;    GETFDC - Get file descriptor character
  772. ;
  773. ;    Entry:    HL = Address of FD string
  774. ;    Exit:    A = character (upper case)
  775. ;        Z = 1 iff terminator
  776. ;
  777. GETFDC:    MOV    A,M        ;Get character
  778.     CPI    'A'+20h        ;Convert to upper case
  779.     JC    GETFC1
  780.     CPI    'Z'+20h
  781.     JNC    GETFC1
  782.     SUI    20h
  783. GETFC1:    CPI    '.'        ;Check for terminator
  784.     RZ
  785.     CPI    ' '
  786.     RZ
  787.     CPI    '='
  788.     RZ
  789.     CPI    '*'
  790.     RET
  791.  
  792.  
  793.  
  794.  
  795. ;    INIFCB - Initialize FCB
  796. ;
  797. ;    Entry:    DE = Address of FCB
  798. ;
  799. INIFCB:    PUSH    H        ;Save registers
  800.     PUSH    D
  801.     POP    H        ;HL = FCB
  802.     PUSH    H
  803.     PUSH    B
  804.     XRA    A        ;clear entry type
  805.     MOV    M,A
  806.     INX    H
  807.     INX    D        ;set file name & type to spaces
  808.     INX    D
  809.     MVI    A,' '
  810.     MOV    M,A
  811.     LXI    B,10
  812.     CALL    MOVDTA
  813.     INX    H
  814.     XRA    A        ;clear rest of FCB
  815.     MOV    M,A
  816.     INX    D
  817.     LXI    B,20        ; and next record number
  818.     CALL    MOVDTA
  819.     POP    B
  820.     POP    D        ;restore registers
  821.     POP    H
  822.     RET
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829. ;    MOVDTA - Move data utility program.
  830. ;
  831. ;    ENTRY    HL = Source field.
  832. ;        DE = Destination field.
  833. ;        BC = number of bytes.
  834.  
  835. MOVDTA:
  836.     MOV    A,M
  837.     STAX    D
  838.     INX    H
  839.     INX    D
  840.     DCX    B
  841.     MOV    A,B
  842.     ORA    C
  843.     JNZ    MOVDTA
  844.     RET
  845.  
  846.  
  847.  
  848. ;    SYSINI - Initialize destination system
  849. ;
  850. SYSINI:    CALL    SWSD        ;Switch page 0
  851.     LXI    H,SYSIN1    ;Set BIOS initialization return
  852.     PUSH    H
  853.     LHLD    WBOOT+1        ;Get warm boot vector address
  854.     DCX    H        ;Get cold boot address
  855.     MOV    D,M
  856.     DCX    H
  857.     MOV    E,M
  858.     LXI    H,-3        ;Point to STSINI entry
  859.     DAD    D
  860.     PCHL            ;Initialize BIOS
  861. SYSIN1:
  862.     CPI    0FFh        ;Initialization error?
  863.     JNZ    SYSIN2
  864.     CALL    SWDS        ;Yes.  Restore source system
  865.     LXI    D,INIMSG
  866.     MVI    C,PRTSTR
  867.     CALL    BDOSV
  868.     JMP    SYSRET
  869. SYSIN2:
  870.     MVI    C,INIT        ;Initialize BDOS and select A
  871.     CALL    BDOSV
  872.     CALL    SWDS        ;Switch page 0
  873.     RET
  874. INIMSG:    DB    CR,LF,'BIOS initialization error.', EOS
  875.  
  876.  
  877.  
  878. ;    SWSD - Switch from source to destination system
  879. ;
  880. SWSD:    LXI    H,0        ;Save source page 0 pointers
  881.     LXI    D,SPZERO
  882.     LXI    B,8
  883.     CALL    MOVDTA
  884.     LXI    H,DPZERO    ;Set destination page 0 pointers
  885. SWDS1:    LXI    D,0
  886.     LXI    B,8
  887.     CALL    MOVDTA
  888.     RET
  889.  
  890. ;    SWDS - Switch from destination to source system
  891. ;
  892. SWDS:    LXI    H,0        ;Save destination page 0 pointers.
  893.     LXI    D,DPZERO
  894.     LXI    B,8
  895.     CALL    MOVDTA
  896.     LXI    H,SPZERO    ;Set source page 0 pointers.
  897.     JMP    SWDS1
  898.  
  899.  
  900. ;    Destination system page 0 pointers
  901. ;
  902. DPZERO:    JMP    CBIOS+3        ;BIOS entry
  903.     DB    0        ;I/O byte
  904.     DB    0        ;Current disk
  905.     JMP    BDOS        ;BDOS entry
  906.  
  907. ;    Source system page 0 pointers
  908. ;
  909. SPZERO:    DS    8
  910.  
  911.  
  912.  
  913. WILD:    DS    1        ;Wild card flag
  914. FNMSG:    DB    CR,LF
  915. FN:    DS    8
  916.     DB    '.'
  917. FT:    DS    3
  918.     DB    EOS
  919.  
  920.  
  921. SYSTK:    DS    2        ;Hold stack
  922.  
  923. ODRIVE:    DS    1        ;Original drive
  924. DDRIVE:    DS    1        ;Destination drive
  925. SDRIVE:    DS    1        ;Source drive
  926.  
  927. SRCOCC:    DS    1        ;Source file occurrence count
  928. CFLAG:    DS    1        ;Continuation flag
  929. FCNT:    DS    2        ;File record count
  930.  
  931.  
  932.  
  933. DFCB:    DS    33        ;destination command file name
  934. DFFCB:    DS    33        ;destination FCB
  935. SFCB:    DS    33        ;source command file name
  936. SFFCB:    DS    33        ;source file FCB
  937. FCB:    DS    33        ;STSCPM.COM FCB
  938.  
  939.  
  940.  
  941.     DS    50
  942. STACK:    DS    1
  943.  
  944.  
  945.  
  946.  
  947. ;
  948. VBUFF:    DS    128
  949. BUFFER:    DS    (CCP-$) AND 0FF00H
  950. BUFSEC:    EQU    ($-BUFFER)/128
  951. BUFEND:    EQU    BUFFER+BUFSEC*128
  952. ;
  953.     ORG    VBUFF
  954. ;
  955. ;    Check for HELP request
  956. ;
  957. HELPCK:    LXI    H,HELPNM
  958.     LXI    D,CPMFCB+1
  959.     MVI    B,8
  960.     LDAX    D        ;Was file specified?
  961.     CPI    ' '
  962.     JZ    HELPC2        ;No
  963. HELPC1:    CMP    M        ;Yes
  964.     RNZ
  965.     INX    D
  966.     INX    H
  967.     LDAX    D
  968.     DCR    B
  969.     JNZ    HELPC1
  970. HELPC2:    LXI    D,HELP        ;Print HELP message
  971.     MVI    C,PRTSTR
  972.     CALL    BDOSV
  973.     JMP    SYSRET
  974.  
  975.  
  976. HELPNM:    DB    'HELP    '
  977.  
  978. HELP:    DB    CR,LF,LF
  979.     DB    'STSCOPY - System-to-System file copy',CR,LF,LF
  980.     DB    'This program provides a means of loading files onto',CR,LF
  981.     DB    'a hard disk from floppy diskette for Data Technology',CR,LF
  982.     DB    'Corporation customers receiving controllers that do',CR,LF
  983.     DB    'not include floppy diskette control.  It is assumed',CR,LF
  984.     DB    'that the customer has an operational CP/M system',CR,LF
  985.     DB    'running with a non-DTC disk controller.',CR,LF,LF
  986.     DB    'After FORMATting the hard disk and INSTALLing CP/M',CR,LF
  987.     DB    'on it, edit the file CONFIG and set MSIZE to a value',CR,LF
  988.     DB    'just below the CCP of your floppy based CP/M.  Then',CR,LF
  989.     DB    'execute the SUBMIT file STSCOPY.SUB which will',CR,LF
  990.     DB    'generate customized copies of STSCOPY.COM and',CR,LF
  991.     DB    'STSCPM.COM.  (See STSCOPY.SUB for details.)',CR,LF
  992.     DB    'To execute STSCOPY.COM, type',CR,LF
  993.     DB    '    STSCOPY STSCPM.COM',CR,LF
  994.     DB    'The file STSCPM.COM is read into memory and the',CR,LF
  995.     DB    'keyboard prompt "*" is output to the console.',CR,LF
  996.     DB    'The form of each command line is',CR,LF,LF
  997.     DB    '    destination=source cr',CR,LF,LF
  998.     DB    'where "destination" is the file in the STSCPM',CR,LF
  999.     DB    'system to receive the data and "source" is the',CR,LF
  1000.     DB    'file in the floppy based CP/M system.  Disk drive',CR,LF
  1001.     DB    'names may be optionally included in the source',CR,LF
  1002.     DB    'and destination.  The destination may be null or',CR,LF
  1003.     DB    'an "unambiguous" (ufn) file reference as defined',CR,LF
  1004.     DB    'in CP/M.  The source may be a ufn or an "ambiguous"',CR,LF
  1005.     DB    '(afn) file reference.  For example',CR,LF,LF
  1006.     DB    '    x:=*.COM',CR,LF,LF
  1007.     DB    'transfers all COM files from the currently selected',CR,LF
  1008.     DB    'drive of the floppy based CP/M system to drive x',CR,LF
  1009.     DB    'of the hard disk system.  All transfers are verified',CR,LF
  1010.     DB    'by reading them back and comparing.',CR,LF,EOS
  1011.  
  1012.     END
  1013.