CP/M-68K Simulator

I found this last night, and thought it was worth sharing.

This simple CP/M-68K simulator, is built around the famous Musashi MC68000 simulator core.  So it’s a little more well debugged than the SIMH CP/M-68k. Namely that COM works!

COM running Zork1 on CP/M-68K

COM running Zork1 on CP/M-68K

I managed to build this under Window with MinGW, the only caveats were that it opens the disk files without explicitly in binary so on Windows it opens everything in ASCII and nothing works.  Also MinGW doesn’t emulate a vt100 or provide termios so all of that had to be commented out.  But for the full experience you’d want to run it on *NIX.

I suppose you could write an ANSI intercept, and manipulate the NT Console, but that is a lot of work.

On the plus side, this solution is more stable, faster and feels more robust with a 16MB hard disk, and a standard IBM 3740 floppy disk in the ‘a’ position.

One thing that was a snag to me, was the windows version of cpmtools is built to default to the apple-do type, aka Apple II CP/M skew for DOS 3.3 … So I was trying to setup a floppy image with too much work.  Also the default size of the 3740 disk is 256,256 bytes.

For example:


C:\temp\cpm\cpmtools>cpmls -f ibm-3740 zork1.cpm


But if you find z80/8080 CP/M too mainstream, give the 68k a shot!

17 thoughts on “CP/M-68K Simulator

    • I saw mention of it inside of CP/M tools of all things. Although having just loaded it, I think MP/M is far more interesting…. 4 user CP/M!

  1. I am so close to getting this to work myself. When I start up the emulator, I’m getting a segmentation fault. Do you have any suggestions? Stepping through with gdb shows that “m68ki_instruction_jump_table” is being loaded with all zeros, and that is an array full of function pointers. Hence, the program tries to jump to a function at 0x000000000000 and that’s where I get the segfault.

    $ ls -l
    total 35376
    -rw——- 1 escott escott 16777216 Jan 22 21:02 backup-diskc.cpm.fs
    -rw-rw-r– 1 escott escott 24576 Jan 22 20:56 cpm400.bin
    -rwxrwxr-x 1 escott escott 799625 Jan 22 21:12 cpmsim
    -rw-rw-r– 1 escott escott 21376 Jan 22 20:56 cpmsim.c
    -rw-rw-r– 1 escott escott 924891 Jan 22 20:56 cpmsim.zip
    -rw——- 1 escott escott 16777216 Jan 22 20:56 diskc.cpm.fs
    drwxrwxr-x 2 escott escott 4096 Apr 28 2016 example
    -rwxr-xr-x 1 escott escott 5450 Apr 28 2016 history.txt
    -rwxr-xr-x 1 escott escott 6634 Jan 22 20:56 m68kconf.h
    -rwxr-xr-x 1 escott escott 36961 Apr 28 2016 m68kcpu.c
    -rwxr-xr-x 1 escott escott 63668 Apr 28 2016 m68kcpu.h
    -rwxr-xr-x 1 escott escott 97239 Apr 28 2016 m68kdasm.c
    -rw-rw-r– 1 escott escott 144944 Jan 22 20:56 m68kdasm.o
    -rwxr-xr-x 1 escott escott 13872 Apr 28 2016 m68k.h
    -rwxr-xr-x 1 escott escott 226050 Apr 28 2016 m68k_in.c
    -rwxr-xr-x 1 escott escott 44360 Apr 28 2016 m68kmake.c
    -rw-rw-r– 1 escott escott 1333 Jan 22 21:12 makefile
    drwxrwxr-x 2 escott escott 4096 Jan 22 21:12 obj
    -rwxr-xr-x 1 escott escott 10550 Apr 28 2016 readme.txt
    -rw-rw-r– 1 escott escott 32768 Jan 22 20:56 simbios.bin
    -rw-rw-r– 1 escott escott 5396 Jan 22 20:56 simbios.s
    -rw-rw-r– 1 escott escott 497 Jan 22 20:56 sim.h
    escott@W530:~/projects/m68k/Musashi-master$ ./cpmsim -c diskc.cpm.fs
    Read 32768 bytes from boot track
    Segmentation fault (core dumped)

    • What is your host platform? what compiler? what flags?

      At first I suspected it was some kind of binary/text mode thing, although it looks like you are on a *NIX?

      • Linux – ubuntu 14.04. Compiler is gcc. Flags are “-g -Iobj -I.” Those are “eye” characters.

        I added a call to m68k_init() just before m68k_pulse_reset() in main, and that has gotten me from all zeros in the array to an “illegal opcode” that causes the emulator to complain about an illegal instruction and then throw a SIGSEGV.

        • try running “uname -a” without quotes.

          Anyways I suspect you are on x86_64 based machine, and further I suspect it’s 32bit only.. Try adding the flag -m32 .. You’ll probably have to run something like :

          “sudo apt-get install g++-multilib libc6-dev-i386”

          to pull in 32bit development, and support…

  2. OK – David Schultz found the problem! In cpmsim.c, right before the line “m68k_pulse_reset()”, add the two lines “m68k_init()” and “m68k_set_cpu_type(M68K_CPU_TYPE_68000)” . Recompile and there you go. I have the simulator up and booted to a C> prompt!

    Kind thanks to you and to David Schultz,

    • Oh wow the emulator drifted from then I’d used a vintage version… Good catch though!!!

      Now that you have it running, what can you do with it?

      • Replying three years later… I never came back to this page. In any case, all I’ve really done with the cpm68k environment is compile some toy C programs and just doodle around with it. It has microEmacs, so I can edit text files. I don’t remember there ever being much in the way of cp/m-68k software. Seems like it might have been used to control some machine tools or something.

        • I think it never caught on as they were expensive machines and then then you had the IBM PC show up and obliterate the CP/M market.

          It’s cool to be able to run the 68k CP/M for sure but yeah, lack of apps that aren’t 8080 translates or straight emulation.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.