• Please review our updated Terms and Rules here

Installing CP/M 3 (Plus?) on a home-built Z80 computer

After years of using vi a stripped-down clone would be nice but so far I haven't found one.

There used to be a set of unix-like tools for DOS, that included a "vi". "mks toolkit"? But, there is also the strip-down "embedded" Linux stuff (busybox, et al) that includes a "vi". Although, I still wonder how much you can edit when your editor consumes 50K just for itself... actually, I don't know what size it would be if you compiled the busybox "vi" in CP/M. I suspect it would require a lot of porting either way.

Since I'm using virtual machines, I usually setup CP/NET and do all my editing in "vi" on the host computer. Or, in this case, use cpmtools to pop the file into the CP/M world after editing with "vi" (and running through "unix2dos").
 
Taking a quick look at vi.c from busybox, this might be doable. You'd have to avoid using STDIO.LIB as that would bloat the COM file too much. But if you rewrite the I/O to use the BDOS, it just might work. Maybe we should see if anybody has already done that...
 
There used to be a set of unix-like tools for DOS, that included a "vi". "mks toolkit"? But, there is also the strip-down "embedded" Linux stuff (busybox, et al) that includes a "vi". Although, I still wonder how much you can edit when your editor consumes 50K just for itself... actually, I don't know what size it would be if you compiled the busybox "vi" in CP/M. I suspect it would require a lot of porting either way.

Since I'm using virtual machines, I usually setup CP/NET and do all my editing in "vi" on the host computer. Or, in this case, use cpmtools to pop the file into the CP/M world after editing with "vi" (and running through "unix2dos").

I'm editing the files in a Windows 7 VM running under Fusion on a MacBook Pro and then using TRSTools to transfer the files to disk images that I then mount in the TRS32 emulator running on the Windows VM and assembling there. Once I get things working in the emulator I convert the disk image to HFE and use that image on an HxC to boot on a real Model 4 to verify.
 
I'm editing the files in a Windows 7 VM running under Fusion on a MacBook Pro and then using TRSTools to transfer the files to disk images that I then mount in the TRS32 emulator running on the Windows VM and assembling there. Once I get things working in the emulator I convert the disk image to HFE and use that image on an HxC to boot on a real Model 4 to verify.

Are you guys competing for who has the most complicated toolchain? ;)

I write the code in Notepad++, assemble it with Z80ASM in Altair CPMulator and transfer the COM file to the SBC via the terminal (all in Windoze)... I could probably just transfer the .Z80 file straight to the SBC and assemble it with Z80ASM in CP/M there and cut the emulator out altogether. In fact, with a working word processor now I could cut out Notepad++ as well and do it ALL in CP/M on the SBC... but that might be a bit too 'bare knuckles' for me all the time I have a serial connection between the PC and SBC. When I get the keyboard and monitor interface working and the SBC becomes truly standalone, that'll be when Magic Wand will be worth its weight in gold. :D
 
Well, I didn't expect that!

Untitled.jpg

I thought I'd do a little debugging on EXIT.COM as it's not resetting back to the DMI as it should do (probably something I've done wrong.) I'd written the assembly in Magic Wand to try out restricting development to CP/M after my last post, tried running EXIT and hard reset back to DMI when it failed. The screenshot above is the DMI showing the second page of low RAM (0100-01FF) - i.e. the TPA area where EXIT is loaded (it says C100-C1FF because of the bank mapping) - look at the text in the middle - Christ is the Answer, apparently! :D Is this an artefact of some previous program I've run in CP/M? The only thing of note was Zork 1 prior to this. And no, I wouldn't have typed that myself! ;)
 
