PDA

View Full Version : Autoexec.bat for cpm?



8008guy
March 5th, 2018, 04:36 AM
Does cpm have an equivalent way to auto start and run a program on power up?

krebizfan
March 5th, 2018, 04:58 AM
CP/M 3 would run PROFILE.SUB at bootup. Insert whatever commands you need into PROFILE.SUB and that should give the desired result.

daver2
March 5th, 2018, 05:11 AM
On earlier versions of CP/M you could insert a command into the command line buffer and (when loaded) that command would be executed. The usual command was to execute a SUBMIT file.

In some cases, the machine supplier would provide some kind of CP/M utility to perform this magic automatically. If not, the patches to do it yourself were published.

Dave

fritzeflink
March 6th, 2018, 11:56 AM
http://oldcomputers.dyndns.org/public/pub/cdrom/cpm/simtel/sigm/vols200/vol234/index.html

Auto inserts an initial command into the CCP command line
buffer on the default drives system track, so that the command
will be executed every cold boot. Note that the bios must reset
the command length byte to zero on warm boot, otherwise the
command will be executed EVERY boot.

8008guy
March 9th, 2018, 07:49 PM
Thanks a ton guys.

Len

deramp5113
March 10th, 2018, 04:59 AM
Here’s a video describing more about automatically running a command line on cold and/or warm boot in CP/M 2.2. The concepts are applicable to most any CP/M 2.2, but note that the addresses shown are specific to CP/M on the Altair.

https://m.youtube.com/watch?v=RxrPmbsmyBs&feature=youtu.be

The video shows running MOVCPM to get the CP/M image to modify, but you can also get the CP/M image by running SYSGEN, selecting the boot drive as the source, and then pressing return to exit to CP/M. At this point, save the image to a file with the SAVE command to then turn around and load the image for patching using DDT as shown in the video.

Finding the location of the MODE byte to patch is a bit more work, but not too difficult. Unfortunately, it’s not going to be the same address as the Altair CP/M example.

I can help you find the mode byte location for your CP/M and patch one of the auto-run configuration programs to work on your machine if you need.

Mike

durgadas311
March 10th, 2018, 05:57 AM
Note that the CP/M 2.2 CCP has two entry points (two JMPs at the beginning). While not well documented, the first is the "cold start" one and will execute any command in the command buffer (as described previously), while the second entry is the "warm start" and will ignore any command pre-initialized in the buffer. This was the intended method of handling such setups, so that the BIOS simply chooses to jump to "CCP" or "CCP+3" depending on the context.

The command buffer normally starts immediately after these two JMPs. The byte at CCP+6 should be 7FH to indicate the total length of the command buffer, next the default distro has 00H to indicate no command in the buffer. You change CCP+7 to indicate the total length of the command, and then put the command characters starting at CCP+8.

Some vendors did make their own custom CCP, although DRI did recommend not changing this part of the CCP image. Also, some vendors did not place the CCP in the boot tracks, so if you go examining the disk sectors directly you may not find what you expect. As deramp5113 mentions, SYSGEN is usually the easiest way to handle this, although it takes more steps. But, some (most?) vendors customized SYSGEN as well, so you may have to hunt around for the CCP. A conforming CCP should have those two JMPs, then (usually) 07FH, then 00H, then a copyright message like "Copyright 1979 (c) by Digital Research" (although it might have been customized to include the vendor). It's not a terribly unique pattern, but can be helpful. The BDOS and BIOS will not look like that.

8008guy
March 11th, 2018, 10:09 AM
Awesome, very helpfull.

Will watch the video.

Len

8008guy
March 11th, 2018, 10:38 AM
Great job on the video Mike

The copy of cpm I want to modify is the one Grant Searle did for his minimalist cpm on a breadboard machine.

Not sure if you have seen my microtv clock... For anyone but me it's a lot of work to get running.

http://www.chronworks.com/TvClock/

Right now I have a little terminal built in that I plug in a keyboard and monitor to bring up cpm and start the clock. The cf card is partitioned into 8 drives. I have the clock sw on e: I can put the software on the a: drive if necessary. Can I assume that it's possible to run a program from any drive with e:clock as the atart up command?

