581305-6 Computer Organization I, 2 ov, course exam 12.05.2005    

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. [4 p]Give Big Endian 16-bit representations for decimal numbers +23 and -40 in a machine that uses
      1. signed
      2. two's complement
      3. one's complement
      4. biased by 32767 (Note that 32767=215-1)
      integer representations.
    2. [1 p] What is the decimal number 90 in hexadecimal?
    3. [2 p] What is the decimal number 19.75 in binary representation?
    4. [2 p] Explain how floating point numbers are represented using the 32-bit IEEE floating point standard representation.
    5. [3 p] What is the 32-bit IEEE floating point standard representation of decimal number -19.375?

  2. [12 p] Process.
    1. [4 p] What is a process? What information does Process Control Block contain?
    2. [4 p] Draw a state diagram of the execution time states of a process. Tell the names of the states and draw state transitions between these states.
    3. [4 p] How and when does the process state change? Handle each possible state change separately using an example.

  3. [12 p] Machine instruction execution.
    1. [4 p] Define the concept "instruction execution cycle". What phases belong to it? Draw a picture of this cycle.
    2. [4 p] What kind is the instruction structure of the TTK-91 machine? What information is stored in each field? Give the representation of the machine instruction "ADD R4, T(R2)" in the memory according to the TTK-91 instruction structure using integer values, when in the symbol table the symbol T has a value 25.
    3. [4 p] What happens at the processor in different instruction execution cycle phases when instruction "ADD R4, T(R2)" is executed?

  4. [12 p + 3 extra points]  Ttk-91 assembly language programming. We have an integer array T[20] defined at the main program level. I.e., the array has 20 elements (elements 0,...,19). We assume that seconds has been stored into elements.
    1. [1 p] Give a definition for a table T.
    2. [4 p] Implement a function Sum(S, N), which returns the sum of the elements, if they are all positive, otherwise the function returns -1. The parameter S is a call-by-reference parameter, and the parameter N a call-by-value parameter.
    3. [4 p] Implement a subroutine Change (TSec, H, Min, Sec), which changes seconds given in the parameter TSec into hours, minutes and seconds and returns the hours in the output parameter H, the minutes in the output parameter Min, and the seconds in the output parameter Sec. For example if the value of the parameter TSec would be 7401, the function should return in the parameter H the value 2, in the parameter Min the value 3, and in the parameter Sec the value 21, because 2 * 3600 + 3 * 60 + 21 = 7401. The parameter N is a call-by-value parameter and the parameters H, Min, and Sec are call-by-reference parameters.
    4. [4 p] Give ttk-91 symbolic assembly language instructions that will use the function Sum and the subroutine Change to print the sum of the seconds in the table T (which is defined at the main program level), and seconds converted into hours, minutes, and seconds. The printing is done only if the elements of the table T are all positive.
    5. [2 p] Draw a picture of the activation record stack
      1. after the call of the Sum (after the execution of the CALL instruction)
      2. when the value of the stack pointer SP is greatest during execution of the function Change.
    Follow the subroutine (function) implementation and call mechanism recommended.


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, JEQU, JGRE, JNLES, JNEQU, JNGRE, CALL, EXIT, PUSH, POP, PUSHR, POPR, SVC