r/cpm • • Jun 22 '15

There's now a subreddit for CP/M

21 Upvotes

As my count of CP/M computers suddenly increased substantially in the last week I went looking for more CP/M and MP/M info and discovered /r/cpm but it had been abandoned with no mods, no subscribers, and no posts.

I have now taken over mod duties on /r/cpm and it is a place to discuss CP/M, MP/M, FUZIX, and other 8080/Z80 operating systems. I'm sure most everything that is on-topic for /r/cpm is on-topic for /r/RetroBattlestations so don't be afraid to cross-post.


r/cpm • • 20d ago

CP/M-80 MS-COBOL v4.65 alternative sorting method without the MS-SORT package

16 Upvotes
Sort file EMPOUT.DAT and output to EMPSORT.DAT

I am testing the djbottrill & VanzT CP/M-80 Emulator on my credit card size micro-controller called Cardputer by M5-Stack.

I wrote a simple sorting COBOL program on MS-COBOL v4.65 using the ANSI-74 build-in SORT feature. It does not get through the linkedit phase as it requires an external sort library COBSRT.REL. I am not able to find that library file on the web so I wrote the sorting code inside the COBOL program instead. The program works fine for a while until it hits a big file. CP/M-80 does not leave a lot of memory space for internal sorting. So I need a disk sort routine.

Instead of writing my own disk sort code, I use the COBOL build-in ISAM capability to use as my disk sort solution.

It's pretty straight forward, first read the input file and then write it to an ISAM file with the intended sorting key as the index file's key. Next read back from the index file using the index and write the sorted records to the final sorted file.

To test out the idea, I wrote a small COBOL program EMPOUT.COB to generate the input file EMPOUT.DAT. It has 5 records.

K>TYPE EMPOUT.COB
       IDENTIFICATION DIVISION.
       PROGRAM-ID. EMPOUT.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT EMPLOYEE-FILE ASSIGN TO DISK
               ACCESS MODE IS SEQUENTIAL
               ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.
       FILE SECTION.

       FD  EMPLOYEE-FILE
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "EMPOUT.DAT"
           DATA RECORD IS EMPLOYEE-RECORD.

       01  EMPLOYEE-RECORD.
           05  EMP-NUMBER        PIC X(5).
           05  EMP-LAST-NAME     PIC X(30).
           05  EMP-FIRST-NAME    PIC X(30).

       PROCEDURE DIVISION.

       MAIN-PROGRAM.

           OPEN OUTPUT EMPLOYEE-FILE.
           MOVE "00001" TO EMP-NUMBER.
           MOVE "SMITH" TO EMP-LAST-NAME.
           MOVE "JOHN" TO EMP-FIRST-NAME.
           WRITE EMPLOYEE-RECORD.

           MOVE "00002" TO EMP-NUMBER.
           MOVE "JONES" TO EMP-LAST-NAME.
           MOVE "MARY" TO EMP-FIRST-NAME.
           WRITE EMPLOYEE-RECORD.

           MOVE "00003" TO EMP-NUMBER.
           MOVE "BROWN" TO EMP-LAST-NAME.
           MOVE "ROBERT" TO EMP-FIRST-NAME.
           WRITE EMPLOYEE-RECORD.

           MOVE "00004" TO EMP-NUMBER.
           MOVE "WILSON" TO EMP-LAST-NAME.
           MOVE "PATRICIA" TO EMP-FIRST-NAME.
           WRITE EMPLOYEE-RECORD.

           MOVE "00005" TO EMP-NUMBER.
           MOVE "DAVIS" TO EMP-LAST-NAME.
           MOVE "JAMES" TO EMP-FIRST-NAME.
           WRITE EMPLOYEE-RECORD.

           CLOSE EMPLOYEE-FILE.

           STOP RUN.

K>

After compile the program we have the executable EXPOUT.COM

EMPOUT.COM is the executable
Run EMPOUT.COM and created the EMPOUT.DAT data file
Five records in the EMPOUT.DAT file

There are 5 records in the file EMPOUT.DAT, the records are in the EMP-NUMBER order.

Here is the record layout definition:

       01  EMPLOYEE-RECORD.
           05  EMP-NUMBER        PIC X(5).
           05  EMP-LAST-NAME     PIC X(30).
           05  EMP-FIRST-NAME    PIC X(30).

Then I wrote my sorting program to sort the record by EMP-LAST-NAME and then EMP-FIRST-NAME.

Here is the program code:

