int x=7, y=3, 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 */ }
Check your program by compiling and running it in Koksi.
int n, i, prev, fib, next; /* variables n, i, prev, fib, next */ main () { /* main program */ scanf ("%d", &n); /* read n */ i = 1; prev = 0; fib = 1; while (i < n) { next = prev+fib; prev = fib; fib = next; i = i+1; } printf ( "%d %d \n", n, fib); /* print n, fib */ }
You can keep variable values either in memory or in device registers.
Check your program by compiling and running it in Koksi.
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
Check your program by compiling and running it in Koksi.
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.