CS 208: Computer Organization and Architecture

PDP-8 experiments

For each of the following, put the associated program into a .pal file, assemble it with "pal -r whatever.pal", and load it into the emulator. Then answer the questions. When I ask you to "predict what the program's result will be," everybody at your table should be quiet for a minute while everyone gets a chance to think about the question. Then check your answers against each other and test the program to see if you were right.

  1. Use the "pause" button in the emulator to step through this program one line at a time. When you execute the JMP instruction, exactly what changes in the PDP8's various chunks of memory?

    *0200
    START, TAD A
           JMP START
    A,     0002
    
  2. First, predict what this program's result will be, run it, and make sure you were right.

    Next try changing the contents of A to 1234, and the address of B to *1234. What do you expect to happen? Why?

    Finally, change the TAD A to TAD I A. What do you expect the program to do? Step through the program and see what happens to memory, AC, etc.

    *0005
    A,     0345
    
    *0200
    START, CLA
           TAD A
           HLT
    
    *0345
    B,     0002
    
  3. This is a very silly program, but it illustrates several ideas. Here are some questions. Predict their answers, then step line-by-line through the code to see if you were right.

    • In what order do the CLA, CLL, CMA, and RAL operations get performed on the first line? What are the values of the AC and L after that instruction is done?
    • Step through just the JMS SUBRTN instruction. Exactly what happens to the PC, AC, L, and memory when you execute that single instruction.
    • Exactly what changes in the PC, AC, L, and memory when you execute JMP I SUBRTN?
    • What value gets deposited to A by the DCA A instruction?
    *0200
    START,  CLA CLL CMA RAL
            JMS SUBRTN
            DCA A
            HLT
    
    A,      0000
    
    SUBRTN, 0000
            CLL RAR
            JMP I SUBRTN
    
  4. Let's write the main program for the multiplication assignment.

    • Read the assignment.
    • Start by putting labels on 0174, 0175, 0176, and 0177 appropriate to the meanings of those locations. (Maybe PRODHI and PRODLO for the hi-order and low-order words of the product, and FCTRA and FCTRB for factors A and B? Any way you go, make sure the labels are 6 characters or fewer so pal doesn't get confused.)
    • Talk about what you think the main program needs to do.
    • Take a look at the slow multiplication program and decide whether you want to mimic its main program or do something else. Be prepared to explain why you made your choice.
    • Write a shell of the MULT subroutine. It needs the "MULT, 0000" line at the top, the JMP I MULT at the bottom, and something trivial in the body. For example, the subroutine might add FCTRA to FCTRB and put the results in PRODLO.
    • Run your program. Does it successfully set up the factors, call the subroutine, return to MAIN, and halt? If so, you're in business.
    • Talk to each other about the question of negative factors. Which part of the program (MAIN or MULT) should deal with the fact that zero, one, or two of the factors might be negative? Why?
    • Do you want a partner for working on this assignment? Maybe somebody at your table would like one, too. This kind of programming is tricky enough that it can be really nice to have somebody to bounce ideas off.