Since EXIT.COM only consumed 1 record, anything beyond 0180H is whatever was left-over. Probably whatever program you ran last. You will see left-over junk in a .COM file also, if the ASM contains large sections of DS space (that's not at the very end). Of course, only if it is assembled/compiled in CP/M. You can see some artifacts like that in DRI distribution .COM files.

FYI, many OSes used to do that sort of thing even when creating processes in memory or disk files. It became known as a security flaw since someone could glimpse at data they weren't suppose to see, so nowadays OSes make sure to clear regions like that to ensure no data is leaked.
 
Regarding the prospect of doing DMA to the Z80 address space, is it your plan to program the GPIO of the STM32F103 to be Z80 address, data, and BUSREQ/BUSACK signals? I didn't see mention of any way to extend the STM32F103 bus outside the chip (to use the internal DMA controller).

Too bad you're not using an STM32F1xx that has ethernet. You could add CP/NET if you had that. Or at least could piggy-back on some other high-speed communication between the system and a host computer (USB would work, but is just a little slower if it were tied to serial port baud timing).
 
Regarding DOWNLOAD.COM, I was going to see if I could replicate the problems you had with CP/M 3. But, it seems that download.asm does not handle "standard" Intel HEX format, and all the HEX files in the repository *are* in Intel HEX format. Am I missing something? What are you using to transfer files to the Z80?

If download.asm is what you are using to transfer, it appears to use a (very) long stream of HEX digits, then a single byte length count and single byte checksum at the very end. Be aware that the count and checksum will not be very effective for long transfers. Intel HEX format has a length and checksum (each as one byte) for each line of the file (16 data bytes traditionally, 24 in modern HEX files), which is pretty effective at catching transfer errors. Granted, in this environment it is not likely that there will be transmission errors, and gross mistakes like pasting random text are probably caught by other means.
 
Sorry for delay replying - had a busy weekend preparing for a house move in the next few weeks!

Regarding DOWNLOAD.COM, I was going to see if I could replicate the problems you had with CP/M 3. But, it seems that download.asm does not handle "standard" Intel HEX format, and all the HEX files in the repository *are* in Intel HEX format. Am I missing something? What are you using to transfer files to the Z80?

Ah, that's because the .HEX files are pasted into the DMI using the RHEX command. DOWNLOAD.COM takes a data stream pasted into the terminal window which is prepared in a Windows program made by my fair hand - you'll find it in Code/TAP Manager/TAP Manager.exe. Basically it's a re-written, modernised version of the program provided by Grant Searle in his original project archive (his is in /Code/windowsApp/FilePackage.exe.)

It takes a file dropped onto it and converts it into a CR/LF-delimited string that you can paste straight into CP/M and follows the format:

Code:
A:DOWNLOAD.COM <FILENAME>
U0
:[HEX BYTE STREAM]>[SINGLE BYTE COUNT][SINGLE CHECKSUM BYTE]

If download.asm is what you are using to transfer, it appears to use a (very) long stream of HEX digits, then a single byte length count and single byte checksum at the very end. Be aware that the count and checksum will not be very effective for long transfers. Intel HEX format has a length and checksum (each as one byte) for each line of the file (16 data bytes traditionally, 24 in modern HEX files), which is pretty effective at catching transfer errors. Granted, in this environment it is not likely that there will be transmission errors, and gross mistakes like pasting random text are probably caught by other means.

Currently my program just does the same thing as Grant's did - the long stream of HEX digits as you've correctly spotted. As and when I get round to working on the program again, I can look to strengthen the integrity of the data transfer, but it has caused no issues so far.
 
I hate moving too, but have got it down to a fine art now (this'll be the 4th time in 12 years) and the new place is much bigger and more permanent, so it's worth it.

Going back to INITDIR and timestamps - I ran INITDIR on all my drives and it seems to have worked (no errors anyway), but I'm not seeing any timestamps with DIR or STAT or anything now, on existing or new files. Just wondered how you see all the timestamps? Thought DIR would show them, but perhaps it's not a default option?
 
Try "DIR [DATE]" or "DIR C: [DATE]".

Ahaaa! Marvellous! I'm a happy camper again. :)

The CP/M User manual is your friend http://www.cpm.z80.de/manuals/cpm3-usr.pdf.

I know - I should look before I ask. Sorry.

There are way more options to DIR that do wonderful things...

Will have a closer look at it! The project is on a bit of a hiatus at the moment, what with the move and everything, but I really need to get my PSG wired in and working and get to work on version 2 of the MMU. I just keep finding distractions in software to keep me from biting the bullet and getting the schematics out again. ;) Plus the breadboard has become a mess of wires like something out of H.R. Giger's worst nightmares.

I have just had my in-laws move closer to us. Stressful time moving - but perhaps worth it in the long run...

Depends if you get on with the in-laws or not. :p How was bonnie Scotland, anyway? Saw this on eBay earlier and was trying to remember if you said you'd got a NASCOM? eBay: Nascom-I-O-Card-Kit-Brand-New-Never-Built

EDIT:

Does anyone have a copy of VDE (the word processor)? I can find no trace of it online, other than a manual. A couple of places talk about it and mention it as a better alternative to ED etc, I'd like to give it a spin but can't find it. :/
 
Last edited:
I hate moving too, but have got it down to a fine art now (this'll be the 4th time in 12 years) and the new place is much bigger and more permanent, so it's worth it.

Going back to INITDIR and timestamps - I ran INITDIR on all my drives and it seems to have worked (no errors anyway), but I'm not seeing any timestamps with DIR or STAT or anything now, on existing or new files. Just wondered how you see all the timestamps? Thought DIR would show them, but perhaps it's not a default option?

Note, STAT is a CP/M 2.2 utility and thus will never show timestamps. You should avoid using CP/M 2.2 system utilties on CP/M 3 - they might get you into trouble. INITDIR only reserves space in the directory for timestamps. You still have to create a directory label (which holds the config flags telling CP/M 3 to use timestamps) then you have to enable the timestamps you want to keep (in that directory label). Use SET to both create the label and enable specific timestamps. HELP has information on all standard CP/M commands and is very handy. Online documentation, essentially. You can enable"Update" timestamps, and either "Access" or "Create" timestamps. I find Create timestamps to be useless most of the time, since most editors and things like PIP always create new files instead of overwriting old ones - thus Create always ends up the same as Update.
 
Last edited:
>>> How was bonnie Scotland, anyway?

Snowy :)! We arrived at Edinburgh airport to a blizzard!

I am back home for the week and then back to Scotland again next week... Probably won't have time to catch up with the mega posts on your thread - but it looks like you are still moving forwards. I thought the same regarding the file transfer - it looks a bit 'simples'. I would have though a download process using the INTEL HEX format would have been a much better bet. This will be guaranteed to catch more errors if they occur. The problem with a very simple 8-bit checksum on a very large file is that you 'think' it is working (because you don't get any errors) only to find that the error detection algorithm is so poor that it would very rarely catch multi-bit errors!

