Yet another blikenlights program?

173 views
Skip to first unread message

Mark Lawler

unread,
Jun 22, 2021, 6:32:22 PM6/22/21
to PiDP-8
So in my effort to try to learn some PDP-8/I PAL assembly language after getting Oscar's kit built I decided to take something I wrote for my Altair 8800 and IMSAI 8080 replicas and "port" it to the PDP-8/I.  The original started out as hacks on top of the Kill The Bit game as I was trying to learn 8080 assembly.  

Turns out it was more of a rewrite than a port due to the nature of the limited instruction set (and my newly acquired limited knowledge in it).  Whereas the Altair could use the LDAX instruction trick and the IMSAI had Programmed Output LEDs to display desired bit patterns on the panel, on the PiDP-8/I I decided to misuse and abuse the EAE to have the Multiplier Quotient lights handle the output display.  The program would probably be way simpler had I just used the EAE MQ correctly vs treating it only as a display means to an end...  I do have to admit I like the visual appeal of this version much better though given how the Incandescent Lamp Simulator that was added to the PiDP8 works. 

The source is ugly as this is a hack with only week's worth of experience after hours and over the weekend.  It is so bloated I even had to figure out why PAL was generating errors once I crossed a page boundary and then changed my source to fix it with a strategically placed next PAGE command.  I also had to give up on being a purist and using only EDIT midway through development (once the code became too long) and started to use the PIP command to input my source code changes from an outside text editor on the Raspberry Pi.

To input the source, assemble, then run:

     .R PIP
     .MARKBI.PA<TTY:
     <paste source here, press enter after the last '$', and then a ^Z to end the file, then the ESC key to exit PIP and save the code>
     .PAL MARKBI
     .LOAD/G MARKBI

