PDP-11 Paper Tape BASIC

Introduction

DEC-11-AJPB-PB

This page provides an overview of PDP-11 paper tape BASIC, and the computer equipment it was typically used with. It then describes how to load and run PDP-11 BASIC on real PDP-11 hardware, and how it can be run instead on a modern Windows-based PC, under the open-source SIMH PDP-11 simulator. Some sample BASIC programs are also provided, for demonstration purposes.

Original Hardware

Digital Equipment Corporation (DEC) released BASIC for its PDP-11 computers in approximately 1970. It was distributed on paper-tape, and was designed to be used on systems that had no other mass storage devices. It was typically used on the PDP-11/05 and PDP-11/10 computers in the early 1970s.

PDP-11 BASIC was closely modelled on the original version of BASIC; Dartmouth BASIC. There are differences between the two languages, and these difference are documented in DEC’s PDP-11 Basic Programming Manual (see references section below).

PDP-11 BASIC can be used on a minimal PDP-11 system with only 4kW (8kB) of core memory and a Teletype Model 33 teleprinter, provided the Model 33 is equipped with a paper tape reader and punch. In fact, PDP-11 BASIC is not able
to load programs from, or save them to, any other mass storage device (other than the optional high-speed paper tape reader/punch, as mentioned in the next section).

The Model 33 teleprinter consists of a keyboard, printer, paper tape reader, and paper tape punch. It interfaces to the PDP-11 via a 20mA current loop interface (one loop for TX data, and a separate loop for RX data). The loops are powered by the PDP-11. They are not electrically isolated from the PDP-11, but they are isolated at the Model 33 end. Data is exchanged in ASCII format at 110 baud. Keyboard and printer data consists of 7 data bits, followed by a parity bit always MARK parity) and two stop bits. This results in a data transfer rate of 10 characters per second (cps). The Model 33 keyboard and printer only support upper case characters.

A third current loop called Reader Enable is used by the PDP-11 to request an 8-bit byte of data from the paper tape reader. When the PDP-11 energises this loop, the paper tape reader sends one byte of data to the PDP-11 (via the RX data loop that is shared by the keyboard and paper-tape reader). By only energising the Reader Enable loop when it is ready to receive a byte from the paper tape reader, the PDP-11 controls the paper tape reader. Paper tape reader and punch data consists of 8 data bits, no parity bit, and 2 stop bits.

All data transmitted by the PDP-11 on the TX data loop is printed on the Model 33’s printer. If the data is intended to be punched on paper tape, the user must manually engage the tape punch before the transmission begins. When the tape punch is engaged, all data sent by the PDP-11 via the TX data loop is both punched and printed.

The user would enter, run and debug PDP-11 BASIC programs using the Model 33’s keyboard and printer. The paper tape reader is used to load the BASIC language itself, and to load user programs (in BASIC source code) that have been saved on paper tape. The paper-tape punch is used to save user programs (in BASIC source code). The BASIC
programs can’t read or write their own data via paper tape. Instead, all I/O for the BASIC programs is via the Model 33’s keyboard and printer, other than data contained in DATA statements in the program itself.

The Model 33 teleprinter uses PDP-11 I/O addresses 177560-177567.

Optional high-speed paper tape reader/punch

Some PDP-11 systems were equipped with an optional “high-speed” paper tape reader and punch. The high-speed unit could read at 300 cps and punch at 50 cps, which is a big improvement over the 10 cps achieved by the Model 33 teleprinter.

On systems equipped with a high-speed unit, the BASIC program itself, and user programs, would be read and punched on that equipment (instead of on the Model 33), leaving the Model 33 to be used just for keyboard input and printer output.

The high-speed paper tape reader and punch uses PDP-11 I/O addresses 177550-177557.

Loading BASIC on a real PDP-11

The focus of this page is on loading PDP-11 BASIC on a PDP-11/10. We will include the high-speed paper tape reader and punch in our hypothetical example.

Step 1: Toggle in the bootstrap loader

The PDP-11/10 does not have a BIOS or boot ROMs. So the computer does not automatically execute any code at startup. Instead, the initial startup program must be toggled in using the switches and LEDs on the front panel of the PDP-11.

