Finding files on CP/M....

416 views
Skip to first unread message

Jay Cotton

unread,
Feb 27, 2021, 7:32:56 PM2/27/21
to retro-comp
If you guys are anything like me, (pack rat), I have tons of files on my CP/M drives.
So finding where the heck I put a file has become an issue.  

Mostly I put similar types of files on the same drive, say J: for all the fortran
and K: for all the cobal etc.

Still its difficult to remember/local where they are. 

So, I coded up a 'work alike' find program to help locate files.  Its a bit
more handy than CP/M 3 dir command and much better than CP/M 2
dir.

Here is a link to the code.  I put a find.hex file there, you can put that on your
CP/M drive and say "load find" and it converts it to a command.

Please file bug reports on github, it makes things easer for me.

https://github.com/jayacotton/macro-library/tree/master/test/find

tnx
JC

Richard Deane

unread,
Feb 28, 2021, 7:30:05 AM2/28/21
to Jay Cotton, retro-comp
Superfile (sf) is a good tool too.

--
You received this message because you are subscribed to the Google Groups "retro-comp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to retro-comp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/retro-comp/6180ac76-a259-4213-9b48-7a37596526dan%40googlegroups.com.

Kurt Pieper

unread,
Feb 28, 2021, 8:50:04 AM2/28/21
to retro-comp
Hi Jay,
I don't have a GitHub account.

Here is some info.
P is the last drive at cp / 2.2 right?
See photo.


greeting
Kurt
kaypro-cpnet.jpg

Kurt Pieper

unread,
Feb 28, 2021, 9:51:04 AM2/28/21
to retro-comp
Here is a test on Karl's very fast sc22c.
find_cpm22.jpg

sc22c_find.jpg

Q does not exist.
It's a very good tool.

Gruß
Kurt

Jay Cotton

unread,
Feb 28, 2021, 1:08:13 PM2/28/21
to retro-comp
I pushed a fix that limits the number of drives to 10.  a through j, this is not ideal but it will stop the drive select error.

jc

Alan Cox

unread,
Feb 28, 2021, 1:28:59 PM2/28/21
to Jay Cotton, retro-comp
On Sun, 28 Feb 2021 at 18:08, Jay Cotton <lbmg...@gmail.com> wrote:
I pushed a fix that limits the number of drives to 10.  a through j, this is not ideal but it will stop the drive select error.

Maybe use BDOS 24 (DRV_LOGINVEC). It will return you a bitmap in HL of the drives. You'd still need to catch and handle the errors but it ought to be less often and look better.



Jay Cotton

unread,
Feb 28, 2021, 1:40:04 PM2/28/21
to Alan Cox, retro-comp
I have looked at that a dozen times and never really read what it does.
I see 'log in' and think of a user,  not a disk drive.

So, RTFM or better.

tnx for the help
jc

Kurt Pieper

unread,
Feb 28, 2021, 2:13:35 PM2/28/21
to retro-comp
Hi jay,

did you look at the picture?

Nothing is found in drive G :.
It is displayed in the H: drive.

The drives are moved.

I'll stick with it, the idea is good.

greeting
Kurt

Jay Cotton

unread,
Feb 28, 2021, 3:26:37 PM2/28/21
to Kurt Pieper, retro-comp
Oh, I see. There is nothing on your H: drive, but it's listed on the G: drive.  Is that correct ?


JC

--
You received this message because you are subscribed to a topic in the Google Groups "retro-comp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/retro-comp/1z5qN01-iEQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to retro-comp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/retro-comp/76561582-c7b2-4fe7-8781-4e21237b9927n%40googlegroups.com.

Wayne Warthen

unread,
Feb 28, 2021, 3:41:54 PM2/28/21
to retro-comp
On Sunday, February 28, 2021 at 10:28:59 AM UTC-8 Alan Cox wrote:
On Sun, 28 Feb 2021 at 18:08, Jay Cotton <lbmg...@gmail.com> wrote:
I pushed a fix that limits the number of drives to 10.  a through j, this is not ideal but it will stop the drive select error.