And now the source (sorry for the formatting--old habit of tabs vs spaces didn't go so well for me, perhaps proving the case for spaces? <grin>):

/YET ANOTHER BLICKEN LIGHTS PROGRAM. THIS VERSION IS BASED ON 
/ONE FOR THE IMSAI 8080, BUT USING THE PDP-8'S EAE
/MULTIPLIER QUOTIENT TO SIMPLY DISPLAY THE FRONT PANEL LIGHT
/PANEL PATTERNS (WHEREAS THE IMSAI USED ITS PROGRAMMED OUTPUT
/DISPLAY).
/
/ SW 0: 0 - DOT          | 1 - DASH
/ SW 1: 0 - RIGHT      | 1 - LEFT
/ SW 2: 0 - NORMAL | 1 - BOUNCE
/ SW 3: 0 - NORMAL | 1 - RANDOM (IGNORE OTHERS)
/ SW ALL 1 = TERMINATE AND RETURN TO MONITOR PROGRAM
/
/CREATED JUNE 2022 BY MARK LAWLER

MUY=7405
MQA=7501
MQL=7421
CAM=7621

IR1=10 /DELAY INNER REGISTER
IR2=11 /DELAY OUTER REGISTER

*200

START, CLA CLL /CLEAR ACCUMULATOR AND LINK
JMS GCMD /GET COMMAND FROM SWITCHES
TAD DSPBTS /LOAD UP AND LIGHT UP
MQL /  MQ WITH DISPLAY BITS
JMS DELAY /TAKE A REST SO MQ ISN'T A BLUR
JMS CDSP /COMPUTE NEXT DISPLAY PATTERN
JMP START /LET'S GO DO THIS AGAIN

GCMD, . /ROUTINE TO READ SWITCHES FOR COMMANDS
CLA CLL /CLEAR ACCUMULATOR AND LINK
OSR /READ IN THE SWITCH VALUES
DCA CURSW /STORE AWAY FOR LATER RECALL
TAD CURSW /HAVE THE SWITCH SETTINGS EVEN CHANGED?
CIA         / MAKE THE NUMBER NEGATIVE
TAD LASTSW / AND ADD THE LAST TO IT. IF == 0 NO CHANGE
SZA /HAVE SWITCHES CHANGED SINCE LAST TIME?
JMP GCMD0 / YES: LET'S GO DO SOMETHING USEFUL
JMP GCMDE / NO: LET'S GET OUT OF HERE
GCMD0, /SWITCHES CHANGED -- GRAB AND EXECUTE COMMAND
CLA CLL
TAD CURSW /WHAT WERE THOSE SWITCH SETTINGS AGAIN?
DCA LASTSW /STORE THAT THEY'VE CHANGED
TAD CURSW /WHAT WERE THOSE SWITCH SETTINGS AGAIN?
CMA /TEST FOR 7777?
SNA / NO: EXAMINE SWITCH SETTINGS MORE
JMP I [7600 / YES: EXIT TO MONITOR PROGRAM
CMA /WHAT WERE THOSE SWITCH SETTINGS AGAIN?
AND (0001 /DISPLAY A DOT OR A DASH?
SNA / IT WAS THE DASH
        JMP GCMD1 / IT WAS THE DOT
CLA CLL
TAD DASH /LOAD THE DASH
DCA DSPBTS / STORE IT
JMP GCMD2 / AND TEST NEXT SWITCH
GCMD1,  TAD DOT /LOAD THE DOT
DCA DSPBTS / STORE IT
GCMD2,  TAD LASTSW /ARE WE GOING TO THE LEFT OR TO THE RIGHT?
AND (0002
DCA DIR /STORE OUR DIRECTION
GCMD3,  TAD LASTSW /DO WE WANT TO BOUNCE IN KITT MODE?
AND (0004
DCA BOUNCE /STORE IF WE BOUNCE OR NOT
GCMD4,  TAD LASTSW /DO WE WANT RANDOM BITS?
AND (0010
DCA RANDOM /STORE IF WE WANT RANDMOM BITS OR NOT
GCMDE, JMP I GCMD /RETURN TO CALLER

CDSP, . /ROUTINE TO COMPUTE NEXT DISPLAY PATTERN
CLA CLL /CLEAR AC AND LINK
TAD RANDOM /CHECK FOR RANDOM BITS
SNA /ARE WE RANDOMIZING?
        JMP CDSP1 / NO: CALC OUR NEXT ROTATION
JMS GETRND / YES: TEE UP THE NEXT RANDOM NUMBER
DCA DSPBTS /      STORE IT FOR DISPLAY
JMP I CDSP /      AND RETURN TO CALLER
CDSP1,  JMS ROT /TIME TO ROTATE SINCE NOT RANDOM
JMP I CDSP /AND RETURN TO CALLER

GETRND, 0                    /ROUTINE GENERATES A RANDOM NUMBER
CLA CLL /CLEAR AC & AL; RN RETURNED IN AC
TAD LRNDMQ /LOAD THE LAST RANDOM MQ VALUE
MQL /STORE THAT IN THE MQ AS NEXT SEED        
TAD LSTRND        /GET THE LAST RANDOM VALUE
MUY 5545 /MULTIPLY BY 2917 BASE 10
TAD RNDADD /SUM IN RANDOM NUMBER ADDEND
DCA LSTRND /SAVE RANDOM NUMBER FOR NEXT TIME
CLA CLL
MQA /STORE WHAT IS IN MQ
DCA LRNDMQ /LATER AS OUR NEXT SEED VALUE
TAD LSTRND /CALLER EXPECTS RND VAL IN AC
JMP I GETRND /RETURN TO CALLER

ROT, . /MOVE THE DOT/DASH TO LEFT OR RIGHT
CLA CLL /CLEAR AC AND LINK
TAD DSPLNK /WAS THE LINK SET IN PREVIOUS ROTATE?
SZA / NO: SKIP NEXT INSTRUCTION
CML / YES: SET THE LINK BEFORE WE DO NEXT ROTATE
CLA /CLEAR THE AC
TAD DIR /LOAD THE DIRECTION WE ARE SUPPOSED TO ROTATE
SNA / !=0 SO GOING RIGHT
JMP ROTL / ==0 SO GOING LEFT
ROTR, CLA 
TAD DSPBTS
RAR /SHIFT RIGHT ONE BIT
JMP ROTE /GO SAVE THE RESULTS
ROTL, CLA 
TAD DSPBTS
RAL /SHIFT LEFT ONE BIT
ROTE, DCA DSPBTS /SAVE THE RESULTS
SZL         /IS THE LINK SET?
JMP ROTE1 / YES: GO TO STORING LINK IS NOW SET
CLA / NO: STORE THAT THE LINK 
DCA DSPLNK /     IS NOW CLEAR
JMP I ROT /RETURN TO CALLER
ROTE1, CLA /STORE THAT THE LINK
IAC         / HAD BEEN SET WITH THAT 
DCA DSPLNK / LAST ROTATE
TAD BOUNCE /SINCE WE HIT END, DO WE CHANGE DIRECTIONS?
SNA         / YES: WE'LL NEED TO CHANGE DIRECTIONS
JMP I ROT / NO: RETURN TO CALLER
CLA
TAD DIR /WHAT DIRECTION WERE WE GOING?
SZA         / YES: WERE GOING LEFT
JMP ROTE2 / NO: WERE GOING RIGHT
CLA /NOW START GOING RIGHT
IAC
JMP ROTE3
ROTE2,  CLA /NOW START GOING LEFT
ROTE3, DCA DIR /STORE OUR NEW DIRECTION,IGNORING DIR SWITCH
JMP I ROT /RETURN TO CALLER

DSPBTS, 0 /BIT PATTERN WE ARE DISPLAYING IN MQ
DSPLNK, 0 /DISPLAY VALUE OF LINK
DOT, 1 /WHAT A DOT SHOULD LOOK LIKE
DASH, 7 /WHAT A DASH SHOULD LOOK LIKE
CURSW,  0 /CURRENT SWITCH SETTINGS
LASTSW, -1 /LAST SWITCH SETTINGS
DIR, 0 /DIRECTION: 0=LEFT; !0=RIGHT (CALL ME LAZY)
BOUNCE, 0 /KITT MODE: 0=OFF; !0=ON
RANDOM, 0 /RANDOM BITS: 0=OFF; !0=ON
LSTRND, 0 /LAST RANDOM NUMBER 
LRNDMQ, 541 /LAST RANDOM MQ
RNDADD, 541               /353 BASE 10
DELAYV, -400 /OUTLOOP DELAY 

PAGE
DELAY, . /DELAY ROUTINE SO WE CAN SEE WHAT IS GOING ON
CLA CLL /CLEAR AC AND LINK
TAD DELAYV /LOAD OUTER LOOP COUNT
DCA IR2 / AND STOR IT
DELAYO, ISZ IR2 /OUTER DELAY LOOP. DONE?
JMP DELAYI         / NO: DO THE INNER LOOP
JMP I DELAY / YES: RETURN TO CALLER
DELAYI, ISZ IR1 /INNER DELAY LOOP. DONE?
JMP DELAYI / NO: DO NEXT INNER LOOP
JMP DELAYO / YES: DO NEXT OUTER LOOP
$

Enjoy!  My next project will be to add some text instructions to display on the terminal.  Looks like the PiDP-8 simulator's rendition of PAL and MAC supports TEXT, but perhaps not TEXTZ?  So much more to dig into and learn...

Best,
-Mark

Steve Tockey

unread,
Jun 23, 2021, 12:26:31 AM6/23/21
to PiDP-8
Mark,
Just for fun (and as yet another example of PAL-8 blinkenlight programming), a rite of passage when I first programmed PDP-8s in 1975-1976 was to write a kind of one dimensional Pong. Two players, one on the left side (Switch Register bit 0) and one on the right side (Switch Register bit 11). Flipping your switch on was like swinging your paddle. You couldn't swing too early, nor too late. Given the size of the PiDP-8/i front panel and switches, I updated the code to use the keyboard instead. The left player can use a set of keys on the left side of the keyboard, the player on the right similarly. See the attached source code for which keys work for which player. It keeps score in binary in the MQ.

Code-wise, the trickiest thing might be that it uses interrupts rather than polled I/O. Otherwise, I would hope it's straightforward.

There are a lot of other PDP-8 blinkenlight programs, if you're interested.


Cheers,

-- steve


kab.pa.txt
Reply all
Reply to author
Forward
0 new messages