- Question 1: Subroutine with reference parameters
Complete the program
lh_kutsu.k91
by
implementing subroutine SUBR(X, A, B), which modifies parameter X into
the difference of AČ and BČ. Parameter X is given as
call-by-reference parameter.
Check your program by compiling and running it in Titokone.
- Question 2[2hwp]: Table
The ttk-91 symbolic assembly language. There is an integer array T[8]
on the main program level. There are 8 elements in the array (elements
0,...,7).
- Allocate space for a 8 element table (1-dimensional array)
Tbl[8]. The indexing starts at zero.
- Implement a function Count(S,N), which returns the count of positive
elements of the table S consisting of N elements. Parameter S is given as
call-by-reference parameter, and parameter N as call-by-value.
- Give ttk-91 symbolic assembly language instructions, that will use
function Count to print count of the positive integers in the table T
consisting of 8 elemets.
- Change the function Count, so that it will return the
count of the even integers of the table S.
- Draw a picture of the activation record stack after the call of the
Count and before the return to called program.
Initialize the Table T with some testvalues, and
check your program by compiling and running it in Titokone.
- Question 3: Constants in machine language instructions
The address field of ttk-91 machine instruction has only 16 bits. This
limits the size of constants used in instructions.
- What is the largest positive number that can be given as constant
in an instruction?
- What is the smallest negative number that can be given as constant
in an instruction?
- What should you do, if you need a bigger constant? E.g., 500000?
- 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?
- Question 4: Data representation.
- What is decimal number 88.375 in binary?
- What is binary number 101010.1010 in decimal?
- What are the 16-bit Big-Endian binary representations of decimal
numbers +43 and -17 in following formats:
- sign and magnitude
- two's complement
- one's complement
- biased by 32767
- Question 5: Data representation.
- What is the IEEE floating point standard representation of decimal
number 71.625?
-
What is 125 in hexadesimal?
-
What is 125 in octal?
- 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.
Paivi.Kuuppelomaki@cs.helsinki.fi