Anywho, that's a bit of background for you.

Cheers,

Len

durgadas311
March 11th, 2018, 11:20 AM
Can I assume that it's possible to run a program from any drive with e:clock as the atart up command?


Yes, the command will be interpreted exactly like any command you type at the CCP prompt. As long as it does not have any prerequisites (i.e. you will be running that command on a cold boot, so something like "SAVE xx file" doesn't really do anything useful)

deramp5113
March 11th, 2018, 01:25 PM
Great job on the video Mike

The copy of cpm I want to modify is the one Grant Searle did for his minimalist cpm on a breadboard machine.

Not sure if you have seen my microtv clock... For anyone but me it's a lot of work to get running.

http://www.chronworks.com/TvClock/

Right now I have a little terminal built in that I plug in a keyboard and monitor to bring up cpm and start the clock. The cf card is partitioned into 8 drives. I have the clock sw on e: I can put the software on the a: drive if necessary. Can I assume that it's possible to run a program from any drive with e:clock as the atart up command?

Anywho, that's a bit of background for you.

Cheers,

Len

Looks like Grant's BIOS jumps to the first jump in the CCP when entering CP/M (both cold and warm boot) which WILL run a command line. His BIOS has no flags for controlling options for executing or not, or for selectively running for cold and/or warm boot.

In Grant's CP/M implementation, the CCP is at D000h in memory. To do what you want, follow "Part 2 Putsys" in the "Installing CP/M" section on Grant's website. Then, before running PUTSYS, put your command string ("e:clock") into memory starting at D008h. Follow the ASCII string with a zero byte. Put the length of the string (7) at location D007. Then run PUTSYS. Upon rebooting (both cold and warm), e:clock will be run.

Let me know how it goes.

Mike

8008guy
March 11th, 2018, 02:54 PM
Looks like Grant's BIOS jumps to the first jump in the CCP when entering CP/M (both cold and warm boot) which WILL run a command line. His BIOS has no flags for controlling options for executing or not, or for selectively running for cold and/or warm boot.

In Grant's CP/M implementation, the CCP is at D000h in memory. To do what you want, follow "Part 2 Putsys" in the "Installing CP/M" section on Grant's website. Then, before running PUTSYS, put your command string ("e:clock") into memory starting at D008h. Follow the ASCII string with a zero byte. Put the length of the string (7) at location D007. Then run PUTSYS. Upon rebooting (both cold and warm), e:clock will be run.

Let me know how it goes.

Mike


Thanks Mike,

Tomorrow I will make a back up of my cf card and give it a try.

So what you are telling me is that one I make the change I wont be able to warm boot back to a cpm prompt?

Len

durgadas311
March 11th, 2018, 03:09 PM
If Grant's BIOS doesn't differentiate between warm and cold start, then you are stuck - sort of. Most CP/M BIOSes, and I think Grant's also, reload the CCP from disk each warm boot. They really have to, since CP/M programs are free to use the memory normally occupied by the CCP. So, if your CCP image on disk contains this command, and your BIOS doesn't jump to CCP+3 on warm start, then you're kinda stuck. But, if you make a simple modification to the BIOS so that warm boot jumps to CCP+3 (and leave cold boot to jump to CCP+0), then you should have the flexibility to enter and exit clock mode as desired.

8008guy
March 11th, 2018, 06:48 PM
If Grant's BIOS doesn't differentiate between warm and cold start, then you are stuck - sort of. Most CP/M BIOSes, and I think Grant's also, reload the CCP from disk each warm boot. They really have to, since CP/M programs are free to use the memory normally occupied by the CCP. So, if your CCP image on disk contains this command, and your BIOS doesn't jump to CCP+3 on warm start, then you're kinda stuck. But, if you make a simple modification to the BIOS so that warm boot jumps to CCP+3 (and leave cold boot to jump to CCP+0), then you should have the flexibility to enter and exit clock mode as desired.

Can the bios be modified on the system in-flight? Or do I need to assemble that elsewhere? I supose I'm at the edge of the RTFM area...

Len

deramp5113
March 11th, 2018, 07:29 PM
Thanks Mike,

Tomorrow I will make a back up of my cf card and give it a try.

So what you are telling me is that one I make the change I wont be able to warm boot back to a cpm prompt?

Len

How does your program exit? If it exits with a jump to zero (i.e., warm boot), then you are correct, you won’t be able to exit to a CP/M prompt. If it exits with a RET instruction to the CCP, then you will get a prompt.

In either case, you are better off patching the BIOS to jump to the 2nd CCP entry for warm start. Shouldn’t be hard to patch in memory as long as there are a few bytes of spare space at the end of the BIOS to put the patch.

Mike

8008guy
March 11th, 2018, 07:59 PM
How does your program exit? If it exits with a jump to zero (i.e., warm boot), then you are correct, you won’t be able to exit to a CP/M prompt. If it exits with a RET instruction to the CCP, then you will get a prompt.

In either case, you are better off patching the BIOS to jump to the 2nd CCP entry for warm start. Shouldn’t be hard to patch in memory as long as there are a few bytes of spare space at the end of the BIOS to put the patch.

Mike

Not sure how it exits, the code was generated using a c compiler. I'd have to dissassemble something simple to see.

I'm currently reading the cpm 2.2 manual trying to see how this all works, lotsa fun! I have my second system about ready to run. I will see where I can get to tomorrow.

Thanks for all the help. This is fun.

Len

durgadas311
March 12th, 2018, 04:45 AM
Can the bios be modified on the system in-flight? Or do I need to assemble that elsewhere? I supose I'm at the edge of the RTFM area...

Len

Did you pick up a binary BIOS image to flash on to disk? Or compile from assembler source code? If you can point me at what you used I could patch it for you.

8008guy
March 12th, 2018, 01:40 PM
Did you pick up a binary BIOS image to flash on to disk? Or compile from assembler source code? If you can point me at what you used I could patch it for you.

All the source files are here:

http://searle.hostei.com/grant/cpm/

Specifically:

http://searle.hostei.com/grant/cpm/z80sbcFiles.zip

I have to do some mods to the monitor as well so it doesn't hang waiting for the <space> <X> and <Y> to boot CPM. There is a monitor of basic you can choose from. I was thinking a time out and then default to a CPM boot whould be good.

I've got my second system up and running the same CF image that my clock runs. I built two CPM SBC's originally. If anyone is interested the PCB layouts are available, I can also post gerbers. It's a cute little machine.

len

durgadas311
March 12th, 2018, 02:37 PM
I'm not sure what all is required to build a system image, but here's updated source (ASM) files for CBIOS, along with LST and HEX files. I also added a "diffs" file to show what I changed. I went for minimal changes rather than elegance, etc. I used ZMAC, so the HEX files are in traditional 16-byte lines instead of 24. I also had to change the 'list' symbol in CBIOS because that's a reserved word.

44229

I don't have anyplace to test it, but I think someone can look at the diffs and/or code and see if looks right. Hope this helps.

deramp5113
March 12th, 2018, 03:55 PM
I'm not sure what all is required to build a system image, but here's updated source (ASM) files for CBIOS, along with LST and HEX files. I also added a "diffs" file to show what I changed. I went for minimal changes rather than elegance, etc. I used ZMAC, so the HEX files are in traditional 16-byte lines instead of 24. I also had to change the 'list' symbol in CBIOS because that's a reserved word.

44229

I don't have anyplace to test it, but I think someone can look at the diffs and/or code and see if looks right. Hope this helps.

Looks good to me. You can simply choose your modified cbios.hex file in step 2 of Part 2 PUTSYS.

Mike

8008guy
March 12th, 2018, 06:38 PM
Cool! Will grab it and test it out tomorrow.

Len

8008guy
March 13th, 2018, 03:13 PM
Ok, I'm working through the process and am on the system. The transient apps don't include getsys, putsys, movcpm, and sysgen. Grant did provide a version of putsys that is used before cpm is up and running. I assume that I can assemble that to a com file. I assume that getsys is the "reverse" of putsys and can be created from the template in the 2.2 manual.

Are movcpm and sysgen system independant and rely on get/putsys? Where do I find those binaries, or asm files?

len


len

durgadas311
March 13th, 2018, 04:22 PM
SYSGEN and MOVCPM are the standard commands outlined by DRI, provided with the 8" SDSS floppy version of CP/M, but for any other type of disk they need to be customized. I'm not sure about Grant's utilities, but "PUTSYS" is usually the equivalent of the SYSGEN with the "from memory, to disk" option. I don't know enough about Grant's system, but depending on how PUTSYS was written it might compile into a working COM file. But you still need to give the system image to PUTSYS somehow.

durgadas311
March 13th, 2018, 04:28 PM
Ok, I'm working through the process and am on the system. The transient apps don't include getsys, putsys, movcpm, and sysgen. Grant did provide a version of putsys that is used before cpm is up and running. I assume that I can assemble that to a com file. I assume that getsys is the "reverse" of putsys and can be created from the template in the 2.2 manual.

Are movcpm and sysgen system independant and rely on get/putsys? Where do I find those binaries, or asm files?

len


len

I took a quick look at PUTSYS, there isn't much there. it is standalone and so does not call CP/M at all. You probably can't return to CP/M after running it. It looks like all it does is write the contents of memory from 0D000H through 0FFFFH onto the first sectors of the disk (CF card). So, you must get CP/M loaded into memory first. The HEX files all specify addresses, so if there is a load function (in the ROM) that will put each HEX file into it's specified address in memory, then you should be able to load the three CP/M HEX files (CCP, BDOS, BIOS), then load PUTSYS and run it. But I'm guessing here - someone that's actually done it would be better to answer.

8008guy
March 13th, 2018, 06:22 PM
i'm going to set up an emulator. There are a few of things thngs I need to get working first. I don't think Grant expected anyone to modify the cpm install.

durgadas311
March 14th, 2018, 05:10 AM
I think the PUTSYS method is just how Grant did modifications to the CP/M install. I'm not sure if you are using all of his code, but his monitor ROM code will automatically download (load into memory) any HEX files that are pasted to the console serial port. Assuming you have some sort of terminal emulator window open on the main serial port, and you see the '>' monitor prompt, you should be able to just paste the HEX files into that window one by one. How you get each one into your clipboard will depend on what OS you are running on your host computer. So, I think the procedure is (order is significant!):

1) start Z80 and get monitor prompt ">"
2) copy CPM22.HEX to the clipboard, paste into Z80 terminal window
3) copy CBIOSxxx.HEX to the clipboard, paste into Z80 terminal window
4) copy PUTSYS.HEX to the clipboard, paste into Z80 terminal window
5) enter monitor command "G5000" to run PUTSYS

