Running 4K FORTRAN on a DEC PDP-8

4K FORTRAN was a subset of FORTRAN II and was the first high-level language available for the DEC PDP-8. It consisted of two parts: the 4K FORTRAN Compiler (nicknamed "Fivetran") and the 4K FORTRAN Operating System. The compiler was written by Larry Portner and the operating system was written by Henry Burkhardt. The introduction of this compiler made the PDP-8 much easier to program and was particularly useful to those using the machine for scientific calculations. Below is a guide to using 4K FORTRAN.

Obtaining 4K FORTRAN and Its Manual

The following files are all from Bitsavers. The 4K FORTRAN compiler is available as a paper-tape image called: dec-08-afc1-pb_9-13-67.bin, and the 4K FORTRAN operating system is also available as a paper-tape image called: dec-08-afc3-pb_8-67.bin. In addition, the 4K FORTRAN Programmers Reference Manual (May 1969) is available in PDF format.

Compiling Source Code

Once you have written some Fortran source code and committed it to paper-tape, you are ready to compile it. For more information on how to create and edit source code on paper-tape, have a look at my article: A Quickstart Guide to Editing Paper Tape with the Symbolic Tape Editor on the DEC PDP-8.

Example Source Code

Below is a simple piece of source code that calculates factorials. It can be entered using the Symbolic Tape Editor mentioned above. For those familiar with Fortran, note the non-standard use of semi-colons after labels, this is because the source is written on free-form paper tape not punched cards.

C;      THIS PROGRAM CALCULATES FACTORIALS
5;      TYPE 200
10;     ACCEPT 300,X
        FACT=Y=1.
        IF (X) 5,32,30
30;     IF (X-Y) 41,32,33
32;     TYPE 400,X,FACT
        GO TO 10
33;     FACT=FACT*(Y=Y+1.)
        GO TO 30
41;     PAUSE
        GO TO 5
200;    FORMAT (/, "PLEASE TYPE A POSITIVE NUMBER", /)
300;    FORMAT (E)
400;    FORMAT (/,E, "FACTORIAL IS",E)
        END

Instructions for Owners of a Real PDP-8

To load the compiler from paper-tape on a real PDP-8 just load the Binary Loader first and then the compiler from paper-tape in the normal way. Now attach the source code paper-tape to the paper-tape reader and some blank tape for the object code to the paper-tape punch. The compiler can then be started at Octal address 200. If you have a high-speed punch or reader then you will want to set Switch Register bit 1 to high for a high-speed reader and bit 2 to high for a high-speed punch (See appendix C of the Fortran Manual).

Instructions for Those Using SimH to Emulate a PDP-8

To load the compiler's paper-tape image from the current directory:

sim> load dec-08-afc1-pb_9-13-67.bin

SimH emulates a high-speed punch and reader, so you will want to set Switch Register bits 1 & 2 to high to tell the compiler that this is what you will be using.

sim> de sr 3000

Attach the Fortran source code to the paper tape reader. In this case we could attach the paper-tape image of the factorials source code from the example above:

sim> attach ptr factorials.ft

Attach a blank file to the paper tape punch, to store the object code produced by the compiler:

sim> attach ptp factorials.f.bin

To run the compiler on the source (200 here is in Octal):

sim> run 200

Running the Compiled Code in the 4K FORTRAN Operating System (Object Time System)

The code that is produced from the compiler can't be run on its own, it has to be run through the 4K FORTRAN Operating System. This seems like a pain to start with, but once you get used to it, you will find that it gives you more flexible control over the devices attached to the PDP-8, without having to re-write your Fortran programs.

Instructions for Owners of a Real PDP-8

Load the operating system from paper-tape via the Binary Loader in the normal way. If you have a high-speed punch or reader then you will want to set Switch Register bit 1 to high for a high-speed reader and bit 2 to high for a high-speed punch (See appendix C of the Fortran Manual). Now attach the object code paper-tape to the paper-tape reader. When the operating system is started at Octal address 200, it will load in the object code tape and halt. To set the operating system to use the teletype for ACCEPT and TYPE statements (user I/O) set bits 1 & 2 to low. All you have to do now to execute the object code is press CONTINUE, and if you want to run it a second time just start execution again at Octal address 201.

Instructions for Those Using SimH to Emulate a PDP-8

If you have not already done so disconnect the paper-tape images from the reader and punch:

sim> detach ptr
sim> detach ptp

To load the Operating System's paper-tape image from the current directory:

sim> load dec-08-afc3-pb_8-67.bin

Set the operating system to use the high-speed punch and high-speed reader:

sim> de sr 3000

Attach the object code produced by the compiler to the paper tape reader. In this case we could attach the paper-tape image of object code produced from the factorials source code above:

sim> attach ptr factorials.f.bin

Start the fortran operating system, which will load in the object code tape and halt:

sim> run 200

To set the operating system to use the teletype for ACCEPT and TYPE statements (user I/O):

sim> de sr 0000

To execute the object code:

sim> cont

To run the object code again:

sim> run 201

Where Now?

As you have seen, basic operation of the Fortran compiler is quite simple. Beyond this there is quite a bit more that can be done, such as using DECtape for processing data. The 4K FORTRAN manual does a good job of explaining how to use the compiler and operating system, as well as teaching this variant of Fortran. If you haven't used SimH before, take a look at my article: Emulating a DEC PDP-8 with SimH. As always, I would be interested to hear what you do with this.

Creative Commons License
Running 4K FORTRAN on a DEC PDP-8 by Lawrence Woodman is licensed under a Creative Commons Attribution 4.0 International License.

Share This Post

Feedback/Discuss

Related Articles

A Quickstart Guide to Editing Paper Tape With the Symbolic Tape Editor on the DEC PDP-8

Before re-writable storage devices, such as tape drives, become popular for the DEC PDP-8, owners had to rely on paper tape. This was fine for loading programs on pre-punched tape, but left the proble...   Read More

Emulating a DEC PDP-8 with SimH

The DEC PDP-8 mini-computer was launched on 22 March 1965 and was a great success. It was fairly cheap for the day and could easily be expanded. What attracts me most to the PDP-8 is its simple desig...   Read More

PDP-8 in 'Three Days of the Condor'

I watched 'Three Days of the Condor' the other night and loved seeing what I believe is a Dec PDP 8/E being used. Also featured in connection with this machine was a DecWriter, paper tape reader and p...   Read More

Modula-2 Compilers on CP/M

Modula-2 is a great language in general and is a good choice for programming on CP/M. There are three good compilers available for CP/M which all require a Z80 processor and we'll compare each in turn...   Read More

80 Columns in Software on the Commodore VIC-20

If you have good eyesight, a well-tuned display and patience it is possible to use 80 columns in software on the VIC-20. This is really just an experiment but considering the limitations of the Vic I ...   Read More