581305-6 Computer Organization I, 2 cu, course exam 13.12.2004    

Write on each answer sheet: your name and signature, id number, course name, and page nr/total nr of pages
  1. [12 p] Data representation
    1. [6 p] Assume that we have the most common Big Endian byte order. If the byte address 184 has the value OxFF and the byte address 185 has the value OxD7, what is the decimal number these bytes together represent in a machine that uses
      1. two's complement
      2. one's complement
      3. biased by 32767 (Note that 32767=215-1)
      integer representations. (Prefix "0x" means that the number after that is in hexadecimal notation.)
    2. [3 p] What is the decimal number 11.325 in binary representation?
    3. [3 p] What is the 32-bit IEEE floating point standard representation of decimal number 11.325?

  2. [12 p] Compiling, loading, and linking. Assume that a program is written in an ordinary programming language (for example C or Pascal).
    1. [6 p] What happens while compiling the program?
    2. [3 p] What happens while linking the program?
    3. [3 p] What happens while loading the program?

  3. [12 p] Program execution
    1. How does a processor execute machine language programs?
    2. What types of events cause disruptions to the normal order of instruction execution?
    3. How are these disruptions handled?
    4. How does the handling of these exceptional situations relate to subroutine call and subroutine returns? Differences/similarities?

  4. [12 p] Ttk-91 assembly language programming
    We have an integer array T[24] defined at the main program level. I.e., the array has 24 elements (elements 0,...,23).
    1. [2 p] Give a definition for a table T.
    2. [4 p] Implement a function Count(S, N, Pos, Neg), which returns the count of positive elements of the table S consisting of N elements. In addition the function should return in the out parameter Pos the sum of positive elemets and in the out parameter Neg the absolute value of the sum of the negative elements. Follow the subroutine (function) implementation and call mechanism recommended. The parameters S, Pos, and Neg are given as call-by-reference parameters, and the parameter N as a call-by-value parameter.
    3. [3 p] Give ttk-91 symbolic assembly language instructions that will use function Count to print the count and the sum of the positive elements in the table T (which is defined at the main program level). Follow the subroutine (function) implementation and call mechanism recommended. The parameters S, Pos, and Neg are given as call-by-reference parameters, and the parameter N as a call-by-value parameter.
    4. [3p] Draw a picture of the activation record stack
      1. after the call of the Count in b) (after the execution of the CALL instruction)
      2. when the value of the stack pointer SP is greatest during execution of the function Count
      3. before the execution of the EXIT instruction of the function Count
      4. after the execution of the EXIT instruction of the function Count.


The TTK-91 assembly language instructions are: NOP, STORE, LOAD, IN, OUT, ADD, SUB, MUL, DIV, MOD, AND, IR, XOR, SHL, SHR, COMP, JUMP, JNEG, JZER, JPOS, JNNEG, JNZER, JNPOS, JLES, LEQU, JGRE, LNLES, LNEQU, NGRE, CALL, EXIT, PUSH, POP, PUSHR, POPR, SVC