So using the front panel, we key in the Bootstrap Loader. The Bootstrap Loader varies from system to system, depending on the amount of memory installed and whether a high-speed paper tape reader/punch is installed. The impact of these variables is explained in Appendix D of the Programming manual.

For the purpose of this example, we will assume a high-speed paper tape reader/punch is installed, and the PDP-11 has 8kW (16kB) of core memory.

Here is the Bootstrap Loader to be keyed in:

Location  Instruction
 037744     016701
 037746     000026
 037750     012702
 037752     000352
 037754     005211
 037756     105711
 037760     100376
 037762     116162
 037764     000002
 037766     037400
 037770     005267
 037772     177756
 037774     000765
 037776     177550

Step 2: Loading the Absolute Loader from paper tape

Position the Absolute Loader paper tape in the high-speed reader. Set the Switch Register (through the front panel) to 037744, move the ENABLE/HALT switch to the ENABLE position, and press the START switch.

The Bootstrap Loader will now load the Absolute Loader into memory.

Step 3: Loading PDP-11 BASIC

Set the Switch Register to 037500 and press LOAD ADRS. Now Set the Switch Register to 0. Position the 8k version of the PDP-11 BASIC paper tape in the high-speed reader. Now press the START switch. PDP-11 BASIC will be read in via the tape reader, and it will automatically start. [Note: This paragraph needs to be verified by operation of the real machine]

Step 4: Configure PDP-11 BASIC

BASIC will type its name and version number, and then give you the following prompt:

PDP-11 BASIC, VERSION 007A
*O

This prompt is asking you to select “options”. These are described in Section 7.1 of the Programming Manual. For the purpose of this example, just press RETURN on the Model 33.

BASIC will now give you the READY prompt.

Now you are good to go. Type in a program (with numbered lines), or enter commands for immediate execution.

Some handy commands to know at this point are:

LIST – to list all program lines in memory

SAVE – to copy the current program from memory to paper tape

OLD – to load a program from paper tape into memory

DELETE – to delete all program lines from memory

It is important to note that PDP-11 BASIC does not accept lower-case characters. This is not a problem when using a Model 33 teletype, as it only has upper-case characters. It could however be a problem if you are using a video terminal in place of the Model 33.

Setting up PDP-11 BASIC on a Windows PC

It is possible to run PDP-11 BASIC on a Windows PC using the SIMH simulator.

The setup process is described below.

Step 1: Download and install the SIMH executable

Download and install the Windows executable version of the SIMH PDP-11 simulator from this website. The download is a ZIP file with multiple files in it. You only need a single file called pdp11.exe. There is no install process involved. Just place the file in an empty directory. The version I am using is 3.9.0.

Step 2: Setup the SIMH configuration file

Using a text editor, create a file called pdp11.ini in your SIMH directory.

ECHO Preparing to boot and run PDP-11 Paper Tape BASIC

; Set CPU parameters - PDP-11/05 with 8kW (16kB) of core memory
SET CPU 11/05
SET CPU 16K

; Throttle SIMH to limit CPU usage, heat and fan noise
SET THROTTLE 5%

; Disable devices that we don't need
SET HK DISABLE
SET RHA DISABLE
SET DZ DISABLE
SET RL DISABLE
SET RX DISABLE
SET RP DISABLE
SET RQ DISABLE
SET TM DISABLE
SET TQ DISABLE
SET RK DISABLE

; Enable the high-speed paper tape reader/punch
SET PTR ENABLE
SET PTP ENABLE

; Deposit the Bootstrap Loader into core memory
; This version assumes 8kW (16kB) of core memory and
; requires the high-speed paper tape reader/punch.
DEPOSIT 037744 016701
DEPOSIT 037746 000026
DEPOSIT 037750 012702
DEPOSIT 037752 000352
DEPOSIT 037754 005211
DEPOSIT 037756 105711
DEPOSIT 037760 100376
DEPOSIT 037762 116162
DEPOSIT 037764 000002
DEPOSIT 037766 037400
DEPOSIT 037770 005267
DEPOSIT 037772 177756
DEPOSIT 037774 000765
DEPOSIT 037776 177550

;  Attach the Absolute Loader paper tape
ATTACH PTR DEC-11-L2PC-PO.ptap

ECHO ... Execute Bootstrap Loader (to load Absolute Loader from paper tape)
GO 037744

