Docsity

Final Exam Close Book Notes - Computer Organization | COMPE 271, Exams of Computer Architecture and Organization

Toggle sidebar
bg1
COMPE271
FINALEXAM
CloseBooks–Notes
1‐ (Knowledgeassessed–InstructionSetArchitecture)(10points)
Thecodesegmentgivenbelowillustratesafunctionforexchangingthevaluesoftwovariablesandits
usewithinanotherfunction(maininthisexample)
int exchange(int *a, int *b)
{
int c;
c = *a;
*a = *b;
*b= c;
return(1);
}
int main(int argc, char* argv[])
{
int a = 0x01010101;
int b = 0x02020202;
int c;
printf(" variable a contains %d\t and b containes %d\n",a,b);
c = exchange(&a,&b);
printf(" variable a contains %d\t and b containes %d\n",a,b);
}
A visual representation of the memory and registers before function call in
the main function is captured and given below. The question is the state
of the memory and the registers after the function is called (when you first
enter the function). On the visual representation of memory and registers
below make necessary changes to illustrate the state of the memory and
registers in the function before the prolog of the function is executed.
Clearly show the value of the stack pointer and the values in changed memory
cells when you first enter the function (before the prolog is executed)
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Final Exam Close Book Notes - Computer Organization | COMPE 271 and more Exams Computer Architecture and Organization in PDF only on Docsity!

COMPE 271

FINAL EXAM

Close Books – Notes

1 ‐ (Knowledge assessed – Instruction Set Architecture ) (10 points)

The code segment given below illustrates a function for exchanging the values of two variables and its use within another function ( main in this example)

int exchange(int *a, int *b) { int c;

c = *a; *a = *b; *b= c;

return(1); }

int main(int argc, char* argv[]) {

int a = 0x01010101; int b = 0x02020202; int c;

printf(" variable a contains %d\t and b containes %d\n",a,b);

c = exchange(&a,&b);

printf(" variable a contains %d\t and b containes %d\n",a,b); }

A visual representation of the memory and registers before function call in the main function is captured and given below. The question is the state of the memory and the registers after the function is called (when you first enter the function). On the visual representation of memory and registers below make necessary changes to illustrate the state of the memory and registers in the function before the prolog of the function is executed. Clearly show the value of the stack pointer and the values in changed memory cells when you first enter the function (before the prolog is executed)

Addres Address

Decimal Hex

999920 000F41F 999924 000F41F 999928 000F41F 999932 000F41FC ESP 00 0F 42 14 999936 000F 999940 000F4204 EBP 999944 000F 999948 000F420C EAX 999952 000F 999956 000F4214 EBX 999960 000F 999964 000F421C ECX 999968 000F 999972 000F4224 EDX 999976 000F 999980 000F422C 999984 000F 999988 000F4234 02 02 02 02 b is stored in this memory location 999992 000F4238 (^01 01 01 01) a is stored in this memory location 999996 000F423C

1000000 000F

3 ‐ (Knowledge assessed ‐‐ Assembly language programming ) (20 points)

Give the following skeleton code write a code segment in assembly to count the number of words

and the number of letters in each word. Store number of words and number of letters in each word

to be printed by C as given below.

#include "stdafx.h"

int main(int argc, char* argv[])

{

char sentence[]=”This was the most difficult class I had this semester. But the final exam is real

easy.Thank you professor Ozturk”

char numwords;

char numletters[40]; // Assuming there are a maximum of 40 words in the sentence , store the

number letters in each word in this array. Number of letters in the first word in numletters[0], …

_asm{

Printf(“\n There are %d words in this sentence\n”, numwords);

For (int i=0; i<numwords; i++)

Printf(“\n number of letters in word %d is %d \n”,i,numletters[i]);

}

4 ‐ (Knowledge assessed – Memory , Performance ) (5 points )

A computer has a cache, main memory and disk used for virtual memory. If a reference word is in the cache 12 ns are required to access it. If it is in the main memory but not in the cache , 60 ns are required to load it into the cache and then reference is started again. If the word is not in the main memory , 12 ms are required to fetch from disk , followed by 60 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?

6 ‐ (Knowledge assessed – Cache memory ) (15 points)

(Cache Design) Suppose a 32 ‐bit byte‐addressable CPU accesses memory in the following order: 17433, 17435, 17443, 17448, 17451, 17438, 17439, 17459. Assume that we have 4 cache blocks. Initially the cache is empty. (1 cache word = 4 bytes)

a. If the cache is direct‐mapped, show the final contents of the cache with memory block number. Assume 1 block is 1 word. (Ignore the tag field and other bits.) What is the total number of misses?

b. If the cache is 2 ‐way set associative with LRU replacement policy, show the final contents of the cache with memory block number. Assume 1 block is 2 words. (Ignore the tag field and other bits.) What is the total number of misses?

7 ‐ (Knowledge Assessed - Processor Architecture) (15 points)

Suppose we analyze the combinational logic given above and determine that it can be separated into a sequence of six block, named A through F, having delays of 30,50,20,50,30 and 10 ps, respectively, illustrated as follows.

We can create a pipelined version of this design by inserting pipeline registers between pairs of these blocks.Different combination of pipeline depth and maximum throughput arise depending on where we insert the pipeline registers. Assume that a pipeline register has a delay of 10 ps.

A. Inserting a single register gives a two stage pipeline. Where should this register be inserted to maximize throughput? What would be the throughput and latency?

B. Where should two registers be inserted to maximize the throughput of a three stage pipeline? What would be the throughput and latency?

C. Where should three registers be inserted to maximize the throughput of a four stage pipeline? What would be throughput and latency?

D. What is the minimum number of stages that would yield a design with the maximum achievable throughput? Describe this design , its throughput and its latency.

Combinational circuit

R

e g

A B C D E F

R

E

G

clock

a‐ Is the variable val stored on the stack? If so, at what byte offset (relative to %ebp) is it stored, and why is it necessary to store it on the stack?

b‐ Is the variable val2 stored on the stack? If so, at what byte offset (relative to %ebp) is it stored, and why is it necessary to store it on the stack?

c‐ What (if anything) is stored at ‐24(%ebp)? If something is stored there, why is it necessary to store it?

d‐ What (if anything) is stored at ‐8(%ebp)? If something is stored there, why is it necessary to store it?