There will be ONLY one online exam including both lectures and labs on Tuesday, August 24, 2021 at 9:00 AM. This is a online exam via Canvas/Zoom.
The final exam covers topics after the lab 3 and is NOT comprehensive.
Overall, the exam may include material from the following sources:
I will not ask any questions which were not somehow covered by one of the above three sources.
.equ Exit, 0x11 .equ Open, 0x66 .equ Close, 0x68 .equ Read_Int, 0x6C .data filename: .asciz "myFile.txt" .text .global _start _start: ;; open the file ldr r0, =filename mov r1, #0 swi Open ;; read an integer from it swi Read_Int ;; close the file swi Close ;; exit the program swi Exit .end
.equ Write_Int, 0x6B .text .global _start _start: ;; print out 42 mov r0, #1 mov r1, #42 swi Write_Int
myFile.txt and print them out.
Consider the following code, which sets up a .data section:
.data label1: .asciz "Hi" label2: .word 1, 2 label3: .asciz "Bye"
Assuming the .data section starts at address 0, how does this look in memory?
Use the following table as a template.
| Value | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Index | 0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
Convert the following Java/C-like code into ARM assembly. The names of the variables reflect which registers must be used for the ARM assembly.
if (r0 >= 5) {
r1 = r6;
} else {
r2 = r7;
}
Convert the following Java/C-like code into ARM assembly. Use branch intructions instead of conditional execution. The names of the variables reflect which registers must be used for the ARM assembly.
if (r5 < r6) {
r2 = r3;
print_string("Less");
} else if (r5 == r6) {
r3 = r4;
print_string("Equal");
} else {
r4 = r5;
print_string("Greater");
}
Convert the following Java/C-like code into ARM assembly. The names of the variables reflect which registers must be used for the ARM assembly.
for (int r2 = r1; r2 <= 150; r2 += 4) {
int r3 = (r2 - 1) * (r2 + 1);
print_int(r3);
print_char('\n');
}
Convert the following Java/C-like code into ARM assembly. The names of the variables reflect which registers must be used for the ARM assembly. Non-register variable names indicate a value that should be stored in memory.
int[] myArray = new int[]{19, 21, -5, 4};
int r2 = 0;
int r3 = 0;
do {
r2 += myArray[r3];
r3++;
} while (r3 < 4);
print_int(r2);
Convert the following Java/C-like code into ARM assembly. The names of the variables reflect which registers must be used for the ARM assembly. Non-register variable names indicate a value that should be stored in memory.
int myArray[4] = {19, 21, -5, 4};
int* r2 = myArray;
int r3 = 4;
int r4 = 0;
do {
r4 += *r2;
r2++;
r3--;
} while (r3 != 0);
print_int(r4);
Convert the following Java/C-like code into ARM assembly. The names of the variables reflect which registers must be used for the ARM assembly.
if (r2 < r3 && r3 < r4) {
r5 = r6;
} else {
r6 = r5;
}
Convert the following Java/C-like code into ARM assembly. The names of the variables reflect which registers must be used for the ARM assembly.
if (r2 < r3 || r3 < r4) {
r5 = r6;
} else {
r6 = r5;
}
Convert the following Java/C-like code into ARM assembly. The names of the variables reflect which registers must be used for the ARM assembly. Non-register variable names indicate a value that should be stored in memory.
int[] first = new int[]{0, 5, 27, 98};
int[] second = new int[]{1, 2, 8, 29, 42};
int[] result = new int[9];
int r0 = 0;
int r1 = 0;
while (r0 < 4) {
result[r0] = first[r0];
r0++;
}
while (r1 < 5) {
result[r0] = second[r1];
r0++;
r1++;
}
for (r2 = 0; r2 < 9; r2++) {
print_int(result[r2]);
print_newline();
}
!A refers to the negation of variable A, and so on:
R = !A!B + AB
R = !ABC + ABC + A!B!C
Using the above equation, do the following:
| A | B | C | D | U |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 0 | 0 | 0 | 1 | |
| 0 | 0 | 1 | 0 | |
| 0 | 0 | 1 | 1 | |
| 0 | 1 | 0 | 0 | |
| 0 | 1 | 0 | 1 | |
| 0 | 1 | 1 | 0 | |
| 0 | 1 | 1 | 1 | |
| 1 | 0 | 0 | 0 | |
| 1 | 0 | 0 | 1 | |
| 1 | 0 | 1 | 0 | |
| 1 | 0 | 1 | 1 | |
| 1 | 1 | 0 | 0 | |
| 1 | 1 | 0 | 1 | |
| 1 | 1 | 1 | 0 | |
| 1 | 1 | 1 | 1 |
Using the above truth table, write out the following: