CS 207
Midterm 1
Ondich
Due 8:30AM, Friday, October 10, 1997
HAND IN ON PAPER


You may use your textbook, Ch. 2 of the PDP8/E manual, your notes, a computer, and your wits on this exam. You may not other books, Internet resources, or other people. If you have questions, see me in my office, call me (x4364 or 663-7123) or send me e-mail. I have tried to write an exam you can finish in six or fewer hours. If it looks like you're going to take significantly longer than this, please let me know.

Explain your answers clearly. Have fun.

  1. (10 points) Fooling around with the PDP8/E.

    There's a PDP8/E instruction I forgot to tell you about. It's an op-code 7 instruction called BSW (for "byte swap"), and it swaps the upper 6 bits of the AC with the lower 6 bits. Its machine code is 7002.



  2. (10 points) The table below lists execution times for all the PDP8/E instructions we have used. Please answer the following questions.

    
    Execution times in micro-seconds for PDP8/E instructions
    --------------------------------------------------------
                             Addressing mode     
                  ------------------------------------------
    Instruction                            Indirect with
       Type       Direct      Indirect     auto-increment
    --------------------------------------------------------
    AND            2.6          3.8             4.0
    TAD            2.6          3.8             4.0
    ISZ            2.6          3.8             4.0
    DCA            2.6          3.8             4.0
    JMS            2.6          3.8             4.0
    JMP            1.2          2.4             2.6
    
    Opcode 7          1.2 (addressing mode irrelevant)
    --------------------------------------------------------
    


  3. (15 points) When we implemented function-calling on the PDP8/E, we assumed each function would have only one parameter, and each stack frame would consist of two words--the parameter on top of the return address. The following are my implementations of CALL and RETURN, including the pre-conditions and post-conditions for each. Note that these routines use straight-forward implementations of PUSH and POP subroutines.

    
    / CALL -- calls a function.
    /
    /  Pre-conditions: The address of the function to be called
    /    is in the page-0 location ADDR, and the parameter of
    /    the function is in the AC.
    /
    /  Post-conditions: The return address to the caller and the
    /    parameter have been pushed (in that order) onto the
    /    system stack.  Control has been transferred to the
    /    function being called.
    
    CALL,       0000
                DCA CALLTMP
                TAD CALL
                JMS PUSH
                TAD CALLTMP
                JMS PUSH
                JMP I ADDR
    CALLTMP,    0000
    
    
    /  RETURN -- returns from a function
    /
    /  Pre-conditions: the return value of the function is in the AC.
    /
    /  Post-conditions: the stack frame has been popped, the return
    /    value is in the AC, and control has been returned to the
    /    original routine that called CALL (via the return address
    /    that was in the stack frame).
    
    RETURN,     DCA RETTMP
                JMS POP
                JMS POP
                DCA ADDR
                TAD RETTMP
                JMP I ADDR
    RETTMP,     0000
    


    How would you modify our function-calling mechanism to allow for a variable number of parameters? How would the stack frame be structured? Show new versions of CALL and RETURN including pre- and post-conditions that implement your extended function-calling mechanism.

  4. (3 points) Direct me to an interesting Web site.

  5. (12 points)

  6. (10 points) Consider the fictional machine Mbase from problem 14 on page 84 of P&H. The compiler team from problem 17 has gone on vacation, and the iterim compiler team has cooked up yet another compiler. The new compiler generates code with 90% as many instructions of each class as the base compiler, and then replaces every class D instruction by two class A instructions. Call the machine with the new compiler Mnew.




Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057
(507) 646-4364, jondich@carleton.edu