in English suomeksi Exercises

Notice 1: All students must have an account for the Computer Science Department's Linux and Windows systems.

Minoring students must first get a UNIX account, or cc account, from the IT Department. A micro-computer account will not do. You can apply for a UNIX account from your own major subject department. After that, you can apply for a CS Dept. account by a freely formulated e-mail to tktl-luvat (AT) cs.helsinki.fi. Please give your cc account name in this e-mail. (See instructions at http://www.cs.helsinki.fi/compfac/ohjeet/Luvat/uusi.html#sivuainelupa). The account is usually activated the day after processing the application.

Notice 2: In order to be recognized in the course bookkeeping, all students must have registered for this course through the ILMO system at the department. If you have not registered yet, please do so now. Thank you.

Notice 3: Students must have a CSMoodle account to be able to work in a study circle. If you do not have one yet, please do it now (by opening CSMoodle, selecting English language and clicking on the "Login" button on top right). Thank you. Do not forget to ask your instructor to enter you in your own study circle in CSMoodle.


Computer Organization I, Autumn 2005, HT 1

To be presented in week 45 (7.-11.11.2005).

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

    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. [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:
    1. SUB
    2. MOD
    3. OR
    4. XOR
    5. COMP
    6. JUMP
    7. JNGRE
    8. DC
    Give an example of each case.
    How do pseudo-instructions differ from ordinary machine instructions?

  3. [2 htp] Memory reference modes.
    Assume that for each instruction below the starting point is the state given in of slide 18 ("TTK-91 muistin osoitusmoodit"). 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. [2 htp] Learn to use the Titokone simulator. Read instruction from the schedule page http://www.cs.helsinki.fi/teemu.kerola/tito/s2005/aikataulu.html in part Kirjallisuutta ja muita viitteitä (Referencies) .
    1. 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.
    2. 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.
    3. Start Titokone. For example, in Windows systems double-click file titokone.bat in your Titokone subdirectory (e.g., titokone).
    4. Use Options/Set language (Asetukset/Aseta kieli) to select English user interface.
    5. Set both compilation options (Options/Set Compiling Options) on
    6. Empty the simulated ttk-91 machine memory with File/Erase memory.
    7. Choose symbolic assembly language program sum.k91 in use with File/Open command ()
    8. 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.
    9. 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?
    10. Select from options (Options/Set running options) "Execute code line by line" () and "Show extra comments while executing" ().
    11. 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?
    12. Reset all other execution options but leave "Show animation while executing " () on.
    13. 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?
    14. 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!
    15. 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