Hopefully, someone familiar with Grant's code can confirm this.

8008guy
March 14th, 2018, 06:13 PM
I think the PUTSYS method is just how Grant did modifications to the CP/M install. I'm not sure if you are using all of his code, but his monitor ROM code will automatically download (load into memory) any HEX files that are pasted to the console serial port. Assuming you have some sort of terminal emulator window open on the main serial port, and you see the '>' monitor prompt, you should be able to just paste the HEX files into that window one by one. How you get each one into your clipboard will depend on what OS you are running on your host computer. So, I think the procedure is (order is significant!):

1) start Z80 and get monitor prompt ">"
2) copy CPM22.HEX to the clipboard, paste into Z80 terminal window
3) copy CBIOSxxx.HEX to the clipboard, paste into Z80 terminal window
4) copy PUTSYS.HEX to the clipboard, paste into Z80 terminal window
5) enter monitor command "G5000" to run PUTSYS

Hopefully, someone familiar with Grant's code can confirm this.

I will still need to modify the input buffer for the ccp, right?

Tonight I tried running movcpm, I got a copy from the ver 2.2 cpm of the z80pack, and it hung. I used ddt to remove the serialization checks, no luck either.

I did email Grant to see if he can help with the utilities.

Len

8008guy
March 14th, 2018, 06:28 PM
Arggg.... Rewatching Mikes video on using ddt I now realize I probably didn't patch movcmp to ignore the serial check. I just changed it in memory.

