Exercises
Notice: All students must have an account for the Computer Science Department's Linux and Windows systems. All students must have registered for this course through the ILMO system at the department. Students must have a CSMoodle account to be able to work in a study circle.
Computer Organization I, HT 1
These problems are done individually in advance, or they will be done in the first group meeting.
- Most important diiferences between machine language and high level programming languages
- As related to system hardware?
- As related to application programming?
- As related to program execution time?
- [2 htp] High level language vs. assemble language. Assume that we have program
Simple that is written with some high level language (C, Java, Pascal), and
that it has been translated into TTK-91 machine language.
Where in the TTK-91 system can the value for variable X be located during program Simple execution? Give at least two cases. Explain.
Give the answers for the following questions for both (all) cases described above (when possible).
- Which machine instructions would you use to print value of X?
- Which machine instructions would you use to print address of X?
- Which machine instructions would you use to store the value 65 as the value of X?
- Which machine instructions would you use to store the value 211 as the address of X?
- Which machine instructions would you use to store the value of X to memory as the value of variable Y?
- [1 htp] High level language vs. symbolic assemble language instructions. What kind
of structure or part in a high level language program would need the
following TTK-91 (pseudo) machine instructions to implement it:
- SUB
- MOD
- OR
- XOR
- COMP
- JUMP
- JNGRE
- DC
Give an example of each case.
How do pseudo-instructions differ from ordinary machine instructions?
- [2 htp] Learn to use the Titokone simulator. See instructions in the Titokone page.
- Read the installation instructions and install Titokone in your Windows or Linux system. For example, in Windows systems, copy titokone.zip into a proper subdirectory (called, e.g., titokone) and unzip it there. If you install Titokone in the file server (e.g., fs-1), it will be usable from any departmental machine later on.
If you copy the jar-file, you can start titokone just by clicking it (or possibly with right click and selecting java platform).
- Copy program sum.k91 from the ttk-91 example programs http://www.cs.helsinki.fi/teemu.kerola/tito/esimerkit and store it into some convenient subdirectory (e.g., titokone/ttk91). If the browser adds on an extra file name suffix (.txt), remove it.
- Start Titokone. For example, in Windows systems double-click file titokone.bat in your Titokone subdirectory (e.g., titokone).
- Use Options/Set language (Asetukset/Aseta kieli) to select English user interface.
- Set both compilation options (Options/Set Compiling Options)
on
- Empty the simulated ttk-91 machine memory with File/Erase memory.
- Choose symbolic assembly language program sum.k91 in use with File/Open
command ()
- Compile sum.k91 with File/Compile
command () into machine language program sum.b91. Compilation occurs one line at a time by clicking the button. Look at the comment printed after each line at the top line of the comment window. Finally, you can finish compiling the rest of the program with button.
- What are the values for symbols Done, KBD and Luku? In which memory location is the value for variable Summa stored at execution time? What is the initial value for variable Summa?
- Select from options (Options/Set running options) "Execute code line by line" ()
and "Show extra comments while executing" ().
- Execute the program with File/Run command ().
Give input 5, 4, 3 and 0 one at a time in the KBD-window. Execute the program one instruction at a time with the button and observe, how each machine instruction changes the "state" of the machine by changing register or memory contents. When/if you get bored to executing line by line, you can finish the execution with button.
The program execution will anyway stop always when the IN instruction needs to read a value from the keyboard KBD. What value was printed in the CRT window?
- Reset all other execution options but leave "Show animation while executing " ()
on.
- execute the program with input 444, 333 and 0. Before giving the first number in the KBD window, select animation speed "Slow" on the top of the Animator display. Then continue executing instructions line by line with the button. Notice, how for each instruction, the instruction is first fetched from memory into intruction register IR, from the memory location for that that instruction. What is the numeric value for instruction "LOAD
R1, Summa" in register IR?
What is the memory address for device "KBD " in MAR-register?
- Modify the program so, that instead of the sum of given values it computes the product of them. You ma edit the program directly in Titokone, or use any text editor outside Titokone. Notice, that in Titokone the original file is always written over!
- Congratulations! Now you can install Titokone into your own environment and execute ready-made ttk-91 programs on it. You can also make small changes into programs. In future, you will of course write your own programs.
Teemu Kerola