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 / SIMTEL / CPMUG / CPMUG008.ARK / MAKEFCB.LIB < prev    next >
Text File  |  1984-04-29  |  3KB  |  195 lines

  1. ;++++++++++++++++++++++++++++++++++++++++++++++
  2. ;
  3. ; MAKE CP/M FILE CONTROL BLOCK
  4. ;
  5. ; MAKEFCB.LIB  -  Version 0.2  -  28 OCT 77
  6. ;
  7. ; JEFFREY W. SHOOK
  8. ; P.O. BOX 185
  9. ; ROCKY POINT, NEW YORK 11778
  10. ; (516) 744 7133
  11. ;
  12. ;++++++++++++++++++++++++++++++++++++++++++++++
  13.  
  14.  
  15. ; Create a CP/M file control block  from
  16. ; a command string at the address in HL
  17. ; and place it at the address in DE.  Return
  18. ; with the carry set if an error occurs.
  19.  
  20.  
  21. ; DEFINITIONS
  22.  
  23. FCBSIZ:    EQU    33
  24. FNMLEN:    EQU    11    ; File name length
  25.  
  26.  
  27. MTFCB:    PUSH    H    ; Save cmd string ptr
  28.     PUSH    D    ; Save FCB address
  29.     
  30.     LXI    B,FCBSIZ; Clear entire FCB area
  31.     MVI    A,0    ;
  32.     CALL    FILLB    ;
  33.  
  34.     POP    D    ; Fill file name with spaces
  35.     PUSH    D    ;
  36.     INX    D    ;
  37.     LXI    B,FNMLEN;
  38.     MVI    A,' '    ;
  39.     CALL    FILLB    ;
  40.  
  41.     POP    D    ; Restore pointers
  42.     POP    H    ;
  43.  
  44.     CALL    SKIPS    ; Skip leading spaces
  45.  
  46.     INX    H    ; Check for disk code
  47.     MOV    A,M    ;
  48.     DCX    H    ;
  49.     CPI    ':'    ;
  50.     JNZ    MTFCB1    ; Jump on no code
  51.  
  52.     MOV    A,M    ; Test if disk code good
  53.     INX    H    ;
  54.     INX    H    ;
  55.     SBI    '@'    ;
  56.     RC        ; Make error return if bad
  57.     CPI    'Z'+1    ;
  58.     CMC        ;
  59.     RC        ;
  60.  
  61.     STAX    D    ; Store disk code at FCB + 0
  62. MTFCB1:    INX    D    ;
  63.  
  64.     MVI    C,8    ; Process file name field
  65.     CALL    GETNAM    ;
  66.  
  67.     MOV    A,M    ; Test for file type separator
  68.     INX    H    ;
  69.     CPI    '.'    ;
  70.     JNZ    MTFCB2    ;
  71.  
  72.     MVI    C,3    ; Process file type field
  73.     CALL    GETNAM    ;
  74.     MOV    A,M    ;
  75.     INX    H    ;
  76.  
  77. MTFCB2:    CALL    TERMT    ; Test for corect terminator
  78.  
  79.     RET
  80.  
  81.  
  82. ; PROCESS NAME FIELD
  83.  
  84. GETNAM:    MOV    A,M    ; Get char from cmd str
  85.     INX    H    ;
  86.  
  87.     CPI    '?'    ; Allow ambig reference char
  88.     JZ    GETNA1    ;
  89.  
  90.     CPI    '*'    ; Fill rest with ?
  91.     JZ    GETNA2    ;
  92.  
  93.     CALL    VALCHR    ; Test for allowed char in name
  94.     JC    GETNA3    ;
  95.  
  96. GETNA1:    STAX    D    ; Store char in TFCB
  97.     INX    D    ;
  98.  
  99.     DCR    C    ; Check name size
  100.     JNZ    GETNAM    ;
  101.     RET        ;
  102.  
  103.  
  104. GETNA2:    MVI    A,'?'    ; Fill rest of field with ?
  105.     MVI    B,0    ;
  106.     JMP    FILLB    ;
  107.  
  108. GETNA3:    INX    D    ; Move FCB ptr to end of field
  109.     DCR    C    ;
  110.     JNZ    GETNA3    ;
  111.     DCX    H    ;
  112.     RET        ;
  113.  
  114.  
  115. ; TEST FOR VALID CHAR IN  NAME FIELD
  116. ; Return with carry set if invalid.
  117.  
  118. VALCHR:    CPI    '*'
  119.     CMC
  120.     RZ
  121.  
  122.     CPI    ','
  123.     CMC
  124.     RC
  125.  
  126.     CPI    '.'
  127.     CMC
  128.     RZ
  129.  
  130.     CPI    ' '
  131.     RC
  132.  
  133.     CPI    '^'+1
  134.     CMC
  135.     RC
  136.  
  137.     CPI    ':'
  138.     CMC
  139.     RNC
  140.  
  141.     CPI    '@'
  142.     RET
  143.  
  144.  
  145. ; TEST FOR VALID FILENAME TERMINATOR CHAR
  146. ; Return with carry set if invalid.
  147.  
  148. TERMT:    CPI    ' '
  149.     RZ
  150.  
  151.     CPI    ','
  152.     RZ
  153.  
  154.     CPI    CR
  155.     RZ
  156.  
  157.     CPI    ';'
  158.     RZ
  159.  
  160.     STC
  161.     RET
  162.  
  163.  
  164. ; SKIP SPACES IN CMD STRING
  165.  
  166. SKIPS:    MVI    A,' '
  167. SKIPS1:    CPI    M
  168.     RNZ
  169.     INX    H
  170.     JMP    SKIPS1
  171.  
  172.  
  173. ; FILL BLOCK WITH VALUE
  174.  
  175. ; Enter with:
  176. ; A  = value for fill
  177. ; DE = start of block
  178. ; BC = length of block
  179.  
  180. CLRB:    MVI    A,0
  181.  
  182. FILLB:    INR    B
  183.     DCR    B
  184.     JNZ    FILLB1
  185.     INR    C
  186.     DCR    C
  187.     RZ
  188.  
  189. FILLB1:    STAX    D
  190.  
  191.     INX    D
  192.     DCX    B
  193.  
  194.     JMP    FILLB
  195.