Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Midterm Exam
2016.04.18 AM 9:00
* General instructions
A. Write clearly. Illegible answers will receive no credit.
B. Show your work! Answers without proper explanation/calculation will be penalized.
<Problems>
1. (10pt) Consider a computer running programs with CPU times shown in the following table.
FP Instr. INT Instr. L/S Instr. Branch Instr. Total time
35 s 85 s 50 s 30 s 200 s
How much is the total time reduced if the time for L/S operations is reduced by 40%?
Answer)
2. (10pt) The following table shows the number of instructions for a program.
5. (10pt) The table below shows translated ARM assembly code from the C code. Fill the blank.
f:
push {r7}
sub sp, sp, #20
add r7, sp, #0
str r0, [r7, #12]
str r1, [r7, #8]
str r2, [r7, #4]
ldr r3, [r7, #8]
lsl r3, r3, #2
ldr r2, [r7, #12]
adds r3, r2, r3
ldr r2, [r3, #0]
ldr r3, [r7, #4]
cmp r2, r3
bne .L3
mov r3, #0
b .L4
.L3:
mov r3, #1
.L4:
mov r0, r3
add r7, r7, #20
mov sp, r7
pop {r7}
bx lr
int f (int* arg0, int arg1, int arg2) {
( )
else return 1;
}
Answer)
6. (15pt) Take a look at the clear(int* array, int size) function below. You could optimize this
code with arithmetic operations on a pointer. Fill the blanks
MOV r4, #0 ; i = 0
MOV r5, #0 ; r5 = 0
loop1:
STR r5, [r0, r4, LSL #2] ; array[i] = 0
ADD r4, r4, #1 ; i = i + 1
CMP r4, r1 ; i < size
BLT loop1
MOV r4, r0
MOV r5, #0
ADD r6, r0, r1, LSL #2
loop2:
( )
( )
BLT loop2
Answer)
7. (15pt) Describe briefly the following computers
(a) Desktop computers
(b) Server computers
(c) Embedded computer
8. (10pt) Briefly compare the power, performance(speed) and capacity(size) among the
memory storages.
Register Cache Main Memory Storage
Power a. <--------------------------> b.
Speed c. <--------------------------> d.
Size e. <--------------------------> e.
Answer)
9. (10pt) Using 4-bit numbers to save space, multiply 0000 00102 01112. Complete the
table 1.
Table 1.
1 2
2 2
3 2
4 2