CS 207
Midterm 1
Ondich
Due on paper at 8:30 AM Friday, October 18, 2002

For this exam, you may use your textbook, the Internet, your notes and assignments, your brain, and divine guidance if available. You may not use other people. If you get stuck, talk to Jeff Ondich, but please don't talk to anyone else about the exam.

  1. (12 points) Consider the following PDP8/E program.

    *0200
            CLA OSR
            DCA A
    LOOP,   DCA N
            TAD A
            SNA
            HLT
            CLL RAL
            DCA A
            RAL
            TAD N
            JMP LOOP
    
    A,		0
    N,		0
    

    The following table 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)
    --------------------------------------------------------
    

    And now, the questions. Assume throughout these questions that the switch register is set to octal 1357.

  2. (9 points) Consider the following boolean function of three variables:

    
     A | B | C || f(A,B,C)
    =======================
     0 | 0 | 0 ||    0
     0 | 0 | 1 ||    0
     0 | 1 | 0 ||    0
     0 | 1 | 1 ||    1
     1 | 0 | 0 ||    1
     1 | 0 | 1 ||    0
     1 | 1 | 0 ||    1
     1 | 1 | 1 ||    0
    

  3. (10 points) In C/C++ using g++ on our version of Linux, variables of type int are stored in 32-bit two's complement format. For this problem, I want you to write a C/C++ program that provides evidence that int variables are indeed stored in this format. Your job is to write a short C/C++ program that illustrates the following properties of the int type. Hand in a hard copy of your source code and a printout of a program run. You may find the unary operator ~ useful.

    Your illustrations should be very brief. For example, to show that there are two integers for which N == -N, all you have to do is this:

    int		a = something;
    int		b = somethingelse;
    
    cout << "a = " << a << endl;  
    cout << "-a = " << -1*a << endl;  
    cout << "b = " << b << endl;  
    cout << "-b = " << -1*b << endl;  
    

    Your only job for this part, then, is to figure out which values of something and somethingelse are the ones that will give a == -a and b == -b.

  4. (2 points) Who are Ted Hoff and Maurice Wilkes, and what importance did they have in the history of computer architecture?

  5. (2 points) Direct me, if you wish, to a web site that you find amusing.

  6. (9 points) Consider the program stackframes.cpp. Compile it and run it. Then compile it with the command "g++ -S stackframes.cpp". This will create the (Intel) assembly language program stackframes.s, which you can examine to help you answer the following questions.