Be prepared to show all Koksi related and other programming 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. Alternatively to bringing the diskette, you can store your programs to the fs file server.
Write a TTK-91 symbolic assembly language program that computes the n'th Fibonacci number. Your program could be a translation from C program
int n, i, prev, fib, next; /* variables n, i, prev, fib, next */ main () { /* main program */ scanf ("%d", &n); /* read an integer into n */ i = 1; prev = 0; fib = 1; while (i < n) { next = prev+fib; prev = fib; fib = next; i++; } printf ( "%d %d \n", n, fib); /* print n, fib */ } /* scanf command simply read one integer and printf command prints two integers */
You can keep variable values either in memory or in device registers.
The web-page asks first you to choose your small group. Then you have to write your name and upload your symbolic assembler file. The same you use as source code to koksi simulator.
You have to return the answer at the latest 24 hours before the small group session's starting time. A late delivery is not possible.
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.
What data in program Simple (e.g., variable values) would one want to keep ...
d) is not a trick question!
Write a TTK-91 symbolic assembly language program that does the same as C program
int x=7, y=33, z=5; /* variables x, y, z */ main () { /* main program */ y = 4; x = 52 - y * z; if (x < 40) { y = x - 34; } else { y = x / y + 4; z = 23; } printf ( "%d %d %d \n", x, y, z) /* print x, y, z */ } /* printf command simply prints three integers */
Constants (e.g., value MAXID=78) can locate in many different places during program execution. Write TTK-91 symbolic assembly language instructions with which one would add value of constant MAXID to R1, and where MAXID value (78) is taken from
Give an example where case (a) would be best suitable. Similarly, for cases (b) and (c). Give reasoning for your examples.
# record person: 3 integer fields Id EQU 0 # relative address within record Age EQU 1 Salary EQU 2
Records Pekka and Jussi have been allocated from memory with
initialized data and record Maija has been allocated with uninitialized
data with pseudoinstructions
Pekka DC 3214 # ID = 3214 DC 35 # AGE = 35 DC 12345 # SALARY = 12345 Jussi DC 8888 DC 54 DC 14321 Maija DS 3 # initial values not defined
Example: If R4 points to the beginning of record Pekka, then Pekka's salary is obtained to register R5 with machine instruction "LOAD R5, Salary(R4)".
Write a TTK-91 symbolic assembly language program to