So can I assume that when I load and modify a file in memory the I have to exit to cpm. Go0. Then I have to do a save command to get it back to disk?

Len

durgadas311
March 14th, 2018, 09:55 PM
I will still need to modify the input buffer for the ccp, right?

Tonight I tried running movcpm, I got a copy from the ver 2.2 cpm of the z80pack, and it hung. I used ddt to remove the serialization checks, no luck either.

I did email Grant to see if he can help with the utilities.

Len

The problem with MOVCPM is that the image of CP/M 2.2 is actually embedded in MOVCPM. So by taking MOVCPM from z80pack you got the wrong BIOS and probably the wrong load addresses. Grant's CP/M is not setup for MOVCPM, as far as I can tell.

So, stepping back a bit, it looks like Grant's CP/M is not setup to use MOVCPM or SYSGEN (since neither is provided). It looks like there is really only one direction for the "sysgen" process: from HEX file to PUTSYS to CF card. Given that, it seems the two methods for patching the CCP is to either patch the boot sectors of the CF card directly, or to patch the HEX file CPM22.HEX before you "sysgen" that onto the CF card. Note that I'm using lower-case "sysgen process" rather than upper-case SYSGEN command.

Patching a HEX file is not really practical, and there appear to be no tools to reconstruct CPM22.HEX from a binary format. DDT will load HEX files, but I don't see any way to write/save that out to a HEX file.

