Practice Final Exam on Computer Organization - Fall 2010 | COMPE 271, Exams of Computer Architecture and Organization

Material Type: Exam; Professor: Ozturk; Class: COMPUTER ORGANIZATION; Subject: Computer Engineering; University: San Diego State University;

Typology: Exams

2011/2012

Uploaded on 02/01/2012

misao-maki
misao-maki ๐Ÿ‡บ๐Ÿ‡ธ

5

(1)

13 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COMPE 271
Fall 2010 - FINAL EXAM
Open Books โ€“ No Calculators โ€“ No Notes
1- (Knowledge assessed -- Assembly language programming ) (15 points)
Consider the following assembly code for a C for loop:
loop:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%ecx
movl 12(%ebp),%edx
xorl %eax,%eax
cmpl %edx,%ecx
jle .L4
.L6:
decl %ecx
incl %edx
incl %eax
cmpl %edx,%ecx
jg .L6
.L4:
incl %eax
movl %ebp,%esp
popl %ebp
ret
Based on the assembly code above, fill in the blanks below in its corresponding C source code.
(Note: you may only use the symbolic variables x, y, and result in your expressions below โ€” do
not use register names.)
int loop(int x, int y)
{
int result;
for (_____________; ___________; result++ ) {
___________________________;
___________________________;
}
__________;
return result;
}
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Practice Final Exam on Computer Organization - Fall 2010 | COMPE 271 and more Exams Computer Architecture and Organization in PDF only on Docsity!

COMPE 271

Fall 2010 - FINAL EXAM Open Books โ€“ No Calculators โ€“ No Notes 1- (Knowledge assessed -- Assembly language programming ) (15 points) Consider the following assembly code for a C for loop: loop: pushl %ebp movl %esp,%ebp movl 8(%ebp),%ecx movl 12(%ebp),%edx xorl %eax,%eax cmpl %edx,%ecx jle .L .L6: decl %ecx incl %edx incl %eax cmpl %edx,%ecx jg .L .L4: incl %eax movl %ebp,%esp popl %ebp ret Based on the assembly code above, fill in the blanks below in its corresponding C source code. (Note: you may only use the symbolic variables x, y, and result in your expressions below โ€” do not use register names. ) int loop(int x, int y) { int result; for (_____________; ___________; result++ ) { ___________________________; ___________________________; } __________; return result; }

2- (Knowledge assessed โ€“ Memory , Performance ) (10 points ) A computer has a cache, main memory and disk used for virtual memory. If a reference word is in the cache 5 ns are required to access it. If it is in the main memory but not in the cache , 50 ns are required to load it into the cache and then reference is started again. If the word is not in the main memory , 11 ms are required to fetch from disk , followed by 50 ns to copy it into the cache and then the reference is started again. The cache hit ratio is 0.8 and the main memory his ratio is 0.6. What is the average time in nanoseconds required to access a referenced word on this system?

4. (Instruction Set Architecture โ€“ 10 POINTS) This problem tests your understanding of how for loops in C relate to IA32 machine code Consider the following IA32 assembly code for a procedure foo(): foo: pushl %ebp movl %esp,%ebp movl 12(%ebp),%ecx xorl %eax,%eax movl 8(%ebp),%edx cmpl %ecx,%edx jle .L .align 4 .L5: addl %edx,%eax decl %edx cmpl %ecx,%edx jg .L .L3: leave ret Based on the assembly code above, fill in the blanks below in its corresponding C source code. (Note: you may only use symbolic variables x, y, i and result , from the source code in your expressions below โ€” do not use register names.) int foo(int x, int y) { int i, result=0; for (i=________; ____________________________; _________) { ______________; } return result; }

5. (Processor Architecture โ€“ 10 points) Hypothetical Y86 processor has eight registers , and each register is represented by a 4 bit identification as given below. Register id 8 , indicates no register. The generic instruction has the format encoded representation as follows. b Where the first byte is the instruction type and second byte is the source and destination operands. The instruction set and the corresponding encoding for each Y86 instruction is given below as well. 6. ( Integer representation ) โ€“ 10 points

%eax

%ecx

%edx

%ebx

%esi

%edi

%esp

%ebp

addl rA, rB 6 0 rA rB

Determine the byte encoding of the Y instruction sequence given below. Note that .pos 0x100 indicates that the starting address of the object code should be 0x100. .pos 0x irmovl $15,%ebx irmovl $15,%ecx addl %ecx,%ebx Loop: rmmovl %ecx,-3(%ebx) addl %ebx,%ecx jmp loop

Byte^0 1 2 3 4

pushl rA A^0 rA 8

jXX Dest 7 fn Dest

popl rA B^0 rA 8

call Dest 8 0 Dest

rrmovl rA, 2 rB^0 rArB

irmovl V, rB 3 0 8 rB V

rmmovl rA, 4 D^ (^0 rB^ rA)rB D

mrmovl D(rB^5 ),^0 rArArB D

OPl rA, rB 6 fn rArB

ret 9 0

nop 0 0

halt 1 0

7. ( Floating Point representation) โ€“ 10 points

  1. (Assembly Language Programming ) โ€“ 20 points Given an array (int scores[N]) containing N integer midterm scores between 0 and 99, write a code fragment in Assembly that computes how many of the scores fall within each of the ten intervals [0, 9], [10, 19], [20, 29], โ€ฆโ€ฆโ€ฆ., [90, 99], where the notation [a, b] refers to all scores greater than or equal to a and less than b. The function should get two array arguments one containing the scores and the second containing the frequencies. An example function stub for the problem is given below. The assembly function wil be called from the main program with the following command. **computeFrequency(int scores, int freq, int N)

Bonus Question: (10 points)