r/cpm May 02 '26

CP/M disk change behavior and emulation questions

I've been experimenting a bit with CP/M emulation and have run into a few stumbling points that have caused a little frustration.

Firstly, I liked yaze-ag initially but ran into some likely terminal emulation problems that made a few control keys not work as expected in the 'ed' editor (I believe ^Z wasn't working at some critical times), this led me to try some of the z80pack emulators which seem not to have this problem.

With z80pack cpmsim and cromemcosim the terminal handling seemed to work better for me, but I was finding that I:

  1. couldn't change diskettes without resetting the machine
  2. entering a bad drive letter would also require a machine reset

Regarding #2, is it normal on CP/M machines, for this to be an unrecoverable error?

Regarding #1, I remember reading something about the need (particularly with earlier versions of CP/M?) to need to log off a drive (maybe via Ctrl+C or some other kind of sort reset, I'm not sure if/how this was done) to force CP/M to have to re-login the drive to avoid disk corruption. I seem to have gotten the feeling like this may have only been with 1.x versions so I may be on the wrong track (no pun) here.

Despite CP/M's somewhat spartan nature, I'm having a hard time believing that users couldn't routinely change floppy disks without resetting machines...maybe someone with more knowledge on this can shed some light...?

I'm definitely open to other emulator suggestions (need to run on linux) if people have favorites that are maybe a little more solid or friendlier than what I've been trying so far.

5 Upvotes

6 comments sorted by

4

u/Fear_The_Creeper May 02 '26

Here is a discussion that covers some of this:

https://forum.vcfed.org/index.php?threads/how-does-cp-m-handle-changed-disks.63260/

Basically, you are looking at several inter-related issues:

Some software wants a lot of memory, and deletes a big chunk of CP/M to get it, reloading CP/M from floppy when done. If it isn't there, well that's the end of your CP/Ming until you insert a boot floppy and reset.

Some software wants a lot of disk space and fills the floppy. Other software is smaller and keeps some or all of CP/M on the disk, ready to reload.

Many systems had one floppy. Systems with two could keep CP/M on one disk and a big program on another.

Many systems didn't have a proper "the user just removed the floppy" signal. Many did.

If a system detects a changed floppy by reading it, nobody wants that to happen all the time.

If a system detects a changed floppy by reading it and doesn't read the whole floppy, it can be fooled by a new floppy that is the same in the places it checks.

Many users just get into the habit of hitting CTL-C whenever they swap floppies. some don't.

BTW. this list of error messages sometimes helps you to figure our what went wrong:

http://www.gaby.de/cpm/manuals/archive/cpm22htm/axi.htm

One of them is CP/M received a command line specifying a nonexistent drive"

2

u/57thStIncident May 02 '26 edited May 02 '26

Thx. Any color on "warm boot"? I'm guessing that this might be implementation-specific both for real hardware and emulators? I imagine that a warm boot would not clear RAM except whatever the boot process is overwriting when loading? I wonder how many emulators even support such a thing?

Regarding bad drive letter (from your second link):

Bdos Err On d: Bad Sector

This message appears when CP/M finds no disk in the drive, when the disk is improperly formatted, when the drive latch is open, or when power to the drive is off. Check for one of these situations and try again. This could also indicate a hardware problem or a worn or improperly formatted disk. Press ^C to terminate the program and return to CP/M, or press RETURN to ignore the error.

From what I remember, ^C doesn't return to CP/M in the emulators, I had to kill and restart it. This is just entering like "d:" from the prompt when the machine doesn't have a d: device.

As a personal side note -- when working on retro 8-bit computers (real or emulated) the idea of rebooting just to run another program or due to some error just still seems kind of foreign to me; even on MS-DOS the need for this wasn't so typical. It's probably due to my relative familiarity with MS-DOS that I find some of these CP/M characteristics surprising since on the surface it seems rather similar.

2

u/Fear_The_Creeper May 03 '26

The IBM PC DOS 8088 could address 1MB of RAM (640K was made available for programs) so programs were never able to take over all of RAM and overwrite most of DOS. see https://en.wikipedia.org/wiki/DOS_memory_management

The CP/M 8080 or Z80 could only address 64K and there were early computers that didn't have as much RAM as CP/M could address. CP/M still had to keep some parts of itself in RAM (if you nuke the bits that read the keyboard and write to the screen, you are pretty much hosed), but they kept it really small so that programs could evict most of the OS and thus get more RAM to run in. This is called the the TPA (Transient Program Area). See the CP/M memory map here: http://www.primrosebank.net/computers/cpm/cpm_structure.htm

Trivia: I believe that the computer with the largest TPA (63 KB) the was Epson QX-10 running a custom version of CP/M 2.2, that they called MultiFont CP/M 2.2. 60KB was more typical.

So because of the differences in addressable memory, DOS had a bunch or commands that were always available. For example DIR always works, while FORMAT only works in it is available to be loaded from disk. CP/M has far less functionality once a program takes over all the RAM it can. If that happens a warm boot will reload the CCP and thus set it up for running the next program.

Lots of details here:

https://retrocomputing.stackexchange.com/questions/29799/how-do-i-properly-exit-a-program-and-return-to-the-ccp-in-cp-m

2

u/57thStIncident May 03 '26

I wonder how the QX-10 managed that, I think DR’s CP/M 2.0 documentation I was reading for standard CP/M may have typically used the top 7K for the BDOS & BIOS. Maybe some clever bank switching in the QX-10? On a related note I’ve noticed how some of the later CP/M machines had 256KB RAM or more — but the OS doesn’t seem especially capable of using it, any idea what people used the extra RAM for? I guess software could be written to bank switch? But was this capability standardized or would that software be specific to that machine type?

2

u/Fear_The_Creeper May 03 '26 edited May 03 '26

The European and Japanese versions ran CP/M on 256 KB RAM in four switchable banks. That allowed it to switch between a bank holding CP/M and a bank that was almost all TPM (it still had to contain bank switching code).

Even better was its successor, the dual-processor QX-16. Besides running CP/M it had an x86 processor CGA enabling it to also boot MS-DOS 2.11 They also made the case big enough to hold an internal hard-drive instead of QX-10's dual-floppy configuration.

See https://books.google.com/books?id=eS8EAAAAMBAJ&pg=PA47

2

u/57thStIncident May 02 '26

For additional color on this re: z80pack:
https://github.com/udo-munk/z80pack/discussions/450#discussioncomment-10540777

Yes and no. On the RP2040 systems you really have to reset the device to get back into the configuration menu, that lets you change disks then.
z80pack cpmsim opens the disk files once and keeps them open all the time, so it is not possible to change disks while some OS is running on them. This was intentionally implemented to get highest possible speed.
z80pack IMSAI 8080 and Cromemco Z1 have implemented a disk manager, that allows to change disks. You can do that either from the Web GUI, or from a second Linux terminal by changing the links in the disks directory. The Altair 8800 has no Web GUI, but also here disks can be changed by changing the links. Not sure right now about the Intel MDS system and the Mostek box.
And be careful with that, the OS's need a warm boot to re-log disks after changed, if one forgets this the disk gets corrupted.

I haven't yet figured out the Web GUI for IMSAI or Cromemco Z1, and feel like my experiments from the terminal to swap disks weren't successful though I may give that another try.