There also does not exist a program to patch the CF card directly, either. I could figure out a way using Linux tools, but you'd have to plug the CF card into your host computer.

I haven't looked at the URL(s) talked about earlier, for that program to stuff a command into the CCP boot sectors, to see if it might work in this environment. I guess that's the next step. I also wrote a "disk patch" program that I used for such things, but would have to dust that off and convert it to whatever terminal type your terminal emulator runs... Actually, I could probably write a simple program to put a command into the CCP on the CF card for you, that would probably be easier than a general-purpose disk patch utility.

8008guy
March 15th, 2018, 04:38 AM
Ok, got you. I'll play around with this a bit now that I better understand what is happening.

Thanks

Len

durgadas311
March 15th, 2018, 05:48 AM
Ok, got you. I'll play around with this a bit now that I better understand what is happening.

Thanks

Len

Just so I'm up-to-date... Do you have a booting, working, CP/M right now? (with the new/patched BIOS?)

deramp5113
March 15th, 2018, 07:03 PM
Why canít you just upload your modified cbios.hex file as detailed in step 2 of PUTSYS of Grantís procdure at http://searle.hostei.com/grant/cpm/index.html#InstallingCPM ?

Mike

8008guy
March 15th, 2018, 07:15 PM
Not yet, will try over the weekend.

8008guy
March 15th, 2018, 07:19 PM
Why can’t you just upload your modified cbios.hex file as detailed in step 2 of PUTSYS of Grant’s procdure at http://searle.hostei.com/grant/cpm/index.html#InstallingCPM ?

Mike

I can, and will try soon. Although I also need to put the command line in the cpp buffer, right?

I also need to update the boot rom not to pause, or at least have a time out and then load.

In the mean time I have been reading up on the internals of cpm. I am interested in knowing the why's and how's.

Len

durgadas311
March 16th, 2018, 08:57 AM
This evening I will throw together a program to update a command into the CCP. But you should be able to run the new BIOS even without that.

durgadas311
March 16th, 2018, 12:50 PM
Here is a new version of an AUTO.COM program to stuff a command into the CCP on the CF card of a system based on Grant Searle's CP/M. I tested this on a simulation I have for another project, but it is also based on Grant's code. This system does not have the "CCP warm start" patch, so I was able to see the behavior in that case.

44362

This command works like that one in the URL, but I wrote this one from scratch so I don't expect it to be bug-for-bug compatible. The basic syntax is the same:


AUTO [command]

Where "command" is optional, and represents whatever command you want to run when CCP cold starts. With no command (i.e. an empty command) it will disable any auto-run command in the CCP.

Be sure to test this with an innocuous, builtin, command such as "DIR" first, or else you risk getting into an infinite loop as previously discussed (in case the BIOS patch is not there, or not working as expected).

