SkillAgentSearch skills...

PDP8EmulatorIpad

PDP8 Emulator for the iPad

Install / Use

/learn @unclebob/PDP8EmulatorIpad
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

PDP-8 Emulator for iPad

This is my PDP8 Emulator for the iPad. It's written in Lua using the Codea platform. All the resources it uses are standard with Codea, or easily accessible, so you shouldn't have any difficulty running it as is.

The Model

The emulator is a faithful representation of a PDP-8 with 4096 12 bit words of core memory, and an ASR-33 Teletype. The Teletype is the only I/O device. The Teletype has an infinite roll of paper, an infinite amount of ink, and an infinite supply of paper tape. It has a built in paper tape reader, and a built in paper tape punch. By default they all operate at approximately 10 characters per second, though there are cheats to make them go significantly faster.

On my iPad, purchased in 2018, the emulator runs at just about the same speed as a real PDP-8. That speed is adjustable should you want it to execute slower than that.

Programming can be accomplished using the buttons on the front panel. I have taken the liberty of turning all the front panel lights into buttons so that the registers can be set by tapping the lights rather than using the switch register at the bottom. For that reason I have not implemented some of the front panel switches that the PDP-8 used to move data between the switch register and the registers.

Programming is better accomplished by using the text editor and the Pal III assembler. These are included as "paper tapes" that you can load by inserting them into the tape reader on the teletype and running the Bin Loader program. More on that later.

The output of the text editor is punched to paper tape. Then the Pal III assembler is loaded using the Bin Loader, and the source code tape is fed to the assembler to produce a binary paper tape containing your executable program. That binary paper tape can then be loaded using the Bin loader.

If that sounds confusing, don't worry. I'll be describing that process more in detail later. In the mean time, let's get this program loaded onto your iPad.

Getting Started

Step 1: Get Dropbox Connected to Codea's "assets".

The emulator runs as a Lua program within an iPad app named Codea. The paper tape images that are included with the emulator need to be moved into Codea's resources. This is best done through Dropbox.

Get the Dropbox app for your iPad. If you don't already have a dropbox account, you should create one now.

Get the Codea app for your iPad. Find the assets window and select dropbox. You'll be prompted to link Dropbox with Codea. You'll also see a sync button. Once synced, you'll see the directory /Dropbox/Apps/Codea was added to your Dropbox account.

The GitHub distribution contains a directory named tapes that contains all the paper tape images that you'll be using. Move these files into /Dropbox/Apps/Codea on your computer, and then verify that you can see them using the Dropbox app on your iPad, and inside the Codea assets under the Dropbox heading.

Step 2: Load the emulator source code into Codea

Go to the main Codea window on your iPad and create a new project. (Hit the big + button). Give the new project a name like PDP-8. You should see some minimal source code show up in the programming window. Ok, return to the main Codea window again.

Now select Codea's Air Code function. It will display a URL. On your computer, browse to that URL. You will see something like Codea's main window. Click on the PDP-8 project that you just created. You'll see an editor with the default source code. Delete it all.

On your computer find the src/PDP8.lua file in the GitHub distribution. Load it into a text editor and copy it all onto your clipboard (Command-A Command-C should do it), and paste it into the Air Code browser editor. Close the window.

Now return to your iPad and go to Codea's main window. Tap the PDP-8 project, and you should see the emulator source code show up. The first few lines should look like this:

--# Main
-- PDP8

-- To Do:
...

VERSION="..some version..."