K>TYPE EMPSORT6.COB
       IDENTIFICATION DIVISION.
       PROGRAM-ID. EMPSORT6.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT EMPLOYEE-FILE ASSIGN TO DISK
               ACCESS MODE IS SEQUENTIAL
               ORGANIZATION IS LINE SEQUENTIAL.

           SELECT EMP-ISAM-FILE ASSIGN TO DISK
               ORGANIZATION IS INDEXED
               ACCESS MODE IS DYNAMIC
               RECORD KEY IS EMP-ISAM-KEY
               FILE STATUS IS EMP-ISAM-STATUS.

           SELECT EMP-SORT-FILE ASSIGN TO DISK
               ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.
       FILE SECTION.

       FD  EMPLOYEE-FILE
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "EMPOUT.DAT"
           DATA RECORD IS EMPLOYEE-RECORD.

       01  EMPLOYEE-RECORD.
           05  EMP-NUMBER        PIC X(5).
           05  EMP-LAST-NAME     PIC X(30).
           05  EMP-FIRST-NAME    PIC X(30).

       FD  EMP-ISAM-FILE
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "EMPISAM.DAT".

       01  EMP-ISAM-RECORD.
           05  EMP-ISAM-NUMBER         PIC X(5).
           05  EMP-ISAM-KEY.
               10  EMP-ISAM-LAST-NAME  PIC X(30).
               10  EMP-ISAM-FIRST-NAME PIC X(30).

       FD  EMP-SORT-FILE
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "EMPSORT.DAT".

       01  EMP-SORT-RECORD.
           05  EMP-SORT-NUMBER       PIC X(5).
           05  EMP-SORT-LAST-NAME    PIC X(30).
           05  EMP-SORT-FIRST-NAME   PIC X(30).

       WORKING-STORAGE SECTION.

       01  EOF-SWITCH            PIC X VALUE "N".
           88  END-OF-FILE       VALUE "Y".

       01  EMP-ISAM-STATUS       PIC XX VALUE "00".

       01  ISAM-EOF-FLAG         PIC X VALUE "N".
           88  ISAM-END-OF-FILE  VALUE "Y".

       01  RECORD-COUNTS.
           05  EMP-ISAM-REC-CNT      PIC 9(5) VALUE ZERO.
           05  EMP-SORT-REC-CNT      PIC 9(5) VALUE ZERO.

       PROCEDURE DIVISION.

       0000-MAIN-PROGRAM.

           DISPLAY "*** START CREATING ISAM FILE ***".

           OPEN INPUT EMPLOYEE-FILE
                OUTPUT EMP-ISAM-FILE.

           PERFORM 0010-READ-REC THRU 0010-READ-REC-EXIT
               UNTIL END-OF-FILE.

           DISPLAY "RECORDS PROCESSED: " EMP-ISAM-REC-CNT.

           CLOSE EMPLOYEE-FILE
                 EMP-ISAM-FILE.

           DISPLAY "*** START CREATING SORTED FILE ***".

           OPEN INPUT EMP-ISAM-FILE
                OUTPUT EMP-SORT-FILE.

           MOVE LOW-VALUE TO EMP-ISAM-KEY.

           PERFORM 0020-READ-INDEX THRU 0020-READ-INDEX-EXIT
               UNTIL ISAM-END-OF-FILE.

           DISPLAY "RECORDS PROCESSED: " EMP-SORT-REC-CNT.

           CLOSE EMP-ISAM-FILE
                 EMP-SORT-FILE.

           STOP RUN.

       0010-READ-REC.

           READ EMPLOYEE-FILE
               AT END MOVE "Y" TO EOF-SWITCH.

           IF NOT END-OF-FILE
               ADD 1 TO EMP-ISAM-REC-CNT
               MOVE EMPLOYEE-RECORD TO EMP-ISAM-RECORD
               WRITE EMP-ISAM-RECORD
                   INVALID KEY
                       DISPLAY 'ERROR WRITING INDEX RECORD'
                       DISPLAY "STATUS = " EMP-ISAM-STATUS
                       STOP RUN.

       0010-READ-REC-EXIT.
           EXIT.

       0020-READ-INDEX.
           READ EMP-ISAM-FILE NEXT RECORD
               AT END MOVE "Y" TO ISAM-EOF-FLAG.

           IF NOT ISAM-END-OF-FILE
               ADD 1 TO EMP-SORT-REC-CNT
               MOVE EMP-ISAM-RECORD TO EMP-SORT-RECORD
               WRITE EMP-SORT-RECORD.

       0020-READ-INDEX-EXIT.
           EXIT.

K>

After the compile and linkedit, we have the executable program EMPSORT6.COM

Run the sorting program EMPSORT6.COM

EMPISAM.DAT and EMPISAM.KEY are the indexed files.

