Helsingin yliopisto - Tietojenkäsittelytieteen laitos
suomeksi Homework (screen layout) (print layout) (handheld layout)

Computer Organization I, Spring 2003, HW 1

To be presented in week 12, 17-21.3.2003.

The last problem is especially important, because we will use the Koksi simulator during the rest of the course as a standard tool.

  1. 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).

    1. Which machine instructions would you use to print value of X?
    2. Which machine instructions would you use to print address of X?
    3. Which machine instructions would you use to store the value 65 as the value of X?
    4. Which machine instructions would you use to store the value 211 as the address of X?
    5. Which machine instructions would you use to store the value of X to memory as the value of variable Y?
  2. 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:
    1. SUB
    2. MOD
    3. OR
    4. XOR
    5. COMP
    6. JUMP
    7. JNGRE
    8. DC
    Give an example of each case.
    How do pseaudo-instructions differ from ordinary machine instructions?

     

  3. 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.
    1. LOAD R4, 200
    2. LOAD R3, One(R1)
    3. LOAD R3, =One(R1)
    4. STORE R0, One(R1)
    5. STORE R2, @9(R3)
    6. LOAD R0, @R1
    7. LOAD R1, @(R1)
    8. STORE R1, @(R1)
    9. STORE R0, R1
    10. STORE R2, =One

     

  4. The KOKSI simulator for TTK-91 architecture
    1. How does a simulator differ from a real machine (computer)?
    2. How do the programs executed in a simulator differ from those executed in a real machine?
    3. What advantage is there to execute programs in a simulator instead of a real machine?
    4. What disadvantage is there to execute programs in a simulator instead of a real machine?
  5. [2 htp] Learn to use the Koksi simulator. See the instructions in schedule web page( ../aikataulu.html)
    1. 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.)
    2. 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".
    3. 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.
    4. 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.
    5. Use the "Asetukset" setup to put commenting option ("kommentointi") on ("päällä").
    6. Load ("Lataa") and compile ("käännä ohjelma") program "sum.k91".
    7. What are the values for symbols DONE, KBD and LUKU?
    8. Execute the program ("Suorita ohjelma") with inputs ("Anna luku") 5, 4, 3 and 0. What value was output ("tulostui")?
    9. In which location is the value for variable SUMMA stored in?
    10. Use the "Asetukset" setup to put commenting option ("kommentointi") off ("pois") and set execution speed ("suoritusnopeus") to slow ("hidas").
    11. 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.
    12. Try out one of the approaches and show that your solution is correct.
    13. 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