Compiling and Running ‘Hello World!’ in PDP-8 FORTRAN IV

(all PDP-8 blog entries can be seen by clicking here)

Since I figured out how to assemble PDP-8 PAL assembly language, I figured I should try to compile a FORTRAN program.

The PDP-8 has two FORTRAN compilers: FORTRAN II and FORTRAN IV. FORTRAN II is particularly primitive. In my second job, I some times had to translate FORTRAN II code to COBOL and detested FORTRAN II – mainly because the IF test was so cryptic.

The FORTRAN II if statement is in the form

IF (expression) label1, label2, label3

The is evaluated. If < 0, it branches to label1. If = 0, it branches to label2. If > 0, it branches to label3. Ugh.

FORTRAN IV has a proper IF statement so that is the FORTRAN I want to use.

And, of course, insisting on using FORTRAN IV created a headache. The initial disk image I have been using (which doesn’t have a working BASIC) also doesn’t have a working FORTRAN IV compiler.

If you attempt to compile a program in FORTRAN IV, I get the error ‘SY’ which indicates one of the additional programs (PASS2, PASS2O, or RALF) are missing or there isn’t enough memory. I know I have the programs, and SIMH provides the maximum possible memory (32K), so the problem would appear to be the compiler.

After doing a lot of searching I found an image that has a working FORTRAN IV compiler (I found the same SY error on several of the other OS/8 images). The working image can be found at;fn=images/os8/disk2.fortran.rk05;sort=name

To copy the necessary files, I did the following:

PDP-8 simulator V3.9-0
Type 'boot rk0' to begin and 'control-e' to return to SIMH prompt
sim> attach rk0 rk0.dsk                 #this is my primary drive
sim> attach rk1 f2.rk0                  #this is the image downloaded above
sim> boot rk0


Now let’s create a ‘Hello World!’ program in FORTRAN:


10      FORMAT(' HELLO WORLD!');
<ctl-G to exit Add mode>

10      FORMAT(' HELLO WORLD!');


To compile this, you must manually run the compiler and loader. I tried various combinations of using the COMPILE and LOAD commands and never got them to work.

To compile and load:

.R F4

and, finally to run the program:




Apr 2016 Update:

Based on some comments, I need to make a few additional comments.

Though I swear I had the F4 compiler working as above, others have had problems getting it to run using that syntax, and now I have the same issue.

Looking at the Fortran IV manual  it appears the proper way to compile, link, load&save is to use the syntax:

.R F4

Further, a short cut that will compile, link, load, save, and execute is to type:

.R F4

where the ‘$’ is actually the escape key.

The manual referenced above appears to match the compiler properly and is quite useful for trying to make sense of the cryptic compile errors you might get (like ‘MK 4’).

This entry was posted in c-retro and tagged . Bookmark the permalink.

15 Responses to Compiling and Running ‘Hello World!’ in PDP-8 FORTRAN IV

  1. Tom Lake says:

    I tried to compile the FORTRAN program HELLO.FT but the LD file doesn’t get created. See below.


    .R F4


    • Dan TheMan says:

      ‘SY’ Indicates an error occurred I believe. Compiling should have produced a listing file, probably called HELLO.LST. Type that, and see if there is an obvious error in the file.

      I don’t recall the format statement (or any FORTRAN statement) being terminated by ‘;’. You might try removing that.

      I see the ‘;’ in my example. It is possible while assembling the materials I had a typo in the example. If removing the ‘;’ works for you, let me know so I can fix the example.

      I don’t have the emulator laying around to just fire up and try myself w/o a bit of work.

    • Dan TheMan says:

      Found I had the emulator on my server so I fired it up. ‘;’ is not the problem. I compile the sample program fine.

      It appears to me that you are not formatting the program correctly. You cannot place program statements in columns 1-7. 1-6 are for labels and column 7 is for a continuation character. In my example, you will see that I use a TAB before each statement. Only the ’10’ starts in column 1, then I use TAB before the format.

      See for formatting info.

      I duplicated your program without tabs, and I get error ‘IF’, not ‘SY’. So you have something else going on as well. I did a quick google of ‘pdp-8 fortran sy’ and found the help file:

      If you jump down to the F4.SV program error codes you will find:


      Pass missing probably means one of the executables for the various passes is missing (the source program is read multiple times, each time being a pass). I believe these are all of the passes:

      F4 .SV 20
      PASS2 .SV 20
      PASS20.SV 5
      PASS3 .SV 8

      Make sure you have all of those program.

      The other possibility is you are out of room for the output file. When you do a DIR command, you will see the amount of free space:

      78 FILES IN 913 BLOCKS – 2279 FREE BLOCKS

      Make sure you’ve got a reasonable amount of free space.

  2. Tom Lake says:

    I took out the semi-colon and recompiled. The listing file shows no errors. There was no LD file produced until explicitly I ran LOAD:

    .R F4
    *HELLO,HELLO,HELLO<HELLO I have to specify all output filenames or nothing is produced

    .DIR HELLO.*

    HELLO .FT 1
    HELLO .LS 1
    HELLO .RL 2

    2121 FREE BLOCKS

    .R LOAD
    *$ (here I press Esc to exit the LOADER)




    • Dan TheMan says:

      Weird. My best guess is something goes wrong when F4 tries to run the loader which causes the SY error. That error then causes it to delete the object file? At least you got it figured out, and thanks for posting your solution here in case anyone else has the same issue.

  3. Neil says:

    I have been trying got get the trig functions working. I can compile a programs with lines like
    PI = 4.0*ATN(1.0)
    but I get a “user error” when I run them. Any hints?

    • Dan TheMan says:

      I tried to fire up my emulator to duplicate the problem and now I can’t get anything to compile (no errors, just no LD file gets output).

      My best guess is somehow the call to ATN is not being linked in. I don’t know if ATN is statically or dynamically linked. My guess would be static.

      Looking at the files in the directory, I have one called forlib.rl which I suspect is the static library. If you are missing that file, it may be the problem.

      • Dan TheMan says:

        OK, got my compiler running. I am seeing the same error and I know I have the forlib.rl file. Looking thru the F4 manual (file named AA0HG09A-TA_OS8LANG), I see that ATN is in FORLIB.RL, so it appears that library isn’t getting linked in.

        I’m out of time for the day, but the trick is almost certainly to include FORLIB.RL during the LOAD operation. Have a look there and if you get it let me know; otherwise, I’ll try to have a look this weekend.

        Also a general note: I couldn’t get this to work which is discussed above:
        .R F4

        as mentioned above, you can use

        also you can type
        then press ESCAPE – this will compile, link, and execute.

        I'll try to get that into the main body of this blog later.

    • Tom Lake says:

      In most versions of FORTRAN, ATN is not a function. Try ATAN() for ArcTANgent.

  4. Neil says:

    All working now. Not unlike the PDP-11 and RT-11, which I knew quite well – a tad more primitive.

  5. Neil says:

    Also note (if someone hasn’t already) that PASS2O.SV has O for Oscar not 0 for zero – pass 2 overlay.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.