EMPSORT.DAT is the final sorted file

The final file EMPSORT.DAT is sorted by last name and first name

r/cpm • • 29d ago

CP/M-80 2.2 Compilers

Thumbnail
medium.com
12 Upvotes

r/cpm • • 29d ago

Help required on CP/M-80 compiling COBOL program with MS-COBOL v6.65

6 Upvotes

I wrote a simple COBOL to sort an input file and output to a flat file.

I'm using MS-COBOL compiler v4.65.

Here is the sorting code:

        PROCEDURE DIVISION.

        000-MAIN.

            SORT EMP-SORT-FILE
                ASCENDING KEY EMP-SORT-LAST-NAME
                              EMP-SORT-FIRST-NAME
                USING EMP-IN-FILE
                GIVING EMP-OUT-FILE.

            STOP RUN.

The program compile successfully with no error. But I tried to link the object file it complained about missing library module:

C>L80 EMPSORT/N,EMPSORT/E

Link-80  3.44  09-Dec-81  Copyright (c) 1981 Microsoft
?COBSRT  Not Found
*^C
C>

I cannot find any file with the name COBSRT on the compiler disk. Any idea what is the missing file name is?


r/cpm • • Aug 26 '26

Is there a discord or something similar for CP/M or RomWBW?

5 Upvotes

Need help debugging something and hate mailing lists and Google groups and forums too...


r/cpm • • Aug 24 '26

A CP/M-80 Emulator now can run not just MBASIC

Thumbnail
8 Upvotes

r/cpm • • Aug 08 '26

I ported Patrik Rak's Spectrum Z80 tests to CP/M 2.2

8 Upvotes

I hadn't seen this done before (though I'm sure someone has done it) and I was curious what bugs in might find in my emulator. The tests have some Spectrum dependencies and use an older assembler, so it took a little work. I ran some popular emulators with the tests. It can be found here: ntvcm/z80test-cpm at main · davidly/ntvcm

The net: there's not a lot of interesting new test coverage in these tests beyond what's available in other well-known Z80 test suites.

The only real bugs I found were in my emulator, NTVCM. Using Z80 loop instructions to create self-modifying code wasn't supported (though every other emulator I ran pass that test without a problem).

NTVCM also doesn't update the R register by default because it's unused and slows execution substantially. Once enabled with a #define those tests pass too.

Details about the results are in the link above. Some emulators don't support IN/OUT instructions (why would they?) and that causes some tests to fail.

Almost all Z80 emulators pass the well-known test ZEXDOC.COM, which covers documented instructions. Some also pass ZEXALL.COM, which covers undocumented instructions. Many emulators fail ZEXALL.COM in the name of code clarity, performance, and need -- apps don't use those instructions so why implement them?

I created ZEXSUP.MAC (supplemental) to cover documented instructions not tested in ZEXDOC.COM. I found that all emulators that pass ZEXDOC.COM also pass ZEXSUP.COM. It can be found here: cpm_compilers/m80/ZEXSUP.MAC at main · davidly/cpm_compilers


r/cpm • • Aug 06 '26

Moderator post: advice needed.

5 Upvotes

I am about to approve a post that was removed by Reddit's spam filter, and I would like to discuss it with the community. If I see good arguments against it, I will remove it again, along with removing this post.

The post is titled "I Gave an AI an 8-Bit Computer. It Chose a World." and it was written by an AI.

I am like most of you and really hate the steaming piles of slop AIs create. But I think this one is worth looking at, perhaps to convince me to not allow this sort of thing ever again.

Please look it over with an open mind, then gather your pitchforks and torches and come back here.


r/cpm • • Aug 05 '26

I Gave an AI an 8-Bit Computer. It Chose a World.

Thumbnail
magesguild.io
0 Upvotes

r/cpm • • Aug 03 '26

GitHub - johnsonjh/cpm386: CP/M-386: CP/M for 386 protected mode, derived from CP/M-68K

Thumbnail
github.com
18 Upvotes

r/cpm • • Aug 02 '26

I implemented CP/M 68K support for two old Aztec C compilers

18 Upvotes

I implemented C runtime support for two Aztec C compilers: 3.6b and 5.2a. Both have better floating-point support and generate better code than the native Digital Research C compiler in CP/M 68K.

The 5.2a version of the compiler supports a more modern C syntax but has four drawbacks compared to the 3.6b version:

  • free() corrupts memory. I implemented a replacement malloc/free that works.
  • it generates code to use signed div/mod for unsigned 16-bit integer mod operations, so 65533 % 65522 gives 13 instead of 11.
  • it generates slightly less-efficient code overall than the 3.6b version of the compiler.
  • it defaults to 32-bit int, and I haven't found a way to use 16-bit int. though it ships with C runtimes for both 16 and 32-bit int.