; We are going to use a PuTTY session in place of the Model 33
; Configure PuTTY as follows:
;	Connection Type: Telnet
;	Host Name: 127.0.0.1
;	Port 6969
SET CONSOLE TELNET=6969

; Attach the 8kW PDP-11 BASIC paper tape
ATTACH PTR DEC-11-AJPB-PB.ptap

; Set SR to 0 for a normal (rather than relocated) load
DEPOSIT SR 0

ECHO ... Execute the Absolute Loader (to load BASIC from paper tape and run it)
GO 037500

Step 3: Download the DEC paper tape images

Download the Absolute Loader paper tape image from here and store it in your SIMH directory.

Download the PDP-11 BASIC paper tape image from here and store it in your SIMH directory.

Step 4: Download and configure PuTTY

Obviously we need a Console through which we can communicate with PDP-11 BASIC. On a real PDP-11 system, the Model 33 teleprinter is the Console. On SIMH, we can do the Console I/O through the SIMH window. However, we also use the SIMH window to communicate with SIMH (to type commands into SIMH, and for the reporting by SIMH of status and error messages).

A better alternative is to use a separate window for the Console. SIMH allows the Console to be implemented over a Telnet session. We are going to do this using PuTTY as the Telnet client.

To use a PuTTY window as the Console, follow these instructions:

  1. Download and install the latest stable release of PuTTY from this website. I am using Release 0.60
  2. Start PuTTY
  3. In the main PuTTY window (which should be the “Session” limb of the configuration tree), configure for a Telnet session to Port 6969 at 127.0.0.1
  4. Save this session as “SIMH” (or any other name you like), so you can configure PuTTY each time you run it, by simply double-clicking on the session name

Step 5: Start SIMH

Double-click on pdp11.exe. The SIMH window should report the ECHO messages that are in your pdp11.ini file, as SIMH loads and runs the Bootstrap Loader, Absolute Loader, and PDP-11 BASIC.

The SIMH window will have a message saying “Waiting for console Telnet connection”. So start PuTTY and double-click on “SIMH” in the list of Saved Sessions. The SIMH window should now say “Running”.

Your PuTTY window should now have the following messages:

Connected to the PDP-11 simulator


PDP-11 BASIC, VERSION 007A
*O

As described earlier, this is the PDP-11 BASIC “options” prompt. We can just press ENTER at this prompt.

PDP-11 BASIC will then respond with:

READY

You can now type in a new program, or enter immediate commands as described earlier. Remember that PDP-11 only recognises UPPER CASE letters. You will get the following error message if you try to type in lower-case characters: “ERROR 3 AT LINE 0”.

Step 6: Loading a BASIC program from paper tape image

We have configured SIMH to use the high-speed paper tape reader/punch. In SIMH terminology, device “PTR” is the paper tape reader, and device “PTP” is the paper tape punch.

Although not mandatory, I recommend you use the file extension “.PTAP” for your paper tape image files.

To load a BASIC program from a paper tape image into PDP-11 BASIC:

  1. Make sure your paper tape image file is located in your SIMH directory
  2. Click on the SIMH window
  3. Press CTRL-E to stop the simulation and to get the “sim>” prompt
  4. Type “ATTACH PTR SAMPLE.PTAP <ENTER>” (replace SAMPLE.PTAP with the name of your paper-tape image)
  5. Type “GO <ENTER>”
  6. Return to the Console window and type “OLD <ENTER>”. The program will load from the paper tape image file, and you should now be able to LIST and RUN the program

At this point it is a good idea (but not mandatory) to go back to SIMH and “DETACH PTR <ENTER>”. Remember that until you do this, the tape is still in the paper tape reader, but it is now positioned beyond the end of the tape. So
if you want to re-load the same tape, you either need to:

  • DETACH and ATTACH it again; or
  • enter the SIMH commands “DE PTR POS 0” and “RESET PTR” (both commands are required)

SIMH does allow you to view the current tape position pointer (use the SIMH command “EX PTR POS”) and change it (use the SIMH command “DE PTR POS 0” to move the tape pointer to the start of the tape). However, this technique does not work for me unless I follow it up with the SIMH command “RESET PTR”.

Another helpful SIMH command is “SHOW PTP <ENTER>”. This will tell you the name of the paper tape image that is currently attached. If no paper tape image is currently attached, it will say “not attached”.

