Please note that there are a couple of guides to the TTK-91 assembly
language available also in English at the following
addresses: http://www.cs.Helsinki.FI/~marttine/titokoksieng1.html and
http://www.cs.Helsinki.FI/~marttine/titokoksieng2.html. Some further
information about assembly languages can be found in Tanenbaum (4th
edit.) pp. 322 - 354, Tanenbaum (3rd edit.) pp. 350 - 354 and in van de Goor chapters 4 - 7.
1. Simulate the execution of the following program. What is the output, if you enter the month of your birth as input? And what would happen, should you enter a negative number?
Alku LOAD R1,=0 STORE R1,15 IN R2,=KBD STORE R2,14 LOAD R3,15 ADD R3,14 STORE R3,15 LOAD R4,14 SUB R4,=1 STORE R4,14 JPOS R4,4 LOAD R5,15 OUT R5,=CRT Loppu SVC SP,=HALTb) The program makes use of direct memory addresses. However, symbolic variable names could be used instead while letting the compiler to do the mapping between names and addresses. Try to make the code more 'readable' and easier to manipulate.
2. a)What do the following commands do? Let jatko be 100 by value and let a be 120. Register R2 has the value 20.
IN R1,=KBD MUL R1,=7 STORE R1,a JUMP @jatko(R2)
b) The contents of some registers and memory words are as follows:
R1: 0, R2: 10, R3: 100 MP 100: 200, MP 110: 300, MP 200: 400, MP 300: 500, MP 400: 400What are the contents of R1 after the following instructions? Instructions are done in the given order.
1) LOAD R1, 100(R2) 2) LOAD R1, =100(R3) 3) LOAD R1, @R3 4) LOAD R1, R3 5) LOAD R1, @100(R2) 6) LOAD R1, @400(R1)(Tanenbaum: Addressing, pp. 213 - 218.)
3. There are one hundred students taking a course. The exam results (points) are stored to the subsequent memory words 100, ..., 199. Write an assembly language program to display the average exam result.
4. Make an assembly language program which displays the factorial of a positive integer entered by the user. (The factorial of a positive integer is the product of the number itself and the integers which are smaller than the said number and greater than zero. For example, the factorial of five is 5*4*3*2*1, i.e. 120.)
5. Four bit strings were found from the main memory of the Koksi simulator. Below they are represented as hexadecimal numbers.
01 A0 00 A0 18 47 00 01 13 31 FF FF 02 80 FF FEGive the instructions in TTK-91 assembly language (hint: make a conversion into bit strings at first). What do the instructions do?
6.
a) Experiment with the KOKSI simulator. The simulator can be downloaded
from the course home page. If you don't install it into your own computer, you
may try it out in the the machines of the department. The simulator can be found at
least in the machines of terminal room D427 (disk G under the Windows
File Manager). Try to run your assembly language programs.
b) If you were to make a simulator like Koksi, how would you begin?
Please do not go into details: the very general idea and the most
important data structures are enough for this exercise.