>>> Saw this on eBay earlier and was trying to remember if you said you'd got a NASCOM?

Yep I have a NASCOM 2. Seen there is a guy who keeps posting NASCOM stuff. I may put a bid on for the I/O card. Thanks for thinking of me...

>>> I know - I should look before I ask. Sorry.

No need to, I was just dropping a hint ;-)... There are many more options you can use - and you will only really get to grips with CP/M by putting in a little study yourself. You won't necessarily remember it all - but (having read the user manual) when you think about something in the future - hopefully your brain will remind you that you have previously read something about this and to go and look it up.

Dave
 
Last edited:
>>> How was bonnie Scotland, anyway?

Snowy :)! We arrived at Edinburgh airport to a blizzard!

Nice. :) I saw there was some bad weather coming down around the time you'd be up there. We missed all of it down here in the bottom-right corner of the country, unfortunately. It has to be almost 'perfect storm' conditions in the Channel for it to get cold here...

I am back home for the week and then back to Scotland again next week... Probably won't have time to catch up with the mega posts on your thread - but it looks like you are still moving forwards. I thought the same regarding the file transfer - it looks a bit 'simples'. I would have though a download process using the INTEL HEX format would have been a much better bet. This will be guaranteed to catch more errors if they occur. The problem with a very simple 8-bit checksum on a very large file is that you 'think' it is working (because you don't get any errors) only to find that the error detection algorithm is so poor that it would very rarely catch multi-bit errors!

Agreed. It's the system used by Grant Searle in his CP/M system - I can't remember how I found that website now (or even why I started looking in the first place, but it was the start of a long journey I'm still on!) but as time has gone by, I'm starting to realise that it's a very basic and limited setup, both for hardware AND software. Still, it has provided no end of learning for me. I'd written a more up-to-date version of the Windows program he used to transfer files from Windows to CP/M, in C using VS 2017, so it won't take much to tweak it and make it fully Intel Hex-compatible. I can then just write a new DOWNLOAD.COM to read in Intel Hex streams, rather than the custom format that Grant had implemented.

Yep I have a NASCOM 2. Seen there is a guy who keeps posting NASCOM stuff. I may put a bid on for the I/O card. Thanks for thinking of me...

I was looking at the vintage computers there (well, Spectrums, Commodores, Amstrads and the like) and came across that and thought - 'Dave'!! I remembered you mentioning your venerable PDP-11 at Christmas (have you got it all moved back now?) and thought you might be interested. ;)
 
