From: Shawn_E_Switenky@engr.usask.ca (Shawn E Switenky)
Newsgroups: alt.folklore.computers
Subject: PDP-11 Program - Please help me!
Date: 17 Nov 1992 21:18:33 -0600
Organization: UTexas Mail-to-News Gateway
NNTP-Posting-Host: cs.utexas.edu

Hi All,

I've got a strange problem.  For an upcoming demonstration by our local DEC 
people of their new Alpha machines, they borrowed a PDP-11/20 for the display,   
so the could say something like, 'Remember how easy it was going from the
PDP-11 to the VAX?  Well it will be even easier to go from VAX to ALPHA!'

I managed to get a working PDP-11/20, but it only has 4K of core and no  
I/O devices except for the console.  I sat down and wrote a short program 
which would have one light move back and forth on the display.  A scanning 
eyeball, like a Cylon Centurion or the KITT on the Knight Rider.

I don't have any kind of software for me to generate programs with.  So
I had to assemble my code to machine code myself.  Now, I have never done
this before, but I figured how hard could it be?  Well once I figured out 
the numbers and entered it into the PDP's memory from the front console
switches, I loaded in the start address and pushed start.  As with all 
first program runs, it performed nothing like I expected it to.  I wrote it 
to run in an endless loop, but after about a second, the processor halts.

I love playing around with older computers, but aside from plugging in an
occasional bootstrap, I've never had to resort to loading in a program this
way.  Debugging this program has got me stumped.  I'm not familiar with 
using the console to debug a program, only entering in programs.

I've got a feeling my problem lies in one or more of the following areas:
        1) I've calculated my branch offsets incorrectly.
        2) I've got an addressing mode coded in binary incorrectly.
        3) I can't just plug something into the display register this way.
        4) I've got JMP figured out wrong.
        5) Something like a stack hides out in the same area as my program.
        6) I'm forgetting something obvious.
                                            
So what I need to ask of someone is to help me debug my program.  If anyone can
run some macro assembler and generate a binary image, I would sure appreciate
the help.  If anyone sees any problems with following code or implementation, 
again please let me know.  The Alpha presentation is this Friday, Nov. 20,
so I am also in a hurry.  Thanks in advance!

Here's my code:

        START:  MOV #1, R0              ; R0 holds eyeball value
                MOV #177570, R1         ; R1 holds the address of the console 
                                        ; display register
                MOV #10000, R2          ; R2 holds the delay value
                MOV R2, R3              ; R3 is the counter for the delay
                MOV START, R4           ; R4 holds the address for LEFT label
        
        LEFT:   MOV R0, (R1)            ; Move the contents of R0 to the console 
                                        ; display register
                ROL R0                  ; Rotate Right the value in R0
        LCOUNT: DEC R3                  ; Decrement the counter 
                BNE LCOUNT              ; Loop if the counter value is not zero
                MOV R2, R3              ; Reset counter
                BCC LEFT                ; If the EYEBALL bit is not in Carry, 
                                        ; the branch to LEFT

        RIGHT:  ROR R0                  ; Rotate Left the value in R0
                MOV R0, (R1)            ; Move the contents of R0 to the console
                                        ; display register
        RCOUNT: DEC R3                  ; Decrement the counter  
                BNE RCOUNT              ; Loop if the counter value is not zero
                MOV R2, R3              ; Reset counter
                BCC RIGHT               ; If the EYEBALL bit is not in Carry, 
                                        ; the branch to RIGHT

                JMP LEFT                ; Start all over again

The value of START is 1000 binary.  Here is my binary version of the above 
program:
                                     OCTAL          MSB - BIT POSITION - LSB
                                    _______             ________________
                                                        1111110000000000
                                                        5432109876543210
                                                        ________________
        START:  MOV #1, R0           012700             0001010111000000                  
                                     000001             0000000000000001                                                        
                                                        
                MOV #177570, R1      012701             0001010111000001
                                     177570             1111111101111000
                                        
                MOV #10000, R2       012702             0001010111000010
                                     010000             0001000000000000

                MOV R2, R3           010203             0001000010000011

                MOV START, R4        012704             0001010111000100
                                     000010             0000000000001000
        
        LEFT:   MOV R0, (R1)         010011             0001000000001001
                                        
                ROL R0               006100             0000110001000000

        LCOUNT: DEC R3               005303             0000101011000011

                BNE LCOUNT           001373             0000001011111011

                MOV R2, R3           010203             0001000010000011

                BCC LEFT             103767             1000011111110111
                                                                        
        RIGHT:  ROR R0               006000             0000110000000000

                MOV R0, (R1)         010011             0001000000001001
                                        
        RCOUNT: DEC R3               005303             0000101011000011

                BNE RCOUNT           001373             0000001011111011

                MOV R2, R3           010203             0001000010000011

                BCC RIGHT            103767             1000011111110111
                                        

                JMP LEFT             000104             0000000001000100


+------------------------------------------+--------------------------------+
| Shawn E. Switenky                        |                                |
| Internet: Shawn_E_Switenky@engr.usask.ca | Real Computers Use Kilowatts!  |
| Compu$erve: 72460, 2604                  |                                |
+------------------------------------------+--------------------------------+
