cpm80
CP/M-80 2.2 emulator with Python API.
Based on the fast and flexible z80 emulator.
Installing
$ pip install cpm80
Running and terminating
$ cpm80
>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
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()
Output:
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)
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')
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()
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cpm80-1.0.0.tar.gz.
File metadata
- Download URL: cpm80-1.0.0.tar.gz
- Upload date:
- Size: 30.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a26f5d609b44c5a4fc58bab57c2383a3802b2ceb17175bb794828fa87a72f735
|
|
| MD5 |
ae5918cd0e32e48cec5e0e521d75c933
|
|
| BLAKE2b-256 |
13cb608d7cb81ef6d299b16cd12b1b0677da2bd3c0e6b1921106bf4be2e1c811
|
Provenance
The following attestation bundles were made for cpm80-1.0.0.tar.gz:
Publisher:
release.yml on kosarev/cpm80
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpm80-1.0.0.tar.gz -
Subject digest:
a26f5d609b44c5a4fc58bab57c2383a3802b2ceb17175bb794828fa87a72f735 - Sigstore transparency entry: 2704548459
- Sigstore integration time:
-
Permalink:
kosarev/cpm80@c504a5e6389d160e9fbff2632a204b7e01d17731 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/kosarev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c504a5e6389d160e9fbff2632a204b7e01d17731 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cpm80-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cpm80-1.0.0-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6abf29a4193e5f1ae04fd6cc6870635dc2c548078e36bd6ce5087bba630e38d4
|
|
| MD5 |
70c9411d9c33eef70cc283507843022c
|
|
| BLAKE2b-256 |
239f895189c9f184514cf2613abfd4fa122e91ddee2ac3d13f4361f6144b6c03
|
Provenance
The following attestation bundles were made for cpm80-1.0.0-py3-none-any.whl:
Publisher:
release.yml on kosarev/cpm80
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpm80-1.0.0-py3-none-any.whl -
Subject digest:
6abf29a4193e5f1ae04fd6cc6870635dc2c548078e36bd6ce5087bba630e38d4 - Sigstore transparency entry: 2704548486
- Sigstore integration time:
-
Permalink:
kosarev/cpm80@c504a5e6389d160e9fbff2632a204b7e01d17731 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/kosarev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c504a5e6389d160e9fbff2632a204b7e01d17731 -
Trigger Event:
push
-
Statement type: