• Please review our updated Terms and Rules here

I finally ported CP/M!

8008guy

Veteran Member
Joined
Jun 25, 2014
Messages
584
Location
Salt Lake City, Utah
Done.JPG


This weekend I successfully booted CP/M on my bench system! It was quite a long journey.

It started almost exactly a year ago when I restored an Altair I acquired several decades ago. After restoring the Altair I got CP/M working on it using an FDC+. That wet my appetite, but using the FDC+ made it so easy it felt like cheating. No disrespect intended, just that all the heavy lifting was done by Mike who did an excellent job! Using his board and software made it impossible to fail.

After the Altair I restored my IMSAI that I bought about the same time I got my Altair. On the IMSAI I decided to take a more “authentic” path to CP/M. Being that the IMSAI would take up too much space in my office I opted to develop everything on a bench system. I bought one of Don Caprio’s Mini Front panels. Got one of the S100 groups nine slot back planes, and also one of Josh Bensadon’s 8080 CPU cards.

Having a working development system I first tackled the issue of an I/O card for the IMSAI. Not finding anything readily available I wire wrapped up an IMSAI SIO2. I completed the SIO2 card in January. I somewhat simplified the output side to only include RS232 drivers, as well as a single chip dual baud rate generator.

Next I bought a bare BYTE8080 MPU board and put it together. I could “un-option” Josh’s board, but wanted to work with a board and card configuration similar to the one in the IMSAI.

For RAM I used a 64K Compupro board which required me to work though the issues of having a RAM card that didn’t work with my front panel. It was designed to work with a standard S100 buss. To get it working required I cut the “inner” ground traces. I also had to pull the IC that does the > 64K bank selection and strap the desired bank select to ground.

To get everything going I needed a Monitor program. In my collection of cards I had a MicroDesign MR8. Not being able to find any documentation I ended up reverse engineering the schematic. Having bought one of Martin Eberhard’s dual seral cards for my Altair I had experience with his Memon/80 monitor and liked it very much. I burnt a copy and put it on the MR8. I also made one modification to the MR8 that would cause the MR8 to assert the phantom line so I didn’t have a conflict with my memory card.

Last I needed a floppy controller card. I chased a few on Ebay and finally ended up with a rather ratty California Computer Systems CCS2422 Rev A. If you are familiar with the Rev A you know there are a few challenges. In addition my controller was missing nearly half its chips. After placing an order for the missing IC’s and testing the existing IC’s I got my controller populated. I did some initial testing and things appeared that it would work. Using Martin’s MeMon I could manually send restore and seek commands.

Next I applied the published “problem” fixes to the board which solve the lock up and glitches of the Rev A version. I also applied some of Martin’s fixes to get the status registers to be the same as the Rev B and C boards. For my testing I am using a TEAC FD-55GFR drive. They can be strapped to run at 300RPM.

Nearly all of the CCS software was written to support Z80 op codes. I found the CCSINIT program which is used to format disks and disassembled it. I discovered that it only used a single unique Z80 instruction to create the error message. I NOP’d that out and then redirected the BDOS calls to use Memon/80’s character input and output routines, as the program was written to be run under CP/M. Once I had that completed I formatted a disk!

Next I set out to write some simple read/write sector commands. Through this process I discovered a bad 1793 controller chip and another IC. I’m really grateful to Martin who was gracious enough to answer a continuous flow of email fill with my novice type questions. I also heavily leveraged my Saleae logic analyzer which was continuously wired to the 2422 controller board.

After getting the basic sector read and write functionality working I started to modify an existing version of the CCBIOS. I ripped out the serial I/O routines substituting in routines to support the IMSAI SIO2. Since Martin’s MeMon supports the SIO2 I shamelessly liberated his functions. When I started doing the math on my system size, CPM/BDOS/CCBIOS, I saw that I would be over the three track limit. I could go double density but opted to go double sided for the system files.

When I played with the side select option everything broke. It took me several more days to understand what was happening and I got that fixed. The solution came after reading Martins format program and doing a few captures with the Saleae. Since Martin does a verify after format, unlike the CCSINIT SW, the problem showed up rather quickly.

Being over the two sided hurdle I could now modify the CCBIOS WBOOT routines to support my two sided system. Just like everything else before, this wasn’t going to be solved as quickly as I thought. At this point in time I could drop the hex files for CPM/BDOS and CCBIOS into memory. Using my boot strap routines, which were modified from my sector read/write code, I would get the disk param area set up and jump into the cold boot entry point of my CCBIOS. The CP/M A> prompt would magically appear and I could now do a dir command and see that I had an empty disk! Having a running system made it much easier to modify the CBIOS.

