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 a=7, c=4, m=15, i=4, i0=4,
k=0, n=0, j=1, p=0; /* variables a,c, i, i0, k, n, j, p */
main(){ /*main program, basic linear congruential
algorithm */
scanf("%d", &n); /* read an integer into n */
scanf("%d", &p); /* read an integer into p */
while (k < n) {
if (i0 == i) /* if the value of i0 is same as the value of i
*/
j=1;
if (p==1) /* print only random numbers */
printf("%d \n", i); /* print i */
else
printf("%d %d %d\n", k, j, i); /* print k, j, i */
i = (a * i + c ) % m; /* take module m from expression inside
() */
k++; j++; /* increment 1 into k and j */
}
}
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 party: 4 integer fields
Places EQU 0 ; relative address within record
Votes EQU 1
Change EQU 2
VoteC EQU 3
Records SDP and KESK have been allocated from memory with
initialized data and record KOK has been allocated partly with uninitialized
data with pseudoinstructions
SDP DC 2585 ; Places = 2585
s1 DC 575822 ; Votes = 575822
s2 DC 26 ; Change = 26
s3 DC 64452 ; VoteC = 64452
KESK DC 4425
k1 DC 543885
k2 DC -200
k3 DC 15566
KOK DC 2078
kok1 DC 521412
kok2 DS 1 ; initial values not defined
kok3 DS 1 ; initial values not defined
Please notice that you should not use symbols s1, s2, s3, k1, k2,k3, kok1, kok2, and kok3. They have been written down because Titokone simulator gives an error if there is DC without symbolic name in front of it.
Example: If R4 points to the beginning of record SDP, then the change of the places of the party SDP compared to the year 2004 election is obtained to register R5 with machine instruction "LOAD R5, Change(R4)".
Write a TTK-91 symbolic assembly language program to