CS 207
Midterm 1
Ondich
Due 11:10 AM Monday, October 25, 1999

For this exam, you may use your textbook, your notes and assignments, your brain, and divine guidance if available. You may use an introductory CS text if you don't remember what selection sort is. You may not use other books, other people, or Internet resources. If you get stuck, talk to Jeff Ondich, but please don't talk to anyone else about the exam.

Submit your answers on paper. For the PDP8 code in problem 1, submit your .pal file using HSP

  1. (15 points) The table below shows the execution times for all of the PDP8/E instructions (not including op-code 6).
    
    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)
    --------------------------------------------------------
    


  2. (12 points) The diagram below (Digital and Microprocessor Electronics for Scientific Application, Dennis Barnaal, Waveland Press, 1989, page D100) shows a circuit known as a JK flip-flop. The weird black triangle in the middle is a diode--you don't need to worry about it.



  3. (15 points) Find out and report as much as you can about the function calling mechanism and the structure of stack frames as they are created by the g++ compiler on our Silicon Graphics computers.

    To do this, log in to green.mathcs.carleton.edu, blue.mathcs.carleton.edu, or cyan.mathcs.carleton.edu, either via telnet or by sitting at the machine in CMC307. Then, write small C++ programs and compile them with the -S flag (for example, "g++ -S program.cpp" will create the MIPS assembly language file called "program.s"). By examining the MIPS versions of your programs, you should be able to discover how g++ organizes its function calls and stack frames for MIPS.

    Some questions you should try to answer are:



  4. (2 points) What book should I read next?

  5. (10 points) Consider the fictional machine Mbase from problem 18 on pages 93-94 of P&H. The compiler team from problem 21 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.