After studying the warm boot code I found where I needed to make my modifications. I first made a change to start reading at sector 3 being that my boot code was just under 256 bytes and it needed two sectors itself. Continuing though the function I would read to the end of the track and check for side and then swap over to side 1 or jump to the next track and reset to side 0. All this worked perfectly. I could see all the system data, minus the CCBIOS which I didn’t re-read, come back into the memory after a warm boot. The trouble came when I pulled out the code to halt after a load and jump to the CCP, the system would crash every time. I went back and forth for an entire day trying to trouble shoot where I had gone wrong. The load was perfect, I even did a memory dump and verified that the memory and hex code for CP/M and BDOS matched.

Later Saturday evening the answer came… Out of desperation, and a little intuition, I put in a single NOP between the warm boot code and the common boot code. I dropped in my CBIOS, did a control C, and the system reread the system from disk and I was back running. I tried the same exercise using two NOP’s and the system failed. For some reason there is a bug/alignment/assembler error that is causing this code to be position sensitive. Martin has encouraged me to go back and find the real error, which I may do one day when I feel slightly sadistic. 

The only thing left to do at this point was to modify my boot loaders for their real and final destinations. Up to this point I was I was just loading them in as hex files and manually kicking them off. The primary loader needed to be burnt in EPROM. It would now reside above MeMon. The disk based loader gets pulled into memory and loaded just below CCP. That way I free up the space around 100H in lower memory so I can load the CP/M transient programs before booting CP/M and save them to disk.

Looking back it was a pretty intense way to pass five months’ worth of evenings and weekends. Before I started I had read many websites and documents about porting CP/M to a new system. I can’t even begin to count the thousands of lines of 8080 assembly code I read though. I really envied, and now greatly admire, those who have boot strapped their own custom systems. I had an amazing amount of help from Martin. Even using modern tools, emulators, a logic analyzer, and with the Internet this was a real challenge. It give me great appreciation for those who did it back in the 70’s and 80’s. For anyone wanting a real challenge I say go for it, you will never regret it.

Cheers and thank you to all those who unknowingly helped an old computer junkie get his fix.

len


IMG_4176.jpg
 
Congratulations!

But "ported" to me implies crossing architectural boundaries. For example, x80 to x86 or 6800 or z8000 or 68K or ARM or...

You get the idea. I guess that I've never heard the word used in the sense of staying with the same ISA. Where I heard it the most was with Unix.
 
Well done, Len, that's a real achievement.

I recall how difficult it was writing CP/M IDE drivers, due to me being a novice, and the sense of achievement when it all started working (helped along by some great advice from Chuck and other members of this forum). I would love to have a go at building a CP/M system up from the ground but I do not have the time at the moment. There's nothing like that feeling of total mastery of low level CP/M, eh?
 
I recall porting CP/M to new platforms, and how difficult it can be. Especially if you don't have a working CP/M system to start with. A bit of a chicken/egg situation. I guess these days you have a modern PC that you can use to create the initial boot image, but it's still no small feat. Congrats!
 
Sounds like a lot of fun! It’s a very rewarding path to complete. But now, you’ll be a bit let down and bored every night for a while :)

Mike
 
Sounds like a lot of fun! It’s a very rewarding path to complete. But now, you’ll be a bit let down and bored every night for a while :)

Mike

Hi Mike,

I'm not so sure about that. Martin sent me his CBIOS to play with. I'm going to changeout the I/O drivers for the Imsai SIO2 and play with double density. :)

No rest for the wicked.

BTW... I still play with WM that you sent me, which is a nice editor. Did you ever make a video showing how to use ED? For the life of me I have never been able to do anything useful with it. If I use it on a new file I can enter text and then save. But if the file already has text in it I'm totally lost on how to get it displayed. I try the 'T' command. But the CP must be lost in space...

Cheers,

len
 
Did you ever make a video showing how to use ED? For the life of me I have never been able to do anything useful with it. If I use it on a new file I can enter text and then save. But if the file already has text in it I'm totally lost on how to get it displayed. I try the 'T' command. But the CP must be lost in space...

Cheers,

len

I used ED, and an ED-like editor on FDOS-III, but that was coming from punch cards and timeshare BASIC on an ASR-33 Teletype. You've got to channel your inner "Master Po" (from Kung Fu) in order to use it. Going backward to ED from modern editors is very very difficult.

