Hello World assembly language program for PDP-8/I

217 views
Skip to first unread message

Mark Lawler

unread,
Jun 15, 2021, 7:48:23 PM6/15/21
to PiDP-8
I was able to get a "Hello World!" to work today.  Yay!  I know, it's those small accomplishments that keep me going.  I found a few examples online, but just couldn't get any to work that didn't seem to spin forever waiting for TSF to flag that it was ready past the first or second character.  I ran across an example on page 5-12 of the "INTRODUCTION TO PROGRAMMING PDP-8 Family Computers" that I made some edits to it (I hate hard coded string lengths vs being terminated by a character and I prefer programs that do a JMP I [7600 to return to the monitor program for OS/8 upon completion vs a simple HLT).  It also forced me to retrain my brain to use EDIT after decades of WYSIWYG...

Here's the source I ended up with...  I named the file HELLO3.PA, assembled it with what I believe to be PAL8 (looks like PAL is an alias for it on my machine) and I ran with the LOAD/G HELLO3 command.

Best...

/ EVERYBODY NEEDS A HELLO WORLD PROGRAM...
/ THIS MODIFIED FROM THE EXAMPLE ON PAGE 5-12 OF
/INTRODUCTION TO PROGRAMMING PDP-8 FAMILY COMPUTERS
*200

HELLO,  CLA CLL                 /INITIALIZE ACCUMULATOR AND LINK
                 TLS                         /TLS TO SET PRINTER FLAG
                 TAD CHARAC       /SET UP INDEX REGISTER
                 DCA IR1                 / FOR GETTING CHARACTERS
NEXT,     TAD I IR1               /GET A CHARACTER
                SNA                         /IF AC NOT ZERO THEN SKIP NEXT INSTRUCTION
                JMP I [7600             /EXIT PROGRAM AND RETURN TO MONITOR
                JMS TYPE              /TYPE IT
                JMP NEXT              /GO FETCH AND TYPE NEXT CHARACTER

TYPE,   0                                /TYPE SUBROUTINE
               TSF                          /WAIT FOR PRINTER READY
               JMP .-1
               TLS                          /SEND THE CHARACTER TO PRINT
               CLA                         /CLEAR CHARACTER AND
              JMP I TYPE              /RETURN FROM SUBROUTINE

CHARAC, .                             /USED AS INTIAL VALUE OF IR1
               310                           /H
               305                           /E
               314                           /L
               314                           /L
               317                          /O
               240                         / (SPACE)
               327                         /W
               317                         /O
               322                         /R
               314                         /L
               304                         /D
               241                         /!
               000                        /<EOS>

IR1=10
$

Mark Lawler

unread,
Jun 16, 2021, 4:45:40 PM6/16/21
to PiDP-8
And then of course I find this today at https://tangentsoft.com/pidp8i/file?name=examples/hello.pal&ci=tip, which works... :)  Only thing I'd change is the HLT, but that's a personal preference I suppose... :) 

Best,
-Mark

Steve Tockey

unread,
Jun 16, 2021, 5:48:25 PM6/16/21
to PiDP-8
Mark,
Do you have the OS/8 v3d Language Reference Manual (http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/pdp8/os8/AA-H609A-TA_OS8_Language_Reference_Manual_Mar79.pdf)? There's a whole section on PAL-8. Clearly, your code works. But, for example, PAL-8 supports a " operator so you would not have to look up (or remember) the ASCII character codes. Specifically, your code could be changed to:

CHARAC, .       /USED AS INTIAL VALUE OF IR1
               "H
               "E
               "L
               "L
               "O
               ",
               "       / "<SPACE>
               "W
               "O
               "R
               "L
               "D
               "! 
               0      /<EOS>

Or, even:

CHARAC, .       /USED AS INTIAL VALUE OF IR1
               "H; "E; "L; "L; "O; " ;",; "W; "O; "R; "L; "D; "!; 0

PAL-8 also has a TEXT// operator that turns the string between the /s into two 6-bit packed characters in each 12-bit word. It's not difficult to unpack, my implementation is about 40 instructions. Overkill, of course, for just TEXT/HELLO, WORLD!/ but convenient when you have PAL-8 code with many strings.

In addition, the OS/8 v3d Software Support Manual (http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/pdp8/os8/DEC-S8-OSSMB-A-D_OS8_v3ssup.pdf) explains how to call system functions like device-independent file I/O if you want to get really ambitious in your PAL programming.   :^)


Happy programming,

-- steve

Mark Lawler

unread,
Jun 16, 2021, 6:44:22 PM6/16/21
to PiDP-8
Steve,

Thanks for the links!  My experience on anything "PDP" is about 3 days in since building Oscar's kit.  Drinking from the firehose for sure!

Best,
-Mark

Reply all
Reply to author
Forward
0 new messages