Note that, as also previously discussed, whether or not the auto-command is triggered when running without the BIOS patch will depend on how the particular command runs and exits. Commands like "DIR" are builtin and never cause a warm boot. Some COM file commands, like STAT.COM, also don't ordinarily do a warm boot and so are "safe" (but annoying) without the BIOS patch.

Here's a quick example, again run on a system without the BIOS patch:


A>auto dir
AUTO - set command in CCP
Updated CCP command to "DIR"
A: ASM COM : COPY COM : DDT COM : DUMP COM
A: ED COM : CCP COM : LOAD COM : PIP COM
A: STAT COM : SUBMIT COM : XKILL COM : XSUB COM
A: CPMLDR COM : RESET ASM : CPM3 SYS : RESET PRN
A: RESET HEX : RESET REL : RESET SYM : RESET COM
A: TERMXT ASM : EDIT COM : TERMXT PRN : TERMXT HEX
A: TERMXT SYM : DOWNLOAD COM : AUTO COM : DOWNLOAD HEX
A: PRN : HEX
A>stat
A: R/W, Space: 7980k


A>asm
CP/M ASSEMBLER - v2.01
NO SOURCE FILE PRESENT

A: ASM COM : COPY COM : DDT COM : DUMP COM
A: ED COM : CCP COM : LOAD COM : PIP COM
A: STAT COM : SUBMIT COM : XKILL COM : XSUB COM
A: CPMLDR COM : RESET ASM : CPM3 SYS : RESET PRN
A: RESET HEX : RESET REL : RESET SYM : RESET COM
A: TERMXT ASM : EDIT COM : TERMXT PRN : TERMXT HEX
A: TERMXT SYM : DOWNLOAD COM : AUTO COM : DOWNLOAD HEX
A: PRN : HEX
A>auto
AUTO - set command in CCP
Updated CCP command to ""
A>asm
CP/M ASSEMBLER - v2.01
NO SOURCE FILE PRESENT

A>

Note how the ASM.COM command will always do a warm boot via jump to 0000h, and this always triggers (in this system) a re-run of the CCP command. On your system, with the BIOS patch, the command would/should not get executed until you actually do a cold boot.

also note, in CP/M 2.2, the auto-run command is not echoed nor is a CP/M prompt printed.

8008guy
March 17th, 2018, 06:37 PM
Hi,

I'm making some progress. I didn't have too much time today, but after spending the last few days reading the Programmers cp/m book things are making sense. I added a drive parameter definition to the cpmtools running under linux and can see files and such on the drive image. I wrote a utility so I can rebuild the system on the disk file from the stock files. Tomorrow I will build it with the new bios and give it a test.

Len

8008guy
March 18th, 2018, 07:31 AM
UPDATE!!!

I got the modified CBIOS patched in and tested. Appears to work perfectly.

Next I copied over your new AUTO command. Ran it, and it works perfectly as well!!! Very cool, thank you.

Cold boot runs the program defined in the CPP command buffer. Warm start just goes to a command prompt.

Now I can go play with Grants ROM code.

Thank you everyone! This was a fun learning experience.

len

deramp5113
March 18th, 2018, 09:35 AM
Great! Always feels great to conquer a vintage computing challenge :)

Mike

SteveH
March 19th, 2018, 05:18 AM
Here is a new version of an AUTO.COM program to stuff a command into the CCP on the CF card of a system based on Grant Searle's CP/M. I tested this on a simulation I have for another project, but it is also based on Grant's code. This system does not have the "CCP warm start" patch, so I was able to see the behavior in that case.

This command works like that one in the URL, but I wrote this one from scratch so I don't expect it to be bug-for-bug compatible. The basic syntax is the same:


Just a minor fix for AUTO.COM. The select disk code is currently testing register A.

ld a,seldsk
call bios
or a,a
jp nz,error


However, a select disk failure should return HL as zero.

ld a,seldsk
call bios
ld a,l
or h
jp z,error


Only spotted it as I, err, pinched it, for use with my own CBIOS. ;)

durgadas311
March 19th, 2018, 06:00 AM
Good catch! thanks. Too much copy-paste...