<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Tue, 02 Jun 1981 (Tues:00day) 0018-EDT
From   : PLATTS@WHARTON-10 (Steve Platt)
Subject: details of search first/next

  FILE SEARCHING in CP/M
 
  Ok, I'm using an old listing of a slightly modified BDOS from CP/M 1.4,
so much of the following might not be exactly the same for newer CP/M's.
But it may give you an idea of what to look for.
 
  CP/M has two calls to search for ambiguous file names (AFN's) in a
directory structure:
      A <- Bdos(17,fcbaddr)   ; find first
      A <- Bdos(18,fcbaddr)     ; find next
Some notes on these:  Each returns a value, that value mod 4 being
the index into the data in the current DMA area of the found file.
(As such, any data in the current DMA area is smashed.)
(Also, DMAaddr + (RA mod 4)*32 gives the fcb of the found file.)
  Finally, it should be noted that the extent# is also checked -- when
using these calls, stick a 00 there if you only want the *first*
occurrance of each file; however, if you are writing a SIZE function of
some sort, you'll want a "?" there (match any extent).
  ** implementation **
  As you may have guessed, BDOS is essentially a router -- it takes
the function code you pass it and jumps to an address in a table.  For
the version I have, the code for 17 and 18 is roughly:

   call17:
       call selfil  ;all-purpose file finder
       mvi  c,13    ;counter for #chs to check - 1(byte 0) +
                       ; 8(name) + 3(typ) + 1(ext)
       call srcdir  ;saves passed DE as FCBTMP, then calls SRCNXT.
                    ;also in general, init's the search process.
       ret

  call18:
       de <- fcbtmp  ;was set by prev call to 17, remember? essentially,
                       ; this means that it really doesn't matter what
                       ;you pass it in DE.  I have never tried this out...
       call selfil     ;again, set up the file-finder (insures logged-in
                       ;drive, etc.)
       call srcnxt
       ret

srcnxt:
       ;just find the next file using the FCB sent to it. (remember
       ;that for bdos(18), it'll still use the one passed from
       ;bdos(17).

Now the documentation I'm looking at (TPM doc. *not* CP/M doc.!) says
"No other intermediate TPM calls are allowed between function 17 and 18
or 18 and the next call on 18.", however, the only problems appear to
be with overlapping disk functions. (You may screw up communication
between 17 and 18 if you do.)  In fact, if you are very careful, almost
anything may be do-able -- just keep a seperate DMA area for whenever
you call 17 or 18, and don't play with the FCB you are comparing against.
Upon thought, I can think of calls to almost every disk primitive:
consider ERA *.* for deletion while searching, PIP B:=A:*.* for
reading and writing, as well as opening/closing, etc.  Again, just keep
the 17/18 data completely seperate ! (and that includes
copying any FCB's you find for use to another location...)
 
If you play with any of this and find anything out (definite) please
confirm the above.  Again, I am not sure how CP/M 2.2
treats this.
 
   ---Steve
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>