Maybe use BDOS 24 (DRV_LOGINVEC). It will return you a bitmap in HL of the drives.

BDOS 24 will only indicate the drives that have been referenced (logged in) since the last warm start (which happens all the time in CP/M).  I am not aware of any way to get a list of the drives that CP/M thinks "exist".
 
You'd still need to catch and handle the errors but it ought to be less often and look better.

This is definitely possible in CP/M 3, but I am not aware of any way to catch drive errors in CP/M 2.2?  Is there a way?

Thanks,

Wayne 

 

Jay Cotton

unread,
Feb 28, 2021, 4:22:15 PM2/28/21
to Wayne Warthen, retro-comp
I can confirm that DRV_LOGINVEC only returns a 1 for drives that have been visited.

So, not a useful as I had hoped.

jc


--
You received this message because you are subscribed to a topic in the Google Groups "retro-comp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/retro-comp/1z5qN01-iEQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to retro-comp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/retro-comp/1e08da81-b453-4223-955f-12e5538ec634n%40googlegroups.com.

Douglas Miller

unread,
Feb 28, 2021, 4:36:01 PM2/28/21
to retro-comp
CP/M 2.2 had some "undefined" pointers near the start of the BDOS where one could intercept errors. I forget the details, but there's probably some documentation out there somewhere.

The BIOS is probably the only authority on what drives exist. You could call the BIOS SELDSK routine and check the return value for error (I think a NULL DPH address). But, it depends on the BIOS implementation as to whether SELDSK is an "active" routine or not... e.g. for floppy drives it might try to read the floppy to get diskette format information.

On Sunday, February 28, 2021 at 2:41:54 PM UTC-6 Wayne Warthen wrote:
On Sunday, February 28, 2021 at 10:28:59 AM UTC-8 Alan Cox wrote:
On Sun, 28 Feb 2021 at 18:08, Jay Cotton wrote:
I pushed a fix that limits the number of drives to 10.  a through j, this is not ideal but it will stop the drive select error.

Maybe use BDOS 24 (DRV_LOGINVEC). It will return you a bitmap in HL of the drives.

Jay Cotton

unread,
Feb 28, 2021, 5:16:23 PM2/28/21
to Douglas Miller, retro-comp
I have found a way to get the drives that CP/M knows about.  
It's a bit hairy but it works.  Only issue is, it's not portable.   It has be built for the system you are running on and 
for the CP/M you have built.

The MAGIC number is the bass address of BIOS.  In my current case that is E600, but on other machines it
could be different.
This works with CP/M 2.2 and ZSDOS 1.1.  It could work with CP/M 3 (untested).

Wayne:  I think this is a good candidate for addition to RomWBW.

magic   equ     0e600h
seldskf equ     magic +(3*9)
        mov     c,a
        call    seldskf

This will attempt to select the drive in REG C and return HL with a bitmap
or NULL if the drive is not populated.

Here is a test run using the above call
C>seltest
1110110011100100
1110110011110100
1110110100000100
1110110100010100
1110110100100100
1110110100110100
1110110101000100
1110110101010100
1110110101100100
1110110101110100
0
0
0
0
0
0

As you can see, any drive that is not 'physically' connected returns a NULL in hl.  

Douglas:  Not sure how to detect the presence of CP/Net drives, Have not tested this on a CP/Net machine.


 

--
You received this message because you are subscribed to the Google Groups "retro-comp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to retro-comp+...@googlegroups.com.

Jay Cotton

unread,
Feb 28, 2021, 5:18:55 PM2/28/21
to retro-comp
I should point out that I picked up the trick by reading the CPM 2.2 source code.  

Douglas Miller