Okay, an update on the problems downloading files via the terminal into CP/M 3. Thanks to durgadas311's invaluable support re-writing DOWNLOAD.COM over the weekend to support Intel Hex format file transfers, I've been able to do a little more testing of the file transfer system in CP/M 3.

Just to recap for those jumping in after a while away, the only way I can transfer files from my PC to my SBC is by pasting a formatted ASCII hex-dump of the file. I say formatted, because at the start it includes a few parameters and runs the DOWNLOAD.COM file in CP/M to receive the rest of the hex dump. The hex dump is an Intel Hex format data stream, addressed from 0100 onwards. It is designed to be pasted directly into the CP/M console, where DOWNLOAD.COM is loaded and receives the rest of the pasted data, which it saves to a new (and appropriately-named) file.

It works flawlessly in CP/M 2.2. However, not so well in CP/M 3. With the revised DOWNLOAD.COM now taking Intel Hex files, it seems to be completing the download and returning to the command prompt without issue (this is a big improvement on the old DOWNLOAD.COM which would crash CP/M 3.)

However, the downloaded file seems to be consistently missing the first record of the downloaded file. I've transferred a small program and to use as an example. This is what I'm pasting into the terminal:

Code:
A:DOWNLOAD DATETIME.COM
U0
X02A8
:4001000021550311800019F921F901110402CD0103211C02110402CD01032180007E23B7281D477E23FE2FCA2F0110F7C33F017EFE3FCAEC01E65F320302FE55CA9801E599
:4001400021F901CD1B032104027EFE78CA4901E13A0302FE44CA6D01FE54CA7501FE57CA7D011104020E09CD0500C3F401210402060AC38201210F020608C382012118028B
:4001800006037EFE24CAF401C5E55F0E02CD0500E1C12310EDC3F4013E0047112202237EFE20CA9E01FE24CAC801FE00CAC8012B237EFE24CAC801FE00CAC8010412137897
:4001C000FE10DAB001C3D3011137020E09CD0500C3F4013E2312133E2412211C02CD1B032104027EFE78CAE301C362011176020E09CD05000E00CD0500255A48684C6C2375
:400200000D0A240078302D30302D303030302D30303A30303A30302D78787824255548684C6C30302D30302D303030302D30303A30303A30302324557064617465642064D8
:4002400061746520616E642074696D65204D55535420626520696E207468697320666F726D61743A2064642F6D6D2F595959592068683A6D6D244441544554494D45207691
:40028000312E312E3433202843292032303137204A2E204E4F434B0D0A446973706C617973207468652063757272656E74206461746520616E642F6F722074696D6520663E
:4002C000726F6D20746865207265616C74696D6520636C6F636B2E0D0A5573653A204441544554494D45205B6F7074696F6E616C202F442C202F542C202F572C202F555D55
:400300002423237ACD3E0377237ACD440377237BCD3E0377237BCD440377C9F57EFE24CA2903CD2B0323C31C03F1C9F5CD350328FBF1D301C997D303DB030FCB4FC9E6F014
:400340000F0F0F0FE60FFE0ADA5203D609F640C35403F630C900000000000000000000000000000000000000000000000000000000000000000000000000000000000000F7
:00000001FF

And below is a dump of the downloaded file:

Code:
F>A:DUMP DATETIME.COM