Step 7: Saving a BASIC program to paper tape image

To save a BASIC program to a paper tape image:

  1. Click on the SIMH window
  2. Press CTRL-E to stop the simulation and to get the “sim>” prompt
  3. Type “ATTACH PTP SAMPLE.PTAP <ENTER>” (replace SAMPLE.PTAP with the name of your paper-tape image)
  4. Type “GO <ENTER>”
  5. Return to the Console window and type “SAVE <ENTER>”. The program in memory will be written to the paper tape image file

PDP-11 BASIC automatically appends 64 NUL character (Octal 000) to the end of the paper tape image. This behaviour is the same on real hardware.

At this point it is a good idea (but not mandatory) to go back to SIMH and “DETACH PTP <ENTER>”. Remember that until you do this, the tape is still in the paper tape punch, and it is positioned at the end of the tape. Another point to remember is that until you DETACH the paper tape image, it will only be cached (ie – the actual file won’t have been written to).

Example PDP-11 BASIC programs

Here are same example BASIC programs, taken from the Programming Manual.

Example 1: Loan Payment Calculator

This example is copied from page 2-2 of the Programming Manual:

10 REMARK -- PROGRAM TO COMPUTE INTEREST PAYMENTS
20 PRINT "INTEREST IN PERCENT";: INPUT J
26 LET J = J/100
30 PRINT "AMOUNT OF LOAN";: INPUT A
40 PRINT "NUMBER OF YEARS";: INPUT N
50 PRINT "NUMBER OF PAYMENTS PER YEAR";: INPUT M
60 LET N = N*M
65 LET I = J/M
70 LET B = 1+I
75 LET R = A*I/(1-1/B^N)
78 PRINT
80 PRINT "AMOUNT PER PAYMENT ="; R
85 PRINT "TOTAL INTEREST     ="; R*N-A
88 PRINT
90 LET B= A
95 PRINT " INTEREST     APP TO PRIN   BALANCE"
100 LET L= B*I
110 LET P= R-L
120 LET B= B-P
130 PRINT L, P, B
140 IF B>R GOTO 100
150 PRINT B*I, R-B*I
160 PRINT "LAST PAYMENT =" B*I+B
200 END

To run this program, start PDP-11 BASIC with option “E”. The program output should look like this (user input is in red):

INTEREST IN PERCENT?9
AMOUNT OF LOAN?2500
NUMBER OF YEARS?2
NUMBER OF PAYMENTS PER YEAR?4

AMOUNT PER PAYMENT = 344.9615
TOTAL INTEREST     = 259.6924

 INTEREST     APP TO PRIN   BALANCE
 56.25         288.7115      2211.288
 49.75399      295.2076      1916.081
 43.11182      301.8497      1614.231
 36.3202       308.6413      1305.59
 29.37577      315.5858      990.0041
 22.27509      322.6865      667.3176
 15.01465      329.9469      337.3707
 7.590841      337.3707
LAST PAYMENT = 344.9616

STOP AT LINE  200
READY

Note: There is a problem with this program. BASIC under SIMH does not calculate exponential values correctly (such as “PRINT 2^3”) unless “E” is entered at the “options” prompt when PDP-11 BASIC first starts. I am not sure whether this is a problem with the PDP-11 paper tape, or the SIMH program.

Handy tips

Throttling SIMH

When I run SIMH on my laptop, it puts the CPU under intense load. This causes the laptop to get hot, and the cooling fans to run on high. This is why I added the line “SET THROTTLE 5%” to the SIMH configuration file pdp11.ini. I tried lower figures (such as 1%) but they seemed to result in SIMH running at full speed. The 5% figure still runs the PDP-11 simulator at an adequate speed for me.

Deleting your current BASIC program

PDP-11 BASIC does not have a “NEW” command. There are two ways to delete a program currently in memory:

  • Enter the command “OLD”. This deletes the program in memory, and then attempts to load another program from the paper tape reader; or
  • Enter the command “DELETE 1,8191”. This deletes the full range of program lines

Halting the execution of a BASIC program

Press CTRL-P to halt execution of a BASIC program. This is handy if your program is stuck in an endless loop.

Revision History

24-Mar-2013: Original version

03-Jul-2016: Ported to new WordPress website and re-formatted to suit