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 / MODEMS / MODEM / CP405SRC.ARK / CP4WLD.ASM < prev   
Assembly Source File  |  1986-12-25  |  4KB  |  142 lines

  1. ; CP4WLD.ASM
  2. ;    KERMIT - (Celtic for "FREE")
  3. ;
  4. ;    This is the CP/M-80 implementation of the Columbia University
  5. ;    KERMIT file transfer protocol.
  6. ;
  7. ;    Version 4.0
  8. ;
  9. ;    Copyright June 1981,1982,1983,1984
  10. ;    Columbia University
  11. ;
  12. ; Originally written by Bill Catchings of the Columbia University Center for
  13. ; Computing Activities, 612 W. 115th St., New York, NY 10025.
  14. ;
  15. ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,
  16. ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many
  17. ; others. 
  18. ;
  19. ;    Multi-file access subroutine.  Allows processing of multiple files
  20. ;    (i.e., *.ASM) from disk.  This routine builds the proper name in the
  21. ;    FCB each time it is called.  This command would be used in such pro-
  22. ;    grams such as modem transfer, tape save, etc. in which you want to
  23. ;    process single or multiple files.
  24. ;    Note that it will fail if more than 256 entries match the wildcard.
  25. ;
  26. ; revision history:
  27. ; edit 3: July 27, 1984
  28. ;    support LASM: remove exclamation points, link to CP4CMD.
  29. ;
  30. ; edit 2: June 7, 1984 (CJC)
  31. ;    formatting and documentation; add module version string; redo movfcb,
  32. ;    in preparation for moving DMA buffer (later...).
  33. ;
  34. ; edit 1: May, 1984 (CJC)
  35. ;    extracted from CPMBASE.M80 version 3.9; modifications are described
  36. ;    in the accompanying .UPD file.
  37. ;
  38. wldver:    db    'CP4WLD.ASM (3) 27-Jul-84$'
  39.  
  40. ;    The FCB will be set up with the next name, ready to do normal 
  41. ;    processing (OPEN, READ, etc.) when routine is called.
  42. ;
  43. ;    Carry is set if no more names can be found
  44. ;
  45. ;    MFFLG1 is count/switch [0 for first time thru, pos for all others]
  46. ;    MFFLG2 is counted down for each successive GETNEXT file call
  47. ;
  48. ;    Technique used is to repeat SFIRST/SNEXT sequence N+1 times for each
  49. ;    successive call, till sequence fails. CP/M does NOT allow disk-handling
  50. ;    between SFIRST and SNEXT.
  51. ;    called by: send, seof, dir
  52.  
  53. mfname:    ora    a        ; clear carry
  54.     push    b        ;Save registers
  55.     push    d
  56.     push    h
  57.     mvi    c,setdma    ;Init DMA addr, FCB
  58.     lxi    d,80H
  59.     call    bdos
  60.     xra    a        ;A = 0
  61.     sta    fcbext        ;clear extension
  62.     lda    mfflg1        ;find out if "second" call in row
  63.     ora    a
  64.     jnz    mfn01        ;Were here before
  65.     sta    mfflg2
  66.     lxi    h,fcb
  67.     lxi    d,mfreq
  68.     lxi    b,12
  69.     call    mover        ;.from FCB to MFREQ
  70.     mvi    c,SFIRST    ;Search first
  71.     lxi    d,fcb
  72.     call    bdos
  73.     jmp    mfn02        ;and check results
  74.  
  75. mfn01:    dcr    a
  76.     sta     mfflg2        ;store down-counter
  77.     lxi    h,mfreq        ;SFIRST REQ name
  78.     lxi    d,fcb
  79.     lxi    b,12
  80.     call    mover        ;.from MFREQ to FCB
  81.     mvi    c,sfirst    ;Search first old one,we got it before
  82.     lxi    d,fcb
  83.     call    bdos        ;no error's expected -we got that before
  84. mfn01a:
  85.     mvi    c,snext        ;Search next
  86.     call    bdos
  87. mfn02:    push    psw
  88.     lda    mfflg2        ;get "repeat file counter"
  89.     ora     a
  90.     jz    mfn02a        ;if zero, check if SNEXT had ERROR
  91.     dcr    a        ;count down
  92.     sta    mfflg2        ;store back
  93.     pop    psw        ;no error-check, we got it before
  94.     jmp    mfn01a        ;next SNEXT
  95.  
  96. mfn02a:    pop    psw
  97.     ora    a
  98.     jm    mffix2        ;No (more) found
  99.     call    movfcb        ;move data to fcb
  100.     lda    mfreq        ;the original disk-designator
  101.     sta    fcb        ;back into fcb
  102.     lda    mfflg1        ;get file-flag
  103.     inr    a        ;increment
  104.     sta    mfflg1        ;and store for next go-around
  105.     mvi    a,0        ;Setup FCB
  106.     sta    fcbext        ;clean up FCB for OPEN etc
  107.     sta    fcbrno
  108. mffix1:    pop    h        ;restore registers
  109.     pop    d
  110.     pop    b
  111.     ret            ;and return
  112.  
  113. mffix2:    stc            ;set carry
  114.     jmp    mffix1        ;return with CARRY set
  115.  
  116. ;    copy directory entry to FCB
  117. ;    called with A/ entry number in directory (0-3)
  118. ;            directory block in DMA buffer (buff)
  119.  
  120. movfcb:    add     a
  121.     add    a
  122.     add     a
  123.     add    a
  124.     add    a        ;* 32
  125.     mov    c,a        ; copy offset to bc
  126.     mvi    b,0        ; (high byte is zero)
  127.     lxi    h,buff        ; get start of disk buffer
  128.     dad    b        ; calculate start of directory entry
  129.     lxi    d,fcb
  130.     lxi    b,12
  131.     call    mover
  132.     ret
  133.  
  134. ;    Data storage for MFNAME (multi-file access)
  135. mfreq:    DS    12        ;Requested name
  136. mfflg1:    DB    0        ;First time thru flag for MFNAME
  137. mfflg2:    DB    0        ;Down counter for MFNAME
  138. ;
  139. IF lasm
  140.     LINK    CP4CMD
  141. ENDIF;lasm
  142.