0000 21 F9 01 CD 1B 03 21 04 02 7E FE 78 CA 49 01 E1
0010 3A 03 02 FE 44 CA 6D 01 FE 54 CA 75 01 FE 57 CA
0020 7D 01 11 04 02 0E 09 CD 05 00 C3 F4 01 21 04 02
0030 06 0A C3 82 01 21 0F 02 06 08 C3 82 01 21 18 02
0040 06 03 7E FE 24 CA F4 01 C5 E5 5F 0E 02 CD 05 00
0050 E1 C1 23 10 ED C3 F4 01 3E 00 47 11 22 02 23 7E
0060 FE 20 CA 9E 01 FE 24 CA C8 01 FE 00 CA C8 01 2B
0070 23 7E FE 24 CA C8 01 FE 00 CA C8 01 04 12 13 78
0080 FE 10 DA B0 01 C3 D3 01 11 37 02 0E 09 CD 05 00
0090 C3 F4 01 3E 23 12 13 3E 24 12 21 1C 02 CD 1B 03
00A0 21 04 02 7E FE 78 CA E3 01 C3 62 01 11 76 02 0E
00B0 09 CD 05 00 0E 00 CD 05 00 25 5A 48 68 4C 6C 23
00C0 0D 0A 24 00 78 30 2D 30 30 2D 30 30 30 30 2D 30
00D0 30 3A 30 30 3A 30 30 2D 78 78 78 24 25 55 48 68
00E0 4C 6C 30 30 2D 30 30 2D 30 30 30 30 2D 30 30 3A
00F0 30 30 3A 30 30 23 24 55 70 64 61 74 65 64 20 64
0100 61 74 65 20 61 6E 64 20 74 69 6D 65 20 4D 55 53
0110 54 20 62 65 20 69 6E 20 74 68 69 73 20 66 6F 72
0120 6D 61 74 3A 20 64 64 2F 6D 6D 2F 59 59 59 59 20
0130 68 68 3A 6D 6D 24 44 41 54 45 54 49 4D 45 20 76
0140 31 2E 31 2E 34 33 20 28 43 29 20 32 30 31 37 20
0150 4A 2E 20 4E 4F 43 4B 0D 0A 44 69 73 70 6C 61 79
0160 73 20 74 68 65 20 63 75 72 72 65 6E 74 20 64 61
0170 74 65 20 61 6E 64 2F 6F 72 20 74 69 6D 65 20 66
0180 72 6F 6D 20 74 68 65 20 72 65 61 6C 74 69 6D 65
0190 20 63 6C 6F 63 6B 2E 0D 0A 55 73 65 3A 20 44 41
01A0 54 45 54 49 4D 45 20 5B 6F 70 74 69 6F 6E 61 6C
01B0 20 2F 44 2C 20 2F 54 2C 20 2F 57 2C 20 2F 55 5D
01C0 24 23 23 7A CD 3E 03 77 23 7A CD 44 03 77 23 7B
01D0 CD 3E 03 77 23 7B CD 44 03 77 C9 F5 7E FE 24 CA
01E0 29 03 CD 2B 03 23 C3 1C 03 F1 C9 F5 CD 35 03 28
01F0 FB F1 D3 01 C9 97 D3 03 DB 03 0F CB 4F C9 E6 F0
0200 0F 0F 0F 0F E6 0F FE 0A DA 52 03 D6 09 F6 40 C3
0210 54 03 F6 30 C9 00 00 00 00 00 00 00 00 00 00 00
0220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0240 24 23 23 7A CD 3E 03 77 23 7A CD 44 03 77 23 7B
0250 CD 3E 03 77 23 7B CD 44 03 77 C9 F5 7E FE 24 CA
0260 29 03 CD 2B 03 23 C3 1C 03 F1 C9 F5 CD 35 03 28
0270 FB F1 D3 01 C9 97 D3 03 DB 03 0F CB 4F C9 E6 F0

As you can see, the first record from the pasted data is missing from the saved file. Not sure why this is happening in CP/M 3 but not in CP/M 2.2. As I said, DOWNLOAD.COM in CP/M 2.2 is rock solid.

I'm thinking I'm going to have to revisit BIOS3 and have a closer look at the I in IO...
 
Last edited:
My guess would be that somehow a character is getting lost (maybe a couple) at the beginning, causing download to skip the rest of the first line while looking for a ':'. But with the "U" and "X" lines you'd think it would have settled down by then. Maybe something to do with CP/M 3 handling of "ctrl C" and interrupt buffers in the BIOS? Will take some more pondering... I'll see if I can reproduce on my end where debugging might be easier.
 
My guess would be that somehow a character is getting lost (maybe a couple) at the beginning, causing download to skip the rest of the first line while looking for a ':'. But with the "U" and "X" lines you'd think it would have settled down by then. Maybe something to do with CP/M 3 handling of "ctrl C" and interrupt buffers in the BIOS? Will take some more pondering... I'll see if I can reproduce on my end where debugging might be easier.

Yes, dropping the first ':' (amongst others) would cause the issue I'm seeing, but CP/M 3 is clearly receiving the first line (as DOWNLOAD.COM is loading and using the correct filename to save the data as) - when I get more time to look at it again I'll add some debug prints to see if the user is being assigned with the U command and X is also being received.

For info, it does exactly the same thing whether running at 4 MHz or 8 MHz - I'm confident it's not a connection speed issue or buffers being overflowed as I have full CTS/RTS flow control on (at least I do in CP/M 2.2 BIOS..... trying to remember if it was implemented in BIOS3 as initially we went with polled IO.... maybe the first thing for me to check later!)
 
Back
Top