Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 18:41 30 Sep 2022 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: Z80 Simulator Running CP/M 2.2

     Page 1 of 2    
Author Message
GerryL
Newbie

Joined: 24/01/2019
Location: Australia
Posts: 26
Posted: 03:56am 20 Sep 2022
Copy link to clipboard 
Print this post

Attached is a zip file of a Z80 Simulator for the CMM2 I have been playing around with that others of my vintage may find interesting.  This will also run CP/M 2.2 which was originally placed in the public domain in 2001 (reconfirmed and clarified in July 2022)
http://www.cpm.z80.de/license.html
Note this is a simulator and not an emulator so I have not covered off on some of the hardware and it will ONLY run the Zilog ‘documented’ instructions. Can be run with or without a mouse. The CP/M side is using the original Digital Research assembly files dated Jan and Feb of 1980.
To assemble the CP/M files and build some testers I wrote a Windows Console macro assembler that I have included. The macro assembler is based on Digital Research’s 1980 CP/M Macro Assembler Manual. This will assemble both 8080/85 and Z80 instruction mnemonics.
This simulator was written as a fun project so I’ll guarantee there will be glitches and the assembler may not understand every way you can write an assembly instruction (the Z80 has about 694 legitimate combinations of opcodes and operands so there is bound to be a screw up somewhere). Also, it is not lightning fast, it runs about an average of 2.5 times faster than a standard 4MHz Z80, or a bit over 1 microsecond per instruction (of course the times depend on the instruction type).
For anyone wanting to have a play around the zip file contains a number of guidance instructions and examples.  The analog clock example is a good demo of using an in-line repeat macro in the assembly code to do all the heavy lifting during assembly in generating the pixel location tables for the minute tick marks, second hand line, and minute and hour hand triangles. Note I have not checked if inputting or setting CMM2 pins actually works as the intent of the project was focused on the software side.

I have a lot of fond memories of the Z80 and CP/M 2.2, my first encounter was back in the early 1980’s when work purchased some Prolog boxes with a STD Bus cage, power supply and two 8 inch hard drives. We used a Z80 ‘Little Big Board’ (manufactured by Pulsar in Melbourne) running CP/M 2.2. This was used extensively to log strain gauges using a compiled Microsoft Basic program. We also used a CMOS Z80 board manufactured by JED Microprocessors in Melbourne for field work, logging a range of sensors and GPS.

Below is the image of the main display panel and below that is a snap-shot of a Tera Term screen of using the TBS Benchmark Basic tests in CP/M.  The first set of times is running directly in Microsoft MBASIC while the second set of times is from a compiled and linked version.








CMM2 Z80.zip

Gerry
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 1649
Posted: 05:37am 20 Sep 2022
Copy link to clipboard 
Print this post

That is amazing. I myself was in the 6502 camp, but looking at this I can only congratulate you on such an achievement. That is stunning. Great work! All the more since it actually runs real code (cpm).
Edited 2022-09-20 15:38 by Volhout
If nothing goes right ... turn left
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 2975
Posted: 07:30am 20 Sep 2022
Copy link to clipboard 
Print this post

Truly beautiful! An excellent piece of work. :)
I'm going to have to have a play with this, that's a lovely simulator panel.

I first played with the Z80 about 43-odd years ago, on the Nascom-1 and I still have a soft spot for it. I also built a Vero-wrapped version of the MBC1 SBC with a couple of flash chips on it to act as disc drives (running CP/M, of course). I'm just considering getting a proper PCB and re-building it into a MBC2. Another ongoing project is a Nascom-4, which is actually a Nascom-2 plus add-ons but all running on a FPGA. It might even get a Gotek drive yet.

I saw a Z80 simulator running CP/M 2.2 or CP/M 3 on a ESP-32 with a SD card pretending to be a pile of disks the other day. I might try that too. :)
Edited 2022-09-20 17:42 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 6490
Posted: 08:06am 20 Sep 2022
Copy link to clipboard 
Print this post

Brilliant bit of coding - many congratulations.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 2882
Posted: 08:12am 20 Sep 2022
Copy link to clipboard 
Print this post

Goodness me!!

Amazing.

(I used to write drivers for CP/M, MP/M, CP/M-86, MP/M-86, MS-DOS as well as UNIX etc.)

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 2732
Posted: 09:10am 20 Sep 2022
Copy link to clipboard 
Print this post

Most impressive.

I didn't know you could call back from CSUBs into MMBasic - very interesting.

Good work,

Tom
CMM2 Welcome Tape, Creaky old text adventures
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 313
Posted: 11:43am 20 Sep 2022
Copy link to clipboard 
Print this post

My goodness! That is a brilliant piece of work!

-Bill
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2336
Posted: 12:01pm 20 Sep 2022
Copy link to clipboard 
Print this post

  GerryL said  I have a lot of fond memories of the Z80 and CP/M 2.2


