Skip to main content

cpm80

CP/M-80 2.2 emulator with Python API.

Python package CI PyPI Python License: MIT

Based on the fast and flexible z80 emulator.

Installing

$ pip install cpm80

Running and terminating

$ cpm80
44k CP/M vers 2.2

A>save 1 dump.dat
A>dir
A: DUMP     DAT
A>exit

Enter exit or just hit Ctrl + C three times to quit the emulator.

Exchanging files with the host

The directory cpm80 starts in is mounted as drive B:, and fresh disks come with PIP, so files just copy.

$ ls
hello.txt
$ cpm80
44k CP/M vers 2.2

A>dir b:
B: HELLO    TXT
A>pip a:=b:hello.txt
A>save 1 b:dump.dat
A>exit
$ ls
DUMP.DAT  hello.txt

A single Ctrl + C re-reads the directory -- the usual CP/M way of telling the system the disk has changed.

Running commands automatically

From the command line:

$ cpm80 dir 'save 1 a.dat' dir

Alternatively, we can use the API's StringKeyboard class to feed arbitrary commands to the command processor, CCP, thus replacing KeyboardDevice console readers used by default:

import cpm80

COMMANDS = (
    'dir',
    'save 1 a.dat',
    'dir',
    )

console_reader = cpm80.StringKeyboard(*COMMANDS)
m = cpm80.I8080CPMMachine(console_reader=console_reader)
m.run()

string_keyboard.py

Output:

44k CP/M vers 2.2

A>dir
NO FILE
A>save 1 a.dat
A>dir
A: A        DAT
A>

Getting output as a string

Similarly, we can replace DisplayDevice console writers used by default with custom writers to do special work for the emulator's output. For example, one could use a StringDisplay writer to gather the output into a string.

d = cpm80.StringDisplay()

m = cpm80.I8080CPMMachine(
    console_reader=cpm80.StringKeyboard('dir'),
    console_writer=d)

m.run()

print(d.string)

string_display.py

Making BDOS calls

BDOS calls can be performed on the machine object directly or by using convenience wrappers.

m = cpm80.I8080CPMMachine()

STR_ADDR = 0x100
m.set_memory_block(STR_ADDR, b'Hello $')
m.bdos_call(m.C_WRITESTR, de=STR_ADDR)

m.write_str('World!\n')

bdos_call.py

Working with files

Similarly, using BDOS wrappers one can manipulate files on disks.

drive = cpm80.DiskDrive()

m = cpm80.I8080CPMMachine(drives=[drive])
m.make_file('file.txt')
m.write_file(f'bin(100) is {bin(100)}\n'.encode())
m.close_file()
del m

# Then read and print the contents of the file using another machine.
m = cpm80.I8080CPMMachine(drives=[drive])
m.open_file('file.txt')
print(m.read_file())
m.close_file()

doing_files.py

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cpm80-1.1.0.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cpm80-1.1.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file cpm80-1.1.0.tar.gz.

File metadata

  • Download URL: cpm80-1.1.0.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cpm80-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8b1ca707ffa8c0c401baf897065c4ef5bc7e4e6411f072e94405cedc2ae2640e
MD5 73f2b043f2b824ac60e929cd44313675
BLAKE2b-256 e3fa3b4f5c3d6a4f95c07f051b7fba63fbba8ec2f866ef32696b9accd01e1fae

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpm80-1.1.0.tar.gz:

Publisher: release.yml on kosarev/cpm80

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpm80-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: cpm80-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cpm80-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8cd0aa5806d0ead518bb61e9a5e77a8182f96e441de471314ba00f06662f5b5e
MD5 40181cf2e5df5f8bfe02eb753ac8284c
BLAKE2b-256 6508e85aa4fbe3c41ed0a9db38ce76e5b94dedd450f7b2ab7391824f577dad42

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpm80-1.1.0-py3-none-any.whl:

Publisher: release.yml on kosarev/cpm80

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page