PDP-11 emulator in Python 3 with GUI.
It runs the Version 6 Unix operating system (1975), the code of which was famously covered by A Commentary on the Unix Operating System (1976) by John Lions.
This project is based on Julius Schmidt's PDP-11 emulator in JavaScript, which you can run in a browser.
Example screenshots:
- Python 3.5+
Make sure Python 3 is installed with Tcl version 8.6 or later (especially if you are using MacOS). To check:
python3 -c 'import tkinter; print(tkinter.TclVersion)'
- Run the file
pdp11.py
with Python. - Press button
Start routine
to run the OS. This will start the Unix shell.
Additional usage notes:
- Instead of
cd
, Unix V6 shell usedchdir
command. - Issuing command
stty -lcase
is needed to enable lowercase output. (In case you are wondering.) - Instead of
Ctrl+C
, press Backspace button if you want to halt execution of a program. - If you want to export the disk image for whatever reason, don't forget to execute the
sync
command first (it flushes the delayed I/O to disk).
Compared to the original JavaScript code, this implementation has the following benefits:
- pasting text into the terminal from clipboard is allowed (making it much more usable)
- resource friendlier
WAIT
instruction (not overheating the physical CPU) - syncing a directory between Unix V6 and your machine
- saving and loading the disk state
- faster output
- some commands were backported and included into the image (see tools directory)
The disk image included into this repository misses on most sources, man pages and documentation. It is unsurprising, knowing that RK05 disk could only contain around 2.5 MB of data, while the Unix V6 sources alone measure beyond that capacity.
Complete Unix V6 manual in somewhat searchable PDF can be found here.
The syncing feature allows you to synchronize a folder between your host OS and the emulated Unix V6. For this purpose, modification time of files is used to track changes between synchronized directories.
Because Unix V6 does not support modern dates, lower 24 bits of modtime in Unix V6 filesystem are used for current local time. Higher 8 bits are used to mark that files were synced. Files are considered in sync if their modification time (24 bits of it) match within 1 minute. Any synced files within Unix V6 filesystem will appear as having modification year of 1983.
To perform syncing, the emulator compares local directory with a Unix V6 directory finding pairs of files with the same name. When a file or subdirectory exists in one filesystem, but not in the other, it is simply created where it is absent. When an unsynchronized pair of files is observed, the following actions are taken:
- if the files were never synchronized before, they are downloaded: copied from Unix V6 into local directory
- if the files were modified inside Unix V6, they are also downloaded
- if the files were modified locally and were synced to Unix V6 more than a minute ago, they are uploaded: copied from local directory to Unix V6
The emulator can synchronize files both before Unix V6 is loaded and after. When Unix V6 is not running (in the boot screen), the RK05 disk image is accessed and manipulated directly.
When Unix V6 is running, at first, the GUI issues a sync
command to Unix, forcing the OS to flush any delayed I/O to disk. After that, the synchronized Unix directory is compared to a local directory via direct access to the disk image. All necessary changes on the Unix side are then performed via executing commands in the Unix terminal. This can be time-consuming, so be patient and don't press any buttons until syncing completes.
This emulator was used to restore Doug McIlroy's TMG compiler-compiler. I ported TMG from PDP-11 assembly to modern C. I used this emulator to compile the original assembly code and run it, making sure my port functions the same way as the original.
This project was used successfully, but only on MacOS. If you are willing to help, please, let me know if it runs on Linux and/or Windows.