Ditto. Terrific job. I started building a Z80 CP/M machine from boards in 1977, and got it working in 1979 (power supply was the big holdup). Did a lot of Z80 assembler coding.

But I'm spoiled now by MMBasic, and don't want to go back.
PicoMite on fruitoftheshed
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 2975
Posted: 12:19pm 20 Sep 2022
Copy link to clipboard 
Print this post

Me too. :)
Happy memories of using Zeap on the old Nascom-1 though. Seeing the OP's pictures suddenly brought back a lot of memories of register pairs and the alternate register set.
I'm going to have to get the Nascom-4 completed now. It has real chips for PIO, CTC and FDC.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Rickard5

Senior Member

Joined: 31/03/2022
Location: United States
Posts: 251
Posted: 12:29pm 20 Sep 2022
Copy link to clipboard 
Print this post

OHH ME OHH MY, this is a pleasant morning, a step to unlocking Walnut Creek CP/M GOODNESS
The days that I keep my gratitude Higher than my expectations, and Well, I have really good days
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1044
Posted: 01:05pm 20 Sep 2022
Copy link to clipboard 
Print this post

@Gerry
Sweet memories! Thanks!

Michael
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1829
Posted: 03:09pm 20 Sep 2022
Copy link to clipboard 
Print this post

this is really amazing work, well done! almost tempted to get a CMM2 just for this.

Hate to be Billy Boring... no R register?

also

Is the HALT="back to basic" functionality programmable? I would love to run some of my old stuff on here and we used the HALT signal as a single bit of I/O (well, O) as part of the memory swap hardware design. While I know the hardware would not be emulated it would still need to continue after the HALT (and subsequent INT to trigger the hardware re-configure). Small point, probably tweakable by yours truly.
Edited 2022-09-21 01:45 by CaptainBoing
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 2975
Posted: 03:56pm 20 Sep 2022
Copy link to clipboard 
Print this post

Are you using dynamic flash, Cap'n?  ;)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1829
Posted: 04:26pm 20 Sep 2022
Copy link to clipboard 
Print this post

LOL, I bought some off ebay... wasn't up to much.

The R register was often used to seed RNGs... just for compatibility's sake. As an aside, how short sighted of Zilog to make it only 7-bits.... why Zilog, Why? (and don't get me started on the 4-bit ALU!!!) I can only assume fab prices were hideous back in the 70s
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 2975
Posted: 05:10pm 20 Sep 2022
Copy link to clipboard 
Print this post

They didn't need 8 bits for a DRAM refresh register at the time so they didn't provide them. :) Some later derivations of the Z80 did have 8-bit refresh.

The 4-bit ALU was very clever. The aim was to equal or better the 8080 in performance and by using 4-bits with pipelining they did it. There was also a separate 16-bit "ALU" that could just increment and decrement, but it was direct on the internal bus so very fast. That was used for all sorts of purposes.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
GerryL
Newbie

Joined: 24/01/2019
Location: Australia
Posts: 26
Posted: 01:44am 21 Sep 2022
Copy link to clipboard 
Print this post

thanks guys, appreciate the kind words.

Gerry
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 370
Posted: 06:29am 21 Sep 2022
Copy link to clipboard 
Print this post

Wonderful ! ! I LOVE my Z80 and CP/M and ZCP/M years.


Big THANKS, now I need to look through some boxes for my BIG Board and 8" drives.


Quazee137
 
LechU
Newbie

Joined: 18/01/2022
Location: United Kingdom
Posts: 3
Posted: 11:34am 21 Sep 2022
Copy link to clipboard 
Print this post

Is it possible to migrate this to MMBasic Windows/DOS?
 
Rickard5

Senior Member

Joined: 31/03/2022
Location: United States
Posts: 251
Posted: 11:48am 21 Sep 2022
Copy link to clipboard 
Print this post

  Quazee137 said  Wonderful ! ! I LOVE my Z80 and CP/M and ZCP/M years.


Big THANKS, now I need to look through some boxes for my BIG Board and 8" drives.


Quazee137



OHH WOW you must be in Dallas to have a Big Board :), Jim Tanner has a Whole Stack of Blank unbuilt Big Boards :) I had a Big board back in the late 80's
The days that I keep my gratitude Higher than my expectations, and Well, I have really good days
 
TrevorC
Newbie

Joined: 15/07/2020
Location: United Kingdom
Posts: 10
Posted: 04:17pm 22 Sep 2022
Copy link to clipboard 
Print this post

Hi. I am having problems with running Z80CPM22.bas.

The OPTION to create the controls needs to be OPTION MAXCTRLS 120

Then when I select LOAD CP/M I get an error

Error in line 527 : IF without THEN

Can you help me with this error.

Thanks Trevor
 
     Page 1 of 2    
Print this page
© JAQ Software 2022