If you're really a glutton for punishment, there is an "ed" on Linux you could bruise your forehead against. Similar sort of thing, possibly better documentation. I can also send you a brick to hit yourself with, I won't charge much for it.
 
I used ED, and an ED-like editor on FDOS-III, but that was coming from punch cards and timeshare BASIC on an ASR-33 Teletype. You've got to channel your inner "Master Po" (from Kung Fu) in order to use it. Going backward to ED from modern editors is very very difficult.

If you're really a glutton for punishment, there is an "ed" on Linux you could bruise your forehead against. Similar sort of thing, possibly better documentation. I can also send you a brick to hit yourself with, I won't charge much for it.

I played with ed a bit tonight, I do feel sightly brused. I did discover the "a" command to copy the disk buffer to the edit buffer.

My favorite editor is vi, when I use normal full screen editors I tend to hit esc more often than not...
 
Honestly, if you're going to go back to ed you might as well just learn TECO; at least then you've picked up a Turing-complete language.


I don't plan on using it much. Just that, like vi, it's there by default. When you're working on a bare install it is quick and dirty. For anything significant I edit under linux and move files onto an emulator or the real machine.
 
Looking back it was a pretty intense way to pass five months’ worth of evenings and weekends. Before I started I had read many websites and documents about porting CP/M to a new system. I can’t even begin to count the thousands of lines of 8080 assembly code I read though. I really envied, and now greatly admire, those who have boot strapped their own custom systems. I had an amazing amount of help from Martin. Even using modern tools, emulators, a logic analyzer, and with the Internet this was a real challenge. It give me great appreciation for those who did it back in the 70’s and 80’s. For anyone wanting a real challenge I say go for it, you will never regret it.
It was a good deal easier "back in the day" - people were intimately familiar with the 8080/8085/Z-80 instruction set, and could work in hex just as easily as using an assembler. There were a large variety of cards available, so if you weren't sure if you had flaky hardware or your code was bad, you could just change out the card. There were enough similar systems around that you didn't have to do cross-development (the worst you'd have to deal with was writing drivers for MP/M on a CP/M system). Some of the systems were quite advanced for their time. The Durango F-85 was a good example of the state of the art.

Having come up "from the trenches", including several years at Lifeboat Associates where I did a number of CP/M implementations including the Datapoint 1550, another employee and I left to start our own company, Pro-Comp Systems. I put some of the Pro-Comp documentation (for the Pro-Comp/8) on my web site here. These are lightly-tweaked (to be readable in ASCII) WordStar files. People here might be interested in reading them - the CP/M was completely interrupt-driven, could run processes in the background (complete with filesystem I/O), implemented TSR-type programs, and so forth. The MP/M implementation was even more complex, but I don't seem to have those documents handy. Eventually we moved to TurboDOS because we couldn't get Digital Research to deliver the promised MP/NOS multiprocessor code - they were busy doing something with George Morrow. We did a bunch of work with Spectravideo (CP/M for the SV-318/328, along with some other stuff), Sony (hard drive support and CP/M work for the SMC-70) as well as branching out into contract hardware design.
 
Congratulations!

But "ported" to me implies crossing architectural boundaries. For example, x80 to x86 or 6800 or z8000 or 68K or ARM or...

You get the idea. I guess that I've never heard the word used in the sense of staying with the same ISA. Where I heard it the most was with Unix.

Just for the record... The CCS code is native Z80. I did have to recompile or otherwise swap out sections of Z80 code to work on my 8080...

:)
 
Terry, I believe we ran into each other briefly when I was working at Durango Systems.
Yup. You're one of those brilliant 80's programmer types - you sent me the source for a driver for the (forthcoming) F-85 hard disk option, with a note that you hadn't tested it because the hardware wasn't ready or somesuch. I assembled the driver and there was one trivial syntax error - something like a ":" instead of a ";" in a comment. After fixing that, it worked fine.

I've written elsewhere that the F-85 getting 1MB on a 5.25" floppy was quite an achievement at the time. I think that record stood for quite a while, until Vertimag released their 5MB perpendicular media (I had one of those as well).
 
You should have seen me in the 60s and 70s... :)

Strangely enough, I still have two of the machines--one with the 20 MB ST506-type drive (Rodime, I think) and one that uses the 14" SA4000 drive on a GPIB bus. Haven't powered either up for a few years, however. Both have the hi-resolution printer upgrade as well as bank-switched RAM.

They're probably pretty rare by now. After Durango, I went back to coding for supercomputers for a time--variety is the spice of life, you know.
 
Back
Top