CS 466: Advanced Computer Architecture


Solutions for hw #2

2.2
CPI - cycles per instruction; CLK - clock cycle time; IC - Instruction count; R - % of total instructions removed.
CPU time old = CPI old X Clk old X IC old ---- 1
CPU time new = CPI new X CLK new X IC new
= CPI old X 1.1 X CLK old + (IC old - R) ---- 2
Equating 1 and 2 and solving for R, we get R = 9%
R is the percentage of instructions to be removed. So percentage of loads that has to be removed = (9% / 22.8%) = 39.5%
b.
Assume r1 = 45; 0(r1) = 5 ld r1, 0(r1)
Add r1,r1,rl
The result is 5 + 5 = 10
If it is replaced by the new instruction
Add r1, 0(r1)
the result would 45 + 5 = 50
Hence the old instruction cannot be replaced by the new instruction

2.3
Write the appropriate assembly language and find the size of the code in bytes and the no. of memory transfers.
Sample: For Accumulator Architecture
Load B
Add C
Store A
Add C
Store B
Sub B
Store D
All instructions access memory. There are 7 instructions in total. Hence
Total no. of memory accesses = 4 X 7 = 28 bytes.
Each instruction occupies 1 byte for opcode + 2 byte for memory address = 3 bytes.
Code size = 3 X 7 = 21 bytes

2.10
no. of memory access = 1 + 0.26 + 0.09 = 1.35
REMEMBER: You have to consider the instruction accesses also for calculating the total no. of memory accesses
For data accesses you have to consider the % of load and stores
no. of data accesses = .26 + .09 = .35
% of data access = no. of data access / number of memory access
= .35/1.35 = 26%
% of data accesses that are reads = no.of data reads/ no. of data accesss
= .26/.35 = 74%
% of memory read = 1 + 0.26 / 1.35 = 93%

2.11
CPI = summation of (CPI of individual instruction X Frequency of individual instructions) Use the above formula and find the CPI.
REMEMBER: For conditional branches you have to find the % of taken branches by multiplying the frequency of conditional branch instrucition by 60% and that of not taken by 40%
The answer is : 1.23

2.12
a. Ic new / IC Old = ( ICold - (26% X 10% - 9% X 10 % )X IC Old ) / IC old
= .965
b. Cpu time new = CPI old + 1.05 X CLK old + 0.965 X IC old = 1.01325 X CPU time old.

this implies the older one is faster.