suomeksi Homework

Computer Organization I, Fall 2001, HW 3

To be presented in week 46 (13-16.11.2001)

     

  1. Complete the program lh_kutsu.k91 (in the Koksi example directory) by implementing subroutine SUBR(X, A, B), which modifies parameter X into the difference of value parameters A and B. Parameter X is given as call-by-reference parameter.

    Check your program by compiling and running it in Koksi.

     

  2. [2 hwp] Write a ttk-91 symbolic assembly language program that
    1. Allocates space for a 20 element table (1-dimensional array) Tbl[20]
    2. Iniotializes Tbl at execution time so that Tbl[i] = i*i
    3. Computes the sum of elements in Tbl so that index register R1 has always the index of current element. Current element is thus loaded to R3 with machine instruction "LOAD  R3, Tbl(R1)".
    4. Prints the sum cumputed above
    5. Initializes pointer variable Xptr to point to the first element in Tbl
    6. Prints the value of pointer variable Xptr
    7. Computes the sum of elements in Tbl so that register R2 has always the address of current element (i.e., pointer to it). Current element is thus loaded to R3 with machine instruction "LOAD  R3, @R2".
    8. Prints the sum cumputed above

    Check your program by compiling and running it in Koksi.

     

  3. The address field of ttk-91 machine instruction has only 16 bits. This limits the size of constants used in instructions.
    1. What is the largest positive number that can be given as constant in an instruction?
    2. What is the smallest negative number that can be given as constant in an instruction?
    3. What should you do, if you need a bigger constant? E.g., 500000?
    4. And what should you do, if you need a large constant with indexed address mode? For example, you need to read the value from (R1)+666666?

     

  4. Memory references
    1. How many memory references can ttk-91 machine instructions cause? Which one is the "worst" instruction in this sense? Which one is the "best"?
    2. Which matters most here, the opcode, the addressing mode, or both? Why?

  5. Data representation.
    1. What is decimal number 43.234 in binary?
    2. What is binary number 101010.1010 in decimal?
    3. What are the 16-bit Big-Endian binary representations of decimal numbers +23 and -75 in following formats:
      1. sign and magnitude
      2. two's complement
      3. one's complement
      4. biased by 32767
    4. What is the IEEE floating point standard representation of decimal number 33.125?

       

    5. Assume that programming language MyLan has both boolean and floating point data types. For example, one can use variables of type boolean or float in it.

      Ttk-91 does not have such data types. Could one make a MyLan compiler that would allow us to execute MyLan programs in ttk-91? If the answer is yes, why? If the answer is no, why not?

     

Use standard method for building and taking apart activation records, when implementing subroutines and functions. Take care, that all work registers (R0-R5) have the same value at the time of subroutine or function return as they were when the subroutine or function call was made.

Be prepared to show all Koksi related and other programming homeworks using a PC at the practice session. Please bring both a listing and on a diskette all the programs you made for this practice session.


Teemu Kerola