unread,
Feb 28, 2021, 5:20:09 PM2/28/21
to retro-comp
Traditionally, the JMP at location 0 is used to find the BIOS in a (fairly) platform-independent way. That JMP at 0 should be referencing the warm boot entry, i.e. BIOS+3. There is a lot of legacy software that does this.

Douglas Miller

unread,
Feb 28, 2021, 5:24:32 PM2/28/21
to retro-comp
Yes, this is what I was trying to suggest with the SELDSK comment. Note, SELDSK returns a pointer to the DPH structure for the drive, or NULL if no drive exists.

Yes, for CP/NET this will require expansion. You can check the BDOS VERSION code for the presence of CP/NET, then consult the drive maps by getting the network config table. I can provide some examples, if you desire to pursue this.

On Sunday, February 28, 2021 at 4:16:23 PM UTC-6 Jay Cotton wrote:
...
magic   equ     0e600h
seldskf equ     magic +(3*9)
        mov     c,a
        call    seldskf

This will attempt to select the drive in REG C and return HL with a bitmap
or NULL if the drive is not populated.

...

Jay Cotton

unread,
Feb 28, 2021, 5:36:47 PM2/28/21
to retro-comp
Douglas:

Yes please provide some sample code.  I'd like to include as complete a search as is possible.  

And, JMP at 0 is to obvious.  I did not even think about is.  Must be getting old.

tnx
jc

Douglas Miller

unread,
Feb 28, 2021, 6:07:14 PM2/28/21
to retro-comp
Pardon the Intel mnemonics, but as you know that's my thing. I'm sure you can translate...

        mvi     c,getver ; FNC 12
        call    bdos
        mov     a,h
        ani     02h
        jz      nocpnt ; no networked drives
...whatever...
        mvi     c,cfgtbl ; FNC 69
        call    bdos
        shld    netcfg
...whatever...
        lhld    netcfg ; drive maps start at +2 (A:)
        mvi     b,16 ; 16 drives possible, two bytes each
loop:   inx     h
        inx     h
        mov     a,m
        ani     80h ; is drive networked?
        jz      skip
... add drive to list...
skip:   djnz    loop
nocpnt: ...; process local drives, excluding
           ; networked drives that override them.

That's the basic premise. CP/NET drives that are networked will override (hide) the local drive (if it exists), so no need to call BIOS SELDSK in those cases.

Kurt Pieper

unread,
Feb 28, 2021, 6:21:05 PM2/28/21
to retro-comp
I once wrote a small basic program and it works with MBASIC or BASCOM

Here is an excerpt:

0370 REM > HAUPTMENUE<
0380 REM<
01000   KOPFZ$="F I N D - F I L E  ":GOSUB 10000<
01010         PRINT:PRINT:PRINT "Suche alle *.HEX Files !"<
01020         PRINT "A:":FILES "A:"+PROG$<
01030         PRINT:PRINT "B:":FILES "B:"+PROG$<
01040         PRINT:PRINT "C:":FILES "C:"+PROG$<
01050         PRINT:PRINT "D:":FILES "D:"+PROG$<
01055         PRINT:PRINT "E:":FILES "E:"+PROG$<
01060         PRINT:PRINT "F:":FILES "F:"+PROG$<
01070         PRINT:PRINT "G:":FILES "G:"+PROG$<
01080         PRINT:PRINT "ENDE"
01090   END                       
10000   PRINT HOME$;RVS$;" ";KOPFZ$;SPACE$(63-LEN(KOPFZ$));<
10010   PRINT "Datum: ";FNDATE$(DATUM$);" ";NRM$;CLEOS$<
10100   RETURN<
65000   IF ERL<10000 AND ERR=53 THEN RESUME NEXT

Rename the findx.txt program find.com.
BRUN.COM is required!

Gruß
Kurt
findx.txt

David Reese

unread,
Feb 28, 2021, 6:31:06 PM2/28/21
to retro...@googlegroups.com
Looks pretty good, but does it span all USERs?  I use USER areas to segregate files by work type:  text and word processing, BASIC, FORTRAN, etc., all go on separate USER areas on a given drive.

Thanks,
David

Jay Cotton

unread,
Feb 28, 2021, 7:03:18 PM2/28/21
to retro-comp

David:

The user area is TBD at this point.  I have not got to that, still hacking through the jungle of drive select.  Soon, maybe by end of the
week.  We shall see.

jc

David Reese

unread,
Feb 28, 2021, 8:54:17 PM2/28/21
to retro...@googlegroups.com
On 2/28/21 6:03 PM, Jay Cotton wrote:
>
> David:
>
> The user area is TBD at this point.  I have not got to that, still
> hacking through the jungle of drive select.  Soon, maybe by end of the
> week.  We shall see.
>
> jc
>
>
>
Cool!  Glad it is under consideration.

Richard Deane

unread,
Mar 1, 2021, 3:22:05 AM3/1/21
to Kurt Pieper, retro-comp
There is also a FIND utility in assembler, used as an example, in the book - The Programmer's CP/M handbook by Andy Johnson Laird. Can be found here. http://www.cpm.z80.de/source.html

Note: this skims through directory blocks to find files, and tries to skip directory entries for all but the first extent. It works where all files are written by CP/M, but fails for files written to disk by CPMTOOLS where the file length is more than one extent (64k I think). I am certain that this is a CPMTOOLS bug, but have not been able to progress technical debugging. This is one of the reasons I prefer to transfer files in via serial link, to avoid using cpmtools for disk writing.

Richard



--
You received this message because you are subscribed to the Google Groups "retro-comp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to retro-comp+...@googlegroups.com.

Jay Cotton

unread,
Mar 7, 2021, 1:23:39 AM3/7/21
to retro-comp
Just updated the REPO with a much better version of find.  There is a find.hex file in there that will load on CP/M and
work without all the hassle of learning how to build it on linux/cygwin  

jc

Phillip Stevens

unread,
Mar 1, 2022, 7:02:23 AM3/1/22
to retro-comp
Jay Cotton wrote:
Just updated the REPO with a much better version of find.  There is a find.hex file in there that will load on CP/M and work without all the hassle of learning how to build it on linux/cygwin

Hi Jay,
sorry I was late to the party.

I've been playing around with your find utility to get it to build across more compilers and platforms with z88dk.

So now it works for Z80 with either sccz80 plus z88dk classic library OR the zsdcc compiler plus z88dk classic library.
The result is a slightly smaller binary for zsdcc, but it is always educational to read the assembly from the two compilers and compare which one did better where.

I've also built it for 8085 CPU using sccz80.
This was the real purpose so that I could have a find for the 8085 CPU Module.

Anyway, thanks again for writing it for us.
Cheers, Phillip

ladislau szilagyi

unread,
Mar 1, 2022, 11:46:27 AM3/1/22
to retro-comp
Hi Phillip,

I'm also late to the party...but I am very happy to be told about this 'find' utility... I missed-it so much!
Only a small comment about the usability of this very useful program...
I jumped to try-it before reading carefully the readme (and I suppose I'm not the only one around here who was this habit :).
What happened: typing A>find *.c<CR>, I got a list of some of the files from all my disks, and at the end of it an alarming "Bdos Err On I: Select" message.
Hoping to get some help, I tried A>find<CR>. This time, I got a smaller list, followed by the same error message.
Only then, I went to read the readme.

It's a pity that the default response is not similar with the one provided after using the "help" option : >find -h
Also, the parsing of the command line should be improved...I noticed that the "Bdos Err..." message appears randomly after messing up the parameters of the command...

Anyway, thanks Jay & Phillip, "find" is a very useful utility...  
Ladislau

ladislau szilagyi

unread,
Mar 3, 2022, 12:55:38 AM3/3/22
to retro-comp
Thanks Jay for fixing this issue!

Help is provided now as default response.

Ladislau

Reply all
Reply to author
Forward
0 new messages