home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / dirutl / file23.lbr / FILE23.AZM / FILE23.ASM
Encoding:
Assembly Source File  |  1987-08-10  |  21.1 KB  |  867 lines

  1.  
  2. ; FILE23.ASM
  3. ;
  4. ; This  program will search all user areas of all drives for any files
  5. ; matching the request on the command line.  Allowable user areas for
  6. ; CP/M are 0-15.  Originally written by R. Rodman.
  7. ;
  8. ; Example:  FILE *.COM <ret>    lists all .COM files on all drives and
  9. ;                all allowable areas (set by default to
  10. ;                show through user 15.)
  11. ;
  12. ;        FILE <ret>        displays short help message
  13. ;
  14. ;        FILE *.COM S    Lists all matching file and includes
  15. ;                all system files as well. read only
  16. ;                files will be followid by "--ro" in
  17. ;                all cases.
  18. ;
  19. ; Please return any updates to technical CBBS Dearborn MI (313) 846-6127
  20. ; so the file will be available to all.
  21. ;
  22. ;=======================================================================
  23. ;
  24. ; 01/27/86  Converted program from Z80 mnemonics back to Intel 8080 like
  25. ;   v21        it was prior to version 22.  It may once again be assembled
  26. ;        with any normal 8080 assembler instead of requiring the M80
  27. ;        assembler and L80 linker (or the Z80ASM assembler by SLR.)
  28. ;                    - Irv Hoff
  29. ;
  30. ; 06/06/85  a. Added a table to enable / disable any combination of
  31. ;   v22         drives users.  See "DTABL:" in code.  The table starts
  32. ;               at 104H.
  33. ;        b. Start next drive on new line.
  34. ;        c. Start  next user display on new line.
  35. ;        d. Changed 8080 code to Z80 code.
  36. ;        e. Added optional display of SYSTEM files.  Set SHOSYS="NO"
  37. ;            If you enter FILE22 FILENAME.TYP<C/R>, only non-system
  38. ;            files will be displayed.  Read-only files will be dis-
  39. ;            played as "FILENAME.TYP--RO".  FILE22 NAME.EXT S<C/R>,
  40. ;            the "S" will enable the system file display and all
  41. ;        files will be displayed in the following four formats.
  42. ;
  43. ;        FILENAME.TYP     = not a system nor read-only file
  44. ;        FILENAME.TYP--ro = not system file, just read-only
  45. ;        FILENAME.TYP-s-- = is a system file, but not read-only
  46. ;        FILENAME.TYP-sro = is a system read-only file
  47. ;        The -xxx will be in lower case to make it easier to read
  48. ;        if your CRT has lower case.
  49. ;
  50. ;        f. Added a flag byte at 104H.  This byte enables/disables
  51. ;        the displaying of "USER PROTECTED AREA" message for
  52. ;        users that are turned off.  00=no message, FFH=display
  53. ;        message.
  54. ;        g. Added "S" option to menu after entering "FILE<C/R>"
  55. ;        h. Tested on CP/M 2.2 using 512-K ram disk & 85M hard disk.
  56. ;        i. Tested on CP/M 3.0+ using 96-K ram and 130M hard disk.
  57. ;
  58. ;            *** Only 8080 compatible Z-80 instructions are used. ***
  59. ;            The code can be assembled using    Microsoft M80.COM and
  60. ;        L80.COM or SLR Systems Z-80 assembler.
  61. ;                - Ron Lambert Sprague Electric Co.
  62. ;                  (615)-457-4130 ex 226
  63. ;
  64. ; 02/27/84  Reformatted, standardized tabs, minor changes, ran through
  65. ;   v21     FILTX and TABASM, saving 19 sectors of source code length.
  66. ;                - Irv Hoff
  67. ;
  68. ; 01/14/84  Fixed bug in user area search limit when USEMAX true.  When
  69. ;   v20     using ZCMD/NZCPR, location 03FH contains Max. user area +1,
  70. ;        and FILE was using this as absolute limit.
  71. ;                - Mark Howard
  72. ;
  73. ;=======================================================================
  74. ;
  75. ;
  76. YES    EQU    0FFFFH
  77. NO    EQU    NOT    YES
  78. ;
  79. ; Set the following as desired:
  80. ;
  81. SHORO    EQU    YES        ; 'YES' to display --ro at all times
  82.                 ; "NO"    to just display in "S" mode if
  83.                 ;   they are read only.
  84. SHOSYS    EQU    YES        ; 'YES' if want to show system files
  85. DRVTYP    EQU    YES        ; 'YES' if BIOS has 'ILLEGAL DRIVE SELECT'
  86. ;
  87. ;
  88. ; Trap set 'NO' if no trap in BIOS, then set 'MAXDRV' to the number of
  89. ; drives to search through for the requested file.
  90. ;
  91. MAXDRV    EQU    2        ; Number of drives to search (1-16)
  92. MAXCOL    EQU    4        ; Max number of displayed columns wanted
  93. MAXUSR    EQU    15        ; Max user # to be checked (0-15)
  94. USEMAX    EQU    NO        ; 'YES' for dynamic changes
  95. USRMAX    EQU    03FH        ; Location of MAXUSER byte
  96. DRIVMAX    EQU    03DH        ; Location of MAXDRIV byte
  97. ;
  98. ;
  99. ; Define some miscellaneous values:
  100. ;
  101. BDOS    EQU    0005H        ; CP/M BDOS entry point
  102. FCB    EQU    005CH        ; CP/M file control block address
  103. TBUF    EQU    0080H        ; DMA buffer address
  104. CR    EQU    0DH        ; ASCII return
  105. LF    EQU    0AH        ; ASCII linefeed
  106. ;
  107. ;
  108. ; BDOS calls
  109. ;
  110. CONIN    EQU    1        ; Console input function
  111. CONOUT    EQU    2        ; Console output function
  112. PRINT    EQU    9        ; Print string at console function
  113. CONSTAT    EQU    11        ; Get console status function
  114. RTNVER    EQU    12        ; Return version number function
  115. SELDRV    EQU    14        ; Select drive
  116. SRCHFST    EQU    17        ; Search for first function
  117. SRCHNXT    EQU    18        ; Search for next function
  118. SETIOB    EQU    24        ; Set I/O byte
  119. SETDMA    EQU    26        ; Set DMA address function
  120. SETUSR    EQU    32        ; Set/get user code function
  121. ;
  122. ;
  123.     ORG    0100H
  124. ;
  125. START:    JMP    START0        ; Stip over table
  126. ;
  127. ;
  128. ; Flag byte for display of "user protected" message
  129. ;
  130. DPROT:    DB    YES        ; "YES" to display protected user msg
  131. ;
  132. ;
  133. ; This table is used to    set up all allowed drives and users.  You may
  134. ; set the  table for any number of drives (maximum is 16) and display
  135. ; any combination of drives and users.  You must set up the table as
  136. ; follows.  The first byte should be either the drive #, "DISON", or
  137. ; "DISOFF".  Here is an example of how one system was set:
  138. ;
  139. ;    A: as ram disk
  140. ;    B: 8" DSDD  floppy
  141. ;    C: 8" DSDD  floppy
  142. ;       D: 5" floppy (not installed so has "DISOFF" to disable the drive)
  143. ;    
  144. ; This program is also put on a user's area and restricts his viewing of
  145. ; certain sections.  You might want to rename FILE22.COM to DIR.COM for
  146. ; general use.
  147. ;
  148. ;     If the table for drive A: is as follows
  149. ;     A:   0  1  2  3  4  5     6  7  8  9  A  B  C  D     E  F
  150. ;     80H,FF,FF,FF,00,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF
  151. ;     display all user areas except 3
  152. ;
  153. ;     If the table for dirve B: is as follows
  154. ;     B:   0  1  2  3  4  5     6  7  8  9  A  B  C  D     E  F
  155. ;     80H,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF
  156. ;     display all users
  157. ;
  158. ;     If the table for Drive C: is as follows
  159. ;     C:      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
  160. ;     DISOFF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF
  161. ;     Skip this drive completely
  162. ;
  163. ; If you have three drives, A:, B:, and C:, set the first byte of D: to
  164. ; "YES", this will flag that C: is your last drive.
  165. ;
  166. ; If byte 0 of any of the drives (0-15) is:
  167. ;    DISON    = look at this drive
  168. ;    DISOFF    = drive not in system
  169. ;    LASTD    = last drive + 1 (end of table)
  170. ;
  171. ; Byte 2-17
  172. ;    NO  = do not display this user area
  173. ;    YES = display this user
  174. ;
  175. LASTD    EQU    YES        ; Flag for last drive + 1
  176. DISON    EQU    80H        ; Drive is enabled  <ON>
  177. DISOFF    EQU    NO        ; Drive is disabled <OFF>
  178. ;
  179. DTABL:    DB    DISON        ; A 512-K ram disk, that looks
  180.     DB    YES,YES,YES,YES    ; Just like another floppy
  181.     DB    YES,YES,YES,YES    ; So look here also
  182.     DB    YES,YES,YES,YES
  183.     DB    YES,YES,YES,YES
  184. ;
  185.     DB    DISON        ; B 8" DS/DD floppy, that is
  186.     DB    YES,YES,YES,YES    ; Always on the system because
  187.     DB    YES,YES,YES,YES    ; I boot off of it, so look at
  188.     DB    YES,YES,YES,YES    ; It
  189.     DB    YES,YES,YES,YES
  190. ;
  191.     DB    DISOFF        ; C: non existant floppy, skip it
  192.     DB    YES,YES,YES,YES    ; This is my second DS/DD 8"
  193.     DB    YES,YES,YES,YES    ; Drive, but if no disk is in
  194.     DB    YES,YES,YES,YES    ; It, I get "DRIVE NOT READY"
  195.     DB    YES,YES,YES,YES    ; So don't look at it.
  196. ;
  197.     DB    DISOFF        ; D: non existant floppy, skip it
  198.     DB    YES,YES,YES,YES    ; This is set up to be a 5 1/4"
  199.     DB    YES,YES,YES,YES    ; Drive which is not connected
  200.     DB    YES,YES,YES,YES    ; So don't look here either
  201.     DB    YES,YES,YES,YES
  202. ;
  203.     DB    DISON        ; E: 8 hard disks assigned E:-N:
  204.     DB    YES,YES,YES,YES    ; So set O: to LASTD to flag
  205.     DB    YES,YES,YES,YES    ; That N: is the last legal
  206.     DB    YES,YES,YES,YES    ; Drive.
  207.     DB    YES,YES,YES,YES
  208. ;
  209.     DB    DISON        ; F
  210.     DB    YES,YES,YES,YES
  211.     DB    YES,YES,YES,YES
  212.     DB    YES,YES,YES,YES
  213.     DB    YES,YES,YES,YES
  214. ;
  215.     DB    DISON        ; G
  216.     DB    YES,YES,YES,YES
  217.     DB    YES,YES,YES,YES
  218.     DB    YES,YES,YES,YES
  219.     DB    YES,YES,YES,YES
  220. ;
  221.     DB    DISON        ; H
  222.     DB    YES,YES,YES,YES
  223.     DB    YES,YES,YES,YES
  224.     DB    YES,YES,YES,YES
  225.     DB    YES,YES,YES,YES
  226. ;
  227.     DB    DISON        ; I
  228.     DB    YES,YES,YES,YES
  229.     DB    YES,YES,YES,YES
  230.     DB    YES,YES,YES,YES
  231.     DB    YES,YES,YES,YES
  232. ;
  233.     DB    DISON        ; J
  234.     DB    YES,YES,YES,YES
  235.     DB    YES,YES,YES,YES
  236.     DB    YES,YES,YES,YES
  237.     DB    YES,YES,YES,YES
  238. ;
  239.     DB    DISON        ; K
  240.     DB    YES,YES,YES,YES
  241.     DB    YES,YES,YES,YES
  242.     DB    YES,YES,YES,YES
  243.     DB    YES,YES,YES,YES
  244. ;
  245.     DB    DISON        ; L
  246.     DB    YES,YES,YES,YES
  247.     DB    YES,YES,YES,YES
  248.     DB    YES,YES,YES,YES
  249.     DB    YES,YES,YES,YES
  250. ;
  251.     DB    DISON        ; M
  252.     DB    YES,YES,YES,YES
  253.     DB    YES,YES,YES,YES
  254.     DB    YES,YES,YES,YES
  255.     DB    YES,YES,YES,YES
  256. ;
  257.     DB    DISON        ; N
  258.     DB    YES,YES,YES,YES
  259.     DB    YES,YES,YES,YES
  260.     DB    YES,YES,YES,YES
  261.     DB    YES,YES,YES,YES
  262. ;
  263.     DB    LASTD        ; O:, N: is the last hard disk
  264.     DB    YES,YES,YES,YES
  265.     DB    YES,YES,YES,YES
  266.     DB    YES,YES,YES,YES
  267.     DB    YES,YES,YES,YES
  268. ;
  269.     DB    DISON        ; P
  270.     DB    YES,YES,YES,YES
  271.     DB    YES,YES,YES,YES
  272.     DB    YES,YES,YES,YES
  273.     DB    YES,YES,YES,YES
  274. ;
  275.     DB    0FFH        ; End of drive table
  276. ;
  277. START0:    LXI    H,0        ; Set 'HL' to zero
  278.     DAD    SP        ; Get stack pointer into 'HL'
  279.     SHLD    STACK        ; Save for exit to 'CCP' stack
  280.     LXI    SP,STACK    ; Set up local stack
  281.     MVI    A,MAXCOL    ; Reset column number after last column
  282.     STA    COLUMN
  283.     CALL    ILPRT        ; Print sign-on message
  284.     DB    CR,LF,'FILE v22 06/06/85 - ^C to abort',CR,LF,0
  285.     LDA    FCB+1        ; Check for filename on command line
  286.     CPI    ' '
  287.     JZ    NONAME
  288.     CALL    ILPRT
  289.     DB    'Searching all drives, and all user areas',CR,LF,00
  290. ;
  291. SETUP:    LDA    0004H        ; Save user & drive #
  292.     STA    UDNUM
  293.     RRC            ; 1st 4 bits give current user #
  294.     RRC
  295.     RRC
  296.     RRC
  297.     ANI    0FH        ; 'and' off the drive bits
  298.     STA    CUN        ; Save current user #
  299.     MOV    B,A
  300. ;
  301.      IF    USEMAX
  302.     LDA    USRMAX
  303.     DCR    A
  304.      ENDIF
  305. ;
  306.      IF    NOT USEMAX
  307.     MVI    A,MAXUSR
  308.      ENDIF
  309. ;
  310.     CMP    B
  311.     JC    OUTSIDE
  312.     XRA    A
  313.     STA    CTU        ; Set current try user to 0:
  314.     STA    ORIGCTU        ; Set original 'CTU' to same
  315. ;
  316.      IF    USEMAX
  317.     LDA    USRMAX
  318.     DCR    A
  319.      ENDIF
  320. ;
  321.      IF    NOT USEMAX
  322.     MVI    A,MAXUSR
  323.      ENDIF
  324. ;
  325.     STA    MAXTEMP        ; Set maximum user number to 'maxusr'
  326. ;
  327. SBOOT:    LXI    D,TBUF
  328.     MVI    C,SETDMA
  329.     CALL    BDOS        ; Set DMA address
  330.     MVI    A,0        ; Start looking on 0 drive ('A')
  331.     STA    TRYDRV        ; Set up to try drive '0' first
  332. ;
  333. TRY:    LDA    TRYDRV        ; Try to select drive
  334.     CALL    TDRIVE        ; See if a legal drive
  335.     CPI    0FFH        ; End of drives to test
  336.     JNZ    TRY02
  337. ;
  338. ;
  339. ; Last drive + 1, exit
  340. ;
  341.     CALL    ILPRT
  342.     DB    CR,LF,00
  343.     JMP    DONE1        ; Y...exit
  344. ;
  345. TRY02:    LDA    TRYDRV        ; Get drive
  346.     ADI    'A'        ; N...ASCII it
  347.     STA    DDRIV
  348.     STA    DDRIV0
  349. ;
  350. TRY01:    CALL    ILPRT
  351.     DB    CR,LF,' ---- Drive '
  352. ;
  353. DDRIV:    DB    00        ; Put drive here
  354.     DB    ': ----',00
  355. ;
  356.      IF    SHOSYS        ;
  357.     LDA    6DH        ; See if system display is on
  358.     ANI    01011111B    ; Convert to upper case
  359.     CPI    'S'        ; "S" = y...
  360.     JNZ    NONSYS        ; N...
  361.     CALL    ILPRT        ; Y...
  362.     DB    '     * * * System File Display Active * * *',00
  363.      ENDIF
  364. ;
  365. NONSYS:    CALL    ILPRT
  366.     DB    CR,LF,00
  367. ;
  368. ;
  369. ; Test for allowed drive, 00=n..., FF=y...
  370. ;
  371. TRY1:    LDA    TRYDRV        ; Try to select drive
  372.     CALL    TDRIVE        ; See if a legal drive
  373.     CPI    NO        ; Drive allowed
  374.     JNZ    TRY2        ; Y...continue
  375. ;
  376.     CALL    ILPRT
  377.     DB    CR,LF,'Drive '
  378. ;
  379. DDRIV0:    DB    00        ; Put drive here
  380.     DB    ': has been disabled.',CR,LF,LF,00
  381.     LDA    TRYDRV
  382.     INR    A
  383.     STA    TRYDRV
  384.     JMP    TRY        ; Next drive
  385. ;
  386. TRY2:    LDA    TRYDRV        ; Get legal drive
  387.     MOV    E,A
  388.     MVI    C,SELDRV
  389.     CALL    BDOS
  390.     LDA    TRYDRV
  391.     INR    A
  392.     STA    TRYDRV        ; Get ready for next drive, too
  393.     STA    FCB        ; Store 1+drive# in FCB (1=A, 2=B, etc.)
  394. ;
  395. NXTUSR:    LDA    CTU        ; Set user to 'CTU' via a BDOS call
  396.     CALL    TUSER        ; See if we display this user
  397.     JNZ    NXT1
  398.     LDA    CTU        ; Get user
  399.     INR    A        ; Skip this user
  400.     STA    CTU        ;
  401.     MOV    B,A        ; Get user in (B)
  402.     LDA    MAXTEMP        ; See if done
  403.     CMP    B
  404.     JNC    NXT01        ; Y...
  405.     JMP    NXT2
  406. ;
  407. NXT01:    LDA    DPROT        ; Look at protected flag
  408.     ORA    A        ; See if display is ON/OFF
  409.     JZ    NXT1        ; Off...
  410.     CALL    ILPRT
  411.     DB    'Protected user area encountered',CR,LF,00
  412.     JMP    NXTUSR
  413. ;
  414. NXT1:    LDA    CTU        ; Resume with next one
  415.     MOV    E,A
  416.     MVI    C,SETUSR
  417.     CALL    BDOS
  418. ;
  419. AVAIL:    MVI    C,CONSTAT    ; Check to see if key pressed
  420.     CALL    BDOS
  421.     ORA    A
  422.     JZ    NOPRESS        ; If no key pressed, then continue
  423.     MVI    C,CONIN        ; If key pressed, then check for abort
  424.     CALL    BDOS
  425.     CPI    'C' AND    1FH    ; Is it CTL-x?
  426. ;
  427. AVAIL1:    JNZ    NOPRESS        ; If no, then continue
  428.     CALL    ILPRT        ; If yes, then print abort message
  429.     DB    CR,LF,CR,LF,' + + ABORTED + +',0
  430.     JMP    DONE1
  431. ;
  432. NOPRESS:LXI    D,FCB
  433.     MVI    C,SRCHFST
  434.     CALL    BDOS        ; Check for directory match with 'FCB'
  435.     CPI    0FFH        ; A-reg. has 0-3 if file found else 0FFH
  436.     JZ    NXT        ; Do next drive if no more matches found
  437.     CALL    SHOFIL        ; If match found, display the filename
  438.     MVI    A,-1
  439.     STA    FNDFIL
  440. ;
  441. SNEXT:    MVI    C,SRCHNXT
  442.     CALL    BDOS        ; Check for next match with FCB
  443.     CPI    0FFH
  444.     JZ    NXT        ; No more matches? then do next drive
  445.     CALL    SHOFIL        ; If match found, display the filename
  446.     MVI    A,-1
  447.     STA    FNDFIL
  448.     JMP    SNEXT        ; Continue until no more matches found
  449. ;
  450. NXT:    LDA    FNDFIL        ; Get found file falg
  451.     ORA    A        ; 0=N...
  452.     JZ    NXT0
  453.     LDA    COLUMN
  454.     CPI    MAXCOL
  455.     JZ    NXTA
  456.     CALL    CRLF
  457. ;
  458. NXTA:    CALL    ILPRT
  459.     DB    CR,LF
  460.     DB    'Searching Additional Users',CR,LF,00
  461.     MVI    A,MAXCOL    ; Reset column number after last column
  462.     STA    COLUMN
  463.     XRA    A
  464.     STA    FNDFIL        ; Clear found file falg
  465. ;
  466. NXT0:    LDA    CTU        ; Increment current try user number
  467.     INR    A
  468.     STA    CTU
  469.     MOV    B,A
  470.     LDA    MAXTEMP
  471.     CMP    B
  472.     JNC    NXTUSR        ; Do next user number if all not done
  473. ;
  474. NXT2:    LDA    ORIGCTU        ; Else reset user # and do next drive
  475.     STA    CTU
  476.     MVI    C,RTNVER
  477.     CALL    BDOS        ; See if CP/M version 1.4 or 2.x
  478.     MVI    C,5        ; (if CP/M 1.4, then BIOS must return an
  479.     ORA    A        ; Error if bad drive #, else won't work)
  480.     JZ    FOUR        ; If 1.4 then four drives maximum
  481. ;
  482.      IF    NOT USEMAX    ; If no trap then the maximum drive is
  483.     MVI    C,MAXDRV    ; Set manually.
  484.      ENDIF
  485. ;
  486.      IF    USEMAX
  487.     LDA    DRIVMAX
  488.     INR    A
  489.     MOV    C,A
  490.      ENDIF
  491. ;
  492. FOUR:    LDA    TRYDRV
  493.     CMP    C
  494.     JC    TRY        ; Continue until all drives checked...
  495. ;
  496. ;
  497. ; Done now, return to CP/M
  498. ;
  499. DONE:    LDA    MFLAG        ; See if any files found
  500.     ORA    A
  501.     JNZ    DONE1        ; If yes, then done, so exit
  502.     CALL    ILPRT        ; If no, then say none found first
  503.     DB    CR,LF,CR,LF,' + + FILE NOT FOUND + +',0
  504. ;
  505. DONE1:    CALL    ILPRT
  506.     DB    CR,LF,0        ; Turn up a line
  507.     LDA    UDNUM        ; Restore user/drive number
  508.     STA    4
  509.     ANI    0FH
  510.     MOV    E,A        ; Select the default drive
  511.     MVI    C,SELDRV
  512.     CALL    BDOS
  513. ;
  514. EXIT:    LDA    UDNUM
  515.     RLC
  516.     RLC
  517.     RLC
  518.     RLC            ; Make it a user area
  519.     ANI    15        ; Make it between 0 and 15
  520.     MOV    E,A        ; Put it in 'E' register
  521.     MVI    C,SETUSR    ; Set user area
  522.     CALL    BDOS
  523. ;
  524. EXITSPCL:
  525.     CALL    ILPRT
  526.     DB    ' Search Completed',CR,LF,00
  527.     LHLD    STACK        ; Get old stack value
  528.     SPHL
  529.     RET            ; All done
  530. ;.....
  531. ;
  532. ;
  533. NONAME:    CALL    ILPRT        ; Else, print help message and exit
  534.     DB    1AH        ; Clear screen chr.
  535.     DB    CR,LF
  536.     DB    '     You must specify the file(s) you want to find.'
  537.     DB    CR,LF
  538.     DB    '     Wildcards are OK.',CR,LF,LF
  539.     DB    '     Example:  FILE MDM7.DOC',CR,LF
  540.     DB    '               FILE MOD*.*',CR,LF
  541.     DB    '               FILE *.ASM',CR,LF,LF
  542.     DB    '     The "S" option will enable the display',CR,LF
  543.     DB    '     of files with the system attribute set',CR,LF,LF
  544.     DB    '               FILE MDM7.DOC S',CR,LF
  545.     DB    '               FILE *.* S',CR,LF
  546.     DB    '               FILE MOD*.* S',CR,LF
  547.     DB    '               FILE *.COM S',CR,LF,LF
  548.     DB    '     The last four will display as follows',CR,LF
  549.     DB    '     FILENAME.TYP     = non system read write file'
  550.     DB    CR,LF
  551.     DB    '     FILEMANE.TYP--ro = non system read only file'
  552.     DB    CR,LF
  553.     DB    '     FILENAME.TYP-s-- = read write system file',CR,LF
  554.     DB    '     FILEMANE.TYP-sro = system read only file',CR,LF
  555.     DB    00
  556. ;
  557. ;
  558. ; Reset everything and exit
  559. ;
  560.     LDA    UDNUM
  561.     RLC
  562.     RLC
  563.     RLC
  564.     RLC            ; Make it a user area
  565.     ANI    15        ; Make it between 0 and 15
  566.     MOV    E,A        ; Put it in 'E' register
  567.     MVI    C,SETUSR    ; Set user area
  568.     CALL    BDOS
  569. ;
  570. ;
  571. ; Restore old stack
  572. ;
  573.     LHLD    STACK        ; Get old stack value
  574.     SPHL            ;
  575.     RET            ; All done
  576. ;.....
  577. ;
  578. ;
  579. OUTSIDE:LDA    CUN
  580.     STA    CTU        ; Set current try user to current user #
  581.     STA    ORIGCTU        ; Set original 'CTU' to same
  582.     STA    MAXTEMP        ; Set maximum user number to current
  583.     JMP    SBOOT        ; And continue...
  584. ;
  585. SHOFIL:    MOV    L,A        ; Get filename to display from directory
  586.     MVI    H,0        ; Which CP/M puts at DMA address
  587.     DAD    H        ; ('A' register has relative position of
  588.     DAD    H        ; Name    within directory record)
  589.     DAD    H
  590.     DAD    H
  591.     DAD    H        ; Multiply 'A' by 32 for filename start
  592.     LXI    D,TBUF        ; Filename
  593.     DAD    D        ; Now point to filename
  594.     XCHG            ; Save filename pointer in 'DE'
  595. ;
  596.      IF    SHOSYS        ; Then ignore 'SYS' files
  597.     LXI    H,10
  598.     DAD    D        ; Point to 'SYS' file attribute
  599.     MOV    A,M
  600.     ANI    80H        ; Check for 'SYS' type file
  601.     STA    SAVSAT        ; Save attributes
  602.     DCX    H        ; To next test byte
  603.     MOV    A,M        ; Get it
  604.     ANI    80H        ; Check for "R/O" type file
  605.     STA    SAVRAT        ; Save attribute
  606.     INX    H
  607.     LDA    6DH        ; Get first chr of second FCB
  608.     ANI    01011111B    ; Convert to upper case
  609.     CPI    'S'        ; "S" = yes, display system files
  610.     JZ    ISOPS        ; Y...is optional "S"
  611.     LDA    SAVSAT        ; Get attribute again
  612.     ORA    A        ; Test for 00
  613.     RNZ            ; Don't display if 'SYS' file
  614.      ENDIF            ; NOT SHOSYS
  615. ;
  616. ISOPS:    LDAX    D        ; Get user number
  617.     INX    D
  618.     PUSH    PSW        ; Save the user number
  619. ;
  620. ;
  621. ; Print "drive user: FILENAME.TYP"
  622. ;
  623. SHOFIL1:LDA    TRYDRV        ; Get the disk drive
  624.     ADI    'A'-1        ; Convert binary to ASCII
  625.     CALL    AOUT        ; Display drive (a-p)
  626.     POP    PSW        ; Save the user number
  627.     CPI    9+1        ; 0-9 ?
  628.     JC    USRL        ; If yes, exit
  629.     SUI    10        ; User number = 10 thru 15
  630.     PUSH    PSW        ; Remainder is <10
  631.     MVI    A,'1'
  632.     CALL    AOUT2        ; Print a leading '1'
  633.     POP    PSW        ; Get the remainder back
  634. ;
  635. USRL:    ADI    '0'        ; Convert from binary to ASCII #
  636.     CALL    AOUT2        ; Print digit
  637. ;
  638. NOUSR:    MVI    A,':'        ; Fence character
  639.     CALL    AOUT2        ; Display a ':' to look nice
  640. ;
  641. ;
  642. ; FILENAME.TYP
  643. ;
  644.     MVI    B,8        ; (8 characters or less in filename)
  645. ;
  646. PFN:    LDAX    D        ; Now print the filename..
  647.     INX    D        ;
  648.     CALL    AOUT2        ; One character at a time
  649.     DCR    B
  650.     JNZ    PFN        ; Continue for all 8 characters
  651.     MVI    A,'.'
  652.     CALL    AOUT2        ; Display the '.' before the filetype
  653.     MVI    B,3        ; Now do the same for the filetype
  654. ;
  655. PXT:    LDAX    D
  656.     INX    D
  657.     CALL    AOUT2
  658.     DCR    B
  659.     JNZ    PXT
  660.     LDA    COLUMN        ; Print MAXCOL columns across the screen
  661.     DCR    A
  662.     JZ    TEOL        ; Go test end of line
  663.     STA    COLUMN
  664.     CALL    THRESP        ; Print two spaces to make it neat
  665.     MVI    A,0FFH        ; Show that a file was found
  666.     STA    MFLAG        ; Suppresses 'not found' message
  667.     RET
  668. ;.....
  669. ;
  670. ;
  671. ; This is end of line sequence, see if it is a system file
  672. ;
  673. TEOL:    LDA    SAVSAT        ; Test the attribute flag
  674.     ORA    A        ; 00=not sys file
  675.     JZ    TEOL1
  676.     CALL    ILPRT
  677.     DB    's',0        ; Is system file
  678.     LDA    SAVRAT
  679.     ORA    A
  680.     JZ    TEOL2
  681.     CALL    ILPRT
  682.     DB    'ro',0        ; Sys and read only
  683.     JMP    DOCRLF
  684. ;
  685. TEOL1:     IF    SHORO
  686.     LDA    SAVRAT
  687.     ORA    A
  688.     JZ    DOCRLF        ; Not sys, not read only, just c/r l/f
  689.     CALL    ILPRT
  690.     DB    '-ro',0        ; Just read only
  691.      ENDIF
  692. ;
  693.     JMP    DOCRLF
  694. ;
  695. TEOL2:    CALL    ILPRT        ; Not read only, just system
  696.     DB    '--',0
  697. ;
  698. ;
  699. ; CR/LF
  700. ;
  701. DOCRLF:    MVI    A,MAXCOL    ; Reset column number after last column
  702.     STA    COLUMN
  703. ;
  704. CRLF:    CALL    ILPRT
  705.     DB    CR,LF,0
  706.     RET
  707. ;.....
  708. ;
  709. ;
  710. THRESP:    LDA    SAVSAT        ; Test the attribute flag
  711.     ORA    A        ; 00=not sys file
  712.     JZ    NOTSYS
  713.     CALL    ILPRT
  714.     DB    's',0        ; Is system file
  715.     JMP    ISSYS
  716. ;
  717. NOTSYS:     IF    SHORO
  718.     LDA    SAVRAT
  719.     ORA    A        ; Test for read only
  720.     JZ    THRES0        ; Not sys or read only
  721.     CALL    ILPRT
  722.     DB    '-ro ',0    ; Is read only
  723.      ENDIF            ; SHORO
  724. ;
  725.      IF    NOT SHORO
  726.     CALL    ILPRT
  727.     DB    '    ',0
  728.      ENDIF
  729. ;
  730.     RET
  731. ;.....
  732. ;
  733. ;
  734. ISSYS:    LDA    SAVRAT
  735.     ORA    A        ; Test for read only
  736.     JZ    NOTRO0
  737.     CALL    ILPRT
  738.     DB    'ro ',0        ; Is read only
  739.     RET
  740. ;.....
  741. ;
  742. ;
  743. ; Not R/O, make it spaces
  744. ;
  745. NOTRO0:    CALL    ILPRT
  746.     DB    '-- ',0
  747.     RET
  748. ;.....
  749. ;
  750. ;
  751. ; Not system, make it 5 spaces
  752. ;
  753. THRES0:    CALL    ILPRT
  754.     DB    '    ',0
  755.     RET
  756. ;.....
  757. ;
  758. ;
  759. AOUT:    MOV    B,A        ; Save the character for now
  760. ;
  761. AOUT2:    PUSH    B        ; Send a character to the console
  762.     PUSH    D
  763.     PUSH    H        ; Save registers in case bdos eats them
  764.     ANI    7FH        ; Strip parity bit
  765.     MOV    E,A
  766.     MVI    C,2
  767.     CALL    BDOS        ; Print the char. in 'A' on the console
  768.     POP    H
  769.     POP    D
  770.     POP    B        ; Restore the registers
  771.     RET
  772. ;.....
  773. ;
  774. ;
  775. ; Inline print routine
  776. ;
  777. ILPRT:    XTHL            ; Set 'HL' to point to message
  778. ;
  779. ILPLP:    MOV    A,M        ; Get a character from message
  780.     CALL    AOUT2        ; Output it
  781.     INX    H        ; Point to next character
  782.     MOV    A,M        ; Check for end of message
  783.     ORA    A        ; (00H marks end of message)
  784.     JNZ    ILPLP
  785.     XTHL            ; Get proper return address onto stack
  786.     RET            ; Then return to program
  787. ;.....
  788. ;
  789. ;
  790. ; Test for legal drive or end of drives
  791. ;
  792. TDRIVE:    PUSH    H
  793.     PUSH    D
  794.     PUSH    B
  795.     INR    A
  796.     LXI    H,DTABL        ; Point to table
  797.     LXI    D,17        ; 16 bytes per table plus 1 for drive no
  798. ;
  799. TDRIV0:    DCR    A        ; Adjust (A)
  800.     JZ    ISD
  801.     DAD    D        ; Not correct, index to next drive
  802.     JMP    TDRIV0
  803. ;
  804. ISD:    MOV    A,M        ; Get drive no.
  805.     ORA    A        ; 00=skip, <> 0 = OK
  806.     POP    B
  807.     POP    D
  808.     POP    H
  809.     RET
  810. ;.....
  811. ;
  812. ;
  813. ; To display or not to display, that is the question!
  814. ;
  815. TUSER:    PUSH    H
  816.     PUSH    D
  817.     PUSH    B
  818.     LDA    TRYDRV
  819.     LXI    H,DTABL        ; Point to table
  820.     LXI    D,17        ; 16 bytes per table plus 1 for drive
  821. ;
  822. TUSER0:    DCR    A        ; Adjust (A)
  823.     JZ    ISU
  824.     DAD    D        ; Not correct, index to next drive entry
  825.     JMP    TUSER0
  826. ;
  827. ISU:    INX    H
  828.     LDA    CTU        ; Get user no.
  829.     MVI    D,00        ; Set up offset
  830.     MOV    E,A
  831.     DAD    D        ; Add it to pointer
  832.     MOV    A,M        ; Read in user's on/off display byte
  833.     ORA    A        ; 00=skip, <> 0 = OK
  834.     POP    B
  835.     POP    D
  836.     POP    H
  837.     RET
  838. ;.....
  839. ;
  840. ;
  841. COLUMN:    DB    MAXCOL        ; Column counter
  842. SAVSAT:    DB    0        ; Storage for system attribute flag
  843. SAVRAT:    DB    0        ; Storage for read only attribute flag
  844. CTU:    DB    0        ; Current try user number
  845. CUN:    DB    0        ; Currently logged-in user number
  846. FIRST:    DB    0        ; First time use of 'AOUT' (for CR/LF)
  847. MAXTEMP:DB    0        ; Maximum try user number
  848. MFLAG:    DB    0        ; Flag set to non-zero if file is found
  849. ORIGCTU:DB    0        ; Original current try user number
  850. TRYDRV:    DB    0        ; Number of drive being tried
  851. UDNUM:    DB    0        ; User/drive number is saved here
  852. FNDFIL:    DB    0        ; FOUND A FILE = FF
  853. ;
  854.     DS    64        ; 32 level stack should be enough room
  855. ;
  856. STACK:    DS    2
  857. ;
  858. ;
  859.     END
  860. ;
  861. ;
  862. ;
  863. ;
  864. ; Line numbers containing untranslated opcodes:
  865. ;
  866. ;
  867.