Exam 3

22C:18, Fall 1996, 25 points

Douglas W. Jones
Name ______________________________________   Section ___________

E-mail address to which
you want your grade sent ________________________________________
This exam is open-book and open-notes, but closed neighbor! You have two hours. Answer the questions in the space provided. If you need scratch paper, feel free to use the backs of the exam pages, but please transcribe your answers into the blanks provided.
  1. Number Representations: Give representations for 4310 in each of the following forms (6 points):

    1. as an ASCII string on a Hawk machine,
      packed into a 16 bit word _____________________________

    2. as a BCD number shown in binary
      most significant digit first _____________________________

    3. as a binary number __________________________________

    4. as an 8-bit two's complement binary
      number shown in hexadecimal _________________________

    5. as an 8-bit unsigned fixed point
      binary number with 2 places after
      the point, shown in hexadecimal ________________________

    6. as a 16-bit floating point number with
      a sign bit for the mantissa, a 7 bit
      biased exponent, and an 8-bit fixed
      point binary fraction to complete the
      mantissa, shown in binary _____________________________

  2. What is the difference between an interrupt, a trap and a procedure call? All three involve a transfer of control to some routine and a transfer of control back to the original program! Your answer must be short and general, not with reference to any specific machine and discussing only the differences between these control structures! (3 points)
          ___________________________________________________________________
    
          ___________________________________________________________________
    
          ___________________________________________________________________
    
          ___________________________________________________________________
    
          ___________________________________________________________________
    
    

  3. Recursion and calling sequences: Using the calling sequence of your choice, write Hawk assembly code equivalent to the following code, making sensible assumptions about the definition of symbolic names for node fields (pointed to by t). (4 points).
    	reverse(t)		    procedure reverse(t:noderef)
    	struct node * t		    var temp:noderef;
    	{			    begin
    	    struct node * temp          if t <> nil then begin
    	    if (t != NULL) {		    reverse( t^.left );
    		reverse( t->left );         reverse( t^.right );
    		reverse( t->right );        temp := t^.left;
    		temp = t->left;             t^.left := t^.right;
    		t->left = t->right;         t^.right := temp;
    		t->right = temp;        end;
    	    }                       end;
    	}
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
    
  4. Arrays and multiplication: Consider the following equivalent declarations (in C and Pascal) for the array A:
    	int A[5][9];	A: array [0..4,0..8] of integer;
    
    Write good Hawk code to fetch A[i,j] into R3, assuming that integers are 32 bits and, R4 and R5 initially hold i and j, and your code is free to wipe out both R4 and R5 (3 points).
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
  5. The IBM Model 1301 Disk Storage System, sold with the IBM 7040 computer in the early 1960's, had 25 disk platters on a common spindle, with a head positioning assembly that had 24 access arms arranged like teeth on a comb, one arm in the gap between two platters, and two heads per arm. The disks spun at 1790 rpm or about 30 revolutions per second. Each disk surface had 250 tracks on it, and 8 recording surfaces were reserved for special purposes (not used for data storage). Each track can hold roughly 2K bytes of data. (4 points)

    1. How many cylinders were there? _________________

    2. How many surfaces were there? __________________

    3. How many tracks were there? ___________________

    4. What is the total storage capacity? _________________

    5. How long would it take to
      read all the data on the system? ___________________

    6. How many bits would you expect there
      to be in the cylinder select register? _________________

    7. How many bits would you expect there
    8. to be in the surface select register? ___________________

  6. Macros and other architectures: Consider a 2's complement binary computer with 64K 32 bit words of main memory address space, where there is only one instruction, with the following format:
     _______________________________ _______________________________
    |_______________________________|_______________________________|
    |31            dst            16|15            src             0|
    
    This instruction is a conditional move instruction, moving data from M[src] to M[dst] when the condition bit is zero; the instruction always clears the condition bit just before storing the operand. Instructions are executed in sequence, just as on a typical modern machine. This machine would be useless if it were not for the fact that all registers inside the machine are memory mapped!
    FFFF16 -- The program counter
    FFFE16 -- The condition bit is bit 0 at this address
    FFFD16 -- The accumulator (AC)
    FFFC16 -- Data stored here is subtracted from AC
    FFFB16 -- Data stored here is added to AC
    FFFA16 -- The sign bit of AC is bit 0 at this address
    Define a SMAL macros for:
    MOVE A,B -- M[A] = M[B] (Note that BR and BPOS do
    BR A -- PC = M[A] not set PC = A, they set
    ADD A -- AC = AC + M[A] PC = M[A]! This makes
    BPOS A -- if AC > 0, PC = M[A] the exam question easier!)
    You should use MOVE to help define the others! (4 points)
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________
    
         _____________________________________________________