Execute the emulator by tapping the arrow button at the upper right. (At least that's where it is on my version of Codea). You should see the emulator appear on your screen. If the keyboard window obscures part of the screen dismiss it. We'll deal with that later. The PDP-8 Control Panel will be at your lower right. The Teletype (TTY) paper will be above that. The paper tape reader and punch will be to the left of the TTY and Control Panel. And on the far left you should see a rack of paper tapes. We'll talk about them later.

Tap some of the lights on the control panel. You should be able to turn them on and off; but you won't hear any sounds, or you may even get errors printed on a popup modal. Let's fix that. Exit the emulator by taping the QuitX2 button (bottom center) twice, or the left arrow in the error modal.

Step 3: Load the sound library.

All the sounds we need are already assets known to Codea, but they need to be downloaded. Once again, go to Codea's asset window, and tap the download button next to Game Sounds One. The sound files will download quickly if you have a good network connection.

Now restart the emulator and tap the lights again. You should hear a pleasant little 'boink'.

Configuring the emulator for your iPad

After starting the emulator tap the RUN button on the front panel. You should see the lights blinking furiously. The PDP8 is rapidly executing the zeros in memory. (0000 is an AND instruction). Look at the lower right and you'll see a little statistics panel with three numbers in it.

  • fps: Frames per second. This is the number of times the screen is being redrawn per second. Codea tries to redraw the screen 60 times per second. If that number is much less than 60 it means that the emulator is taking longer than one sixtieth of a second to execute a batch of instruction.
  • ips: Instructions per second. This number, on an iPad pro (circa 2019) should be something above 100,000. On slower iPads it could be significantly less.
  • ipf: Instructions per frame. This is the batch size. It is the number of instructions that are executed between drawing frames. You can change this number by tapping the Speed button just to the left of the numbers. It defaults to 9999. The bigger the batch, the faster the emulator runs, but the slower the screen updates. If 'fps' is a lot lower than 30 you probably have a very slow iPad, and you might want to use the 'speed' button to reduce the batch size and slow the PDP-8 processor down.

Note on processor speed and old DEC programs.

I have found that some of the old DEC programs, particularly the PALIII assembler, misbehave when using the slow paper tape reader in combination with processor speeds greater than about 150,000 ips. I presume this is because the programs counted on the slow speed of the processor and the synchronization of the TTY and the tape reader on the ASR33. The emulator does not enforce that synchronization.

The symptom I have seen is that the paper tape reader reads one or two characters and then stops. I generally fix this either by slowing the processor using the processor speed button, or by switching the paper tape reader to FAST mode.

FOCAL (more on this later) works much better with faster processor speeds when reading programs from the slow reader. This is because FOCAL does not know it is reading from paper tape. The reader must be placed in AUTO mode, and FOCAL simply thinks someone is typing the program at the TTY keyboard. FOCAL is not fast enough to keep up with a very fast typist. ;-)

Keyboard

I use a bluetooth keyboard with my emulator. The mapping of keys to the old TTY works tolerably well, but there are a few strange exceptions.

  • Type Delete or Backspace for CR (Carriage Return)
  • Type Enter for LF (Line Feed)
  • Type Option-backslash for rubout (used by PDP-8 software as backspace or delete.)
  • Type Option-C for Ctrl-C
  • Type Option-L for Ctrl-L (Form Feed)
  • Type Option-G for Ctrl-G (Bell)
  • Type Option-1 for Ctrl-D (EOT)

Some bluetooth keyboard like to go to sleep. When this happens the iPad keyboard window may pop up. If you wake up the bluetooth keyboard, the iPad keyboard window should go away. If you dismiss the iPad keyboard window, you may find that your bluetooth keyboard will no longer work until you reboot the emulator. (Ugh. Trying to simulate 1960s equipment with all this fancy tech is challenging ;-)

iPad sleep.

If the iPad goes to sleep while the emulator is running, then when it wakes up the screen will not refresh properly. This is because, in order to give as much processing power to the PDP-8 as possible, I avoid redrawing the screen unless something changes. I'll be thinking about how to resolve this in future releases.

Manuals

The manuals directory of the GitHub distribution has several PDF files that you will find invaluable. Above all is the IntroToProgramming1969 (1).pdf manual; affectionately known as Introduction to Programming. This manual will tell you everything (and I mean everything) you need to know to program the PDP-8, including how to use the text editor, the assembler, and FOCAL (A basic like interpreter). This manual will be your bible. It starts with binary math, and takes you all the way through the wonderful world of the PDP-8.

The other manuals in that directory are supplementary. They contain separate, and somewhat more detailed, descriptions of the text editor, the assembler, the FORTRAN compiler, and FOCAL. Have fun with all of them.

The Front Panel

The lights on the front panel are also buttons. You can tap them to change their state. You can also slide your finger along the lights to change them as a group. Try it!

Chapter 4 of Introduction to Programming describes the PDP-8 control panel. You might want to read that and compare it to the

Related Skills

View on GitHub
GitHub Stars121
CategoryDevelopment
Updated7mo ago
Forks11

Languages

Lua

Security Score

72/100

Audited on Sep 8, 2025

No findings