Homework
Computer Organization I, Fall 2001, HW 1
To be presented in week 44, 30.10-1.11.2001
The last problem is especially important, because we will use the Koksi
simulator during the rest of the course as a standard tool.
- 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?
- 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?
- Memory reference modes.
Assume that for each instruction below the starting point is the state given
in of slide 18 ("TTK-91 muistin
osoitusmoodit") of lecture 2. For each instruction, please give the
effective address and either the modified register contents or the address
and the contents of the modified memory location. If some instructions are
not legal, give explanation for it.
- LOAD R4, 200
- LOAD R3, One(R1)
- LOAD R3, =One(R1)
- STORE R0, One(R1)
- STORE R2, @9(R3)
- LOAD R0, @R1
- LOAD R1, @(R1)
- STORE R1, @(R1)
- STORE R0, R1
- STORE R2, =One
- The KOKSI simulator for TTK-91 architecture
- How does a simulator differ from a real machine (computer)?
- How do the programs executed in a simulator differ from those executed
in a real machine?
- What advantage is there to execute programs in a simulator instead of
a real machine?
- What disadvantage is there to execute programs in a simulator instead
of a real machine?
- [2 htp] Learn to use the Koksi simulator. See the instructions in schedule
web page http://www.cs.helsinki.fi/teemu.kerola/tito/s2001/schedule.html
- Copy koksi.zip into your own directory (e.g., "koksi"), and
unzip it into that same directory.
(In some Windows versions your directory must reside on the local disk,
not on the file server.)
- Use e.g. the "Find" facility to locate some textual editor
(e.g., "edit.com") and place the absolute path name to that
(e.g., "c:\dos\edit.com") as the only line in initialization
file "Koksi.cfg".
- From the Koksi example programs http://www.cs.helsinki.fi/teemu.kerola/tito/esimerkit
pick up the program sum.k91 and save it into your "koksi"
directory.
- Start Koksi simulator (koksi.exe), and clear its memory ("nollaa
muisti"). Most of the time it is easier to use the keys (return,
arrows, Esc) than the mouse for control.
- Use the "Asetukset" setup to put commenting option
("kommentointi") on ("päällä").
- Load ("Lataa") and compile ("käännä ohjelma")
program "sum.k91".
- What are the values for symbols DONE, KBD and LUKU?
- Execute the program ("Suorita ohjelma") with inputs
("Anna luku") 5, 4, 3 and 0. What value was output
("tulostui")?
- In which location is the value for variable SUMMA stored in?
- Use the "Asetukset" setup to put commenting option
("kommentointi") off ("pois") and set execution
speed ("suoritusnopeus") to slow ("hidas").
- Execute the program ("Suorita ohjelma") with inputs
("Anna luku") 4, 3 and 0. What value was output
("Tulostettiin")? Why is the value output wrong? Give two
different approaches to fix the problem.
- Try out one of the approaches and show that your solution is correct.
- Modify the program so that instead of the sum of input values you
compute the product of the input values. You can edit the program
directly withing Koksi simulator system using the editor you selected
(in Koksi configuration file Koksi.cfg), or outside Koksi using any text
editor. However, all Koksi programs must be stored into that one
"koksi" directory.
Be prepared to show all Koksi related 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