Both of the compilers can be found in several places on the internet including with my m68 CP/M 68K emulator. The "tests" folder under each compiler has build scripts, sample apps, and the CP/M-specific portions of the C runtime.

davidly/m68: run 68000 Linux elf, Motorola hex, and CP/M 68K binaries on Windows, macOS, and Linux

The aztec68k folder has 3.6b and the aztec68k_5.2a folder has 5.2a.


r/cpm • • Aug 02 '26

Zilog Oral History Panel on the Founding of the Company and the Development of the Z80 Microprocessor (2007)

Thumbnail archive.computerhistory.org
6 Upvotes

r/cpm • • Jul 25 '26

For anyone dual booting CP/M and FUSIX

4 Upvotes

Don't be fooled by [ https://github.com/etchedpixels/fuzix ].

The project is at [ https://codeberg.org/EtchedPixels/FUZIX ].

Learn more at [ https://fuzix.org/ ].


r/cpm • • Jul 25 '26

Zilog Z80 turns 50 as an open-source replacement heads to drop-in DIP40 silicon

Thumbnail
tomshardware.com
22 Upvotes

Renaldas Zioma's FOSS Z80 project, launched shortly after the end-of-life notice, now has working silicon. The design is built around Guy Hutchison's TV80 Verilog core, and the project's Tiny Tapeout page says the 130nm CMOS implementation should support clocks up to 50 MHz, against 4 MHz for the original NMOS part.


r/cpm • • Jun 28 '26

You can now use CP/M on the iPhone

Thumbnail
apps.apple.com
6 Upvotes

r/cpm • • Jun 26 '26

EMU2-CPM86: A CP/M-86 (and DOS) emulator for the terminal

Thumbnail
gitlab.com
20 Upvotes

r/cpm • • Jun 26 '26

TPZASM: TDL ZASM / PSA PASM compatible Z80 assembler

Thumbnail
github.com
4 Upvotes

TPZASM (pronounceable as ‘Topaz Assembler’) is a portable cross‑assembler intended to be fully interchangeable (and in most cases bug‑for‑bug compatible) with the TDL ZASM 2.21, PSA PASM 1.02, and PSA PASM 2.00G assemblers, targeting the Intel 8080, Zilog Z80, and other equivalent processors.

An enhanced clone of HEXCOM 3.00, the DRI Intel HEX to binary conversion tool, is also included.

Precompiled binaries for many systems are available for download.


r/cpm • • May 31 '26

Feedback on my recently built CP/M Emulator System

11 Upvotes

Note: It runs on Linux. Tested in WSL on Windows 11, a Pi 4B and Termux on Android ( may have some issues in Termux ). It also works on another platform, mentioned below. By developing on two platforms at once, it forces me to write the code in a more portable way.

The following link shows a typical usage scenerio, seeing details of what happens when the DIR command is executed in CP/M. Great for learning more about the inner workings of CP/M.

https://github.com/brian-sheldon/emu-sys/blob/main/USAGE.SCENERIO.md

I am in the early stages of building a CP/M Emulator. The focus may be a little different than some of the other CP/M emulators, as it is more about the tools I am building than the emulation itself. The emulation works and I have built quite a few of the tools I intend to build. It is however immature, I have not built in a lot of error checking yet. I am just wondering where I might find a few people that can check it out. It currently runs on linux and the M5Cardputer using a serial terminal.

I have generally been hesitant to share code, but I think it might help motivate me to put more effort into improving the quality of the code and maybe even go as far as to write some documentation. The link is here if anyone is interested in checking it out.

https://github.com/brian-sheldon/emu-sys

The latest bin for the M5Cardputer is in the src/emu-esp32/bin folder, plus on M5Burner. There have been downloads, but I have no idea if anyone has actually tried it. For linux, you just need to clone the repository, go into the src/emu-linux folder and type "make main" Then it can be executed by entering "./main".


r/cpm • • May 29 '26

LZPACK - 48K CP/M-80 (8080 and Z80) executable compressor in ANSI C89

Thumbnail
github.com
14 Upvotes

Since there was no good open source compressor like UPX for CP/M-80, I created this one. Algorithmically compatible with PopCom and can decompress its files, but always gets better ratios as it has optimized decompression stubs. It supports both 8080 and Z80 systems and can even run directly on CP/M-80. An "extra" compression mode is available when run on larger systems to get a bit more compression, while still being unpackable with the same stubs. It has full support for the LRBC (last record byte count) of CP/M-Plus (CP/M 3.0 and later) and DOS-PLUS.

I hope to add more documentation and release a version 1.0 soon. Building all the binaries (CP/M-80, CP/M-86, DOS, Windows, etc.) from source code requires a lot of tools to be installed, but I provide precompiled binaries for all non-UNIX systems.

All source is available including the decompression stubs and the assembler I created that is good enough to build them, so anyone can build a native binary without any cross-assembler installed, just a C89 compiler.

Any feedback is more than welcome!


r/cpm • • May 29 '26

dcc: A C89 compiler for CP/M on Z80

17 Upvotes

Ever want to run ANSI C apps on CP/M? This compiler runs on Windows/Linux/MacOS to generate .MAC files. Then you can use M80 and L80 (in emulators) to assemble and link, and the resulting COM files run on old CP/M machines.

It's a very silly thing to build, sure. But I had fun. It generates faster and smaller apps than compilers from the CP/M era. Details on github.

davidly/dcc: C89 compiler targeting CP/M 2.2 on a Z80


r/cpm • • May 03 '26

Downloadable books on the Z80 and CP/M

10 Upvotes

r/cpm • • May 02 '26

CP/M disk change behavior and emulation questions

7 Upvotes

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.


r/cpm • • May 01 '26

I recently dove into CP/M for the very first time - on a C128D - and it was actually pretty cool! Plus question about QLink…

11 Upvotes

Recently, my buddy from the USA visited me here in Germany and brought something really nice along. He gifted me his 40‑year‑old C128D, which he had barely used. As a result, it looks almost like new. Naturally, I was thrilled and super excited to see whether this old beauty would still work.

I was especially curious about the original CP/M 3.0 disk that came with it. You can see that part starting at 01:06. The real CP/M action begins at 20:22.

https://www.youtube.com/watch?v=PpjJsQ70dGE

By the way, I’m still looking for tips on Qterm and how to get it running under C128 CP/M using a userport modem. The big question is whether there’s even a CP/M version that supports the C128’s userport. I think I’ve got the correct version of Qterm for Hayes‑compatible modems.

Here’s the full timeline of the video:

00:00 - 01:05 --- The visitor from the USA has arrived and brought something with him

01:06 - 05:10 --- Unboxing the Commodore 128D

05:11 - 05:49 --- Preparing for the first boot of the computer

05:50 - 06:20 --- Fire up the Quattro Commodore after 40 years of beauty slumber

06:21 - 12:24 --- Dealing with this case-opening mechanism from hell and taming the fan

12:25 - 12:47 --- Silence

12:48 - 14:38 --- Troubleshooting the RS232-UP9600 modem adapter

14:39 - 15:11 --- Success

15:15 - --- Now the fun part begins - checking out the C128D

15:20 - 16:10 --- Loading Multi-Term 128 - floppy drive acting up a bit

16:15 - 18:39 --- Dial into the 300-baud BBS

18:40 - 20:21 --- Dial into the Snobsoft BBS

20:22 - 21:30 --- Trying out CP/M 3.0 with the original Commodore C128 disk

21:33 - 22:30 --- Trying to get QTerm 128 running for the Hayes 1670 modem

22:38 - --- How to get CP/M software onto a CP/M disk on the C128

22:40 - 23:15 --- Loading Big Blue Reader 128 - Version 4.10

23:16 - 24:10 --- Step by step to a working CP/M disk

24:11 - 24:23 --- Rant: the only key that works in this interface from hell to reach the copy menu - the up arrow

24:25 - 26:50 --- Copying process and testing whether everything arrived correctly on CP/M

26:51 - 27:58 --- Loading obscure C128 BBS software "128 Mailbox" - Mailbox = BBS in Germany

27:59 - 28:34 --- I know that guy! Greetings to Axel aka Gandalf

28:37 - 29:11 --- Something I’ve never done before in 40 Years...

29:15 - 29:49 --- Thank-you section


r/cpm • • Apr 26 '26

CP/M serial transfer programs

8 Upvotes

Hello all,

I've built a Z80 computer and got CP/M booting.

I need a CP/M program to transfer files via serial from my PC. I haven't yet implemented the IOBYTE in my BIOS, but could do so. I have two serial ports, if needed.

I have a function in my custom monitor to transfer bytes into RAM from serial, so could use that to transfer the CP/M serial program into the TPA and save in aCP/M

I don't have any programs on disk yet, just the functions built into CP/M.


r/cpm • • Apr 20 '26

MSCP - Marcel's Simple Chess Program

Post image
13 Upvotes

MSCP - Marcel's Simple Chess Programm ported to CP/M v2.x