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.
Alternatively to bringing the diskette, you can store your programs to the fs file server.
- Question 1: Floating point and Big vs. Little Endian
Return the answer to this question day before your meeting!
This answer will grant you one point equal to the points of the course exam.
- What is the decimal number represented by IEEE floating point
standard, hexadecimal 0xC1600000? (Please notice, that the prefix 0x is
not part of the value, but simply indication that it is a hexadecimal value.)
- Please give an example (with actual floating point number values) of a
situation, where X+Y=X, even when Y>0.
Please give at least the values of X and Y in decimal numbers and their
binary representations.
- Let us assume that a memory location 0x124 (byte address) contains
a four-byte word. An integer 0x12345 is stored to the word staring from
memory location 0x124. Give the actual content of the first byte (0x124)
of the word, when the integer is stored using
- Little Endian fashion.
- Big Endian fashion.
Write your answer (formulas, different phases of calculations) to a plain text file,
which you must then send to the
course assistant using the web-page
http://db.cs.helsinki.fi/~tuohinie/tito/ .
The web-page asks first you to choose your small group. Then you have to
write your name and upload the text file containing your report.
You have to return the answer at the latest 24 hours before the
small group session's starting time.
A late delivery is not possible.
- Question 2: Jump table ( This values as two questions )
Long case and switch statements can slow down the program execution
remarkably, if, for example, a selection between 60 different choises is
done one-by-one within a loop that is used very often or executed
multiple times. On average each selection within the loop takes 30
comparations and each comparation requires at the minimum 2 machine instructions.
If the choise values in case statements are integers, start from zero and cover (almost)
consistent number range, then a jump table can be used instead of numerous if-then-else
statements usually used in the implementation of switch-statement.
With the jump table we can always reach the right choise with few
machine instructions. A Jump table contains several jump instructions
(one for each case value). The right jump instruction is chosen using
indexing, more specifically indexed addressing.
For eaxmple, when the register R3 has the selection (case) value and jump table
address is JTBL, we can find the right case and the attached jump instruction
using instruction "JUMP JTBL(R3)".
- Give a (Koksi executable) example using ttk-91 of the usage
of jump table, when there are 10 different cases.
- How do you implement the selection, if the jump table contains
the addesses instead of the full jump instructions? Give similar example
as in a).
- When would it be better to store the instruction instead of the
address to the table? Why?
- When would it be better to store the address instead of the
instruction to the table? Why?
- Assume that each case selection requires 10 machine
instructions and that there are 60 differents cases. How much faster (in
%) would
the usage of the jump table be compared to the sequential implementation
using if-the-else structure. Is there any difference between the two jump
table alternatives?
- Question 3: Java program execution
Java programs (byte code) can be executed in (at least) four different
ways: interpretation, ordinary compilation, Just-In-Time compilation and
directly on a Java processor.
- Give examples on situation where interpretation would be better
than any other way. Give reasoning for your examples.
- Give similar examples and reasoning to situations where the other
ways to execute Java programs would be the best choise.
- What would be the best choise to execute (Java) programming
laboratory exercise? Why?
- Which prosesses are needed in the system at the time when your
Java program MyProg is executed with 1) interpretation, 2) ordinary
compilation, 3) Just-In-Time compilation, or 4) Java processor?
- Question 4: Function
In the exercise 2, the first question was about a program that
calculated Fibonacci numbers. Let's modify this ttk-91 program to have
slightly more features.
First, the calculation of the Fibonacci number will be done by a
function. Second, the program should provide multiple Fibonacci numbers,
for the user based on the values the user inputs to the system via keyboard.
- Write the function Fibonacci that can be used as
x=Fibonacci(y). Each Fibonacci number is the sum of the two preceeding
numbers.
- Write the main program that reads the input from the
keyboard one at a time. For each value, it calculates the corresponding
Fibonacci number and outputs it. The program continues to read and
process new values as long as the new one is greater than zero. Zero or
negative value will terminate the program.
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.
- Question 5: Student Feedback
Fill in the Student Feedback
form (only in Finnish, sorry). Give extra
care in your answers to questions 14 and 19.
In question 14 ("Miten kurssia voisi kehittää? or "How the course could
be made better") answer also to the following:
- How many hours have you used for this class altogether up to now?
For lectures? Practices sessions? Self study?
- What proportion of the lectures did you attend to? (100%, 90%,
...)
- If you attended most lectures, did you learn the basic material
there, or did you have to study hard from the books.
- Did you use the Finnish material or only the English language books? How much?
Tiina.Niklander@cs.helsinki.fi