Question: Problem 1 : Write a function add 6 4 that adds two input unsigned 6 4 bit integers x and y and returns the unsigned
Problem : Write a function add that adds two input unsigned bit integers x and y and returns the unsigned bit integer sum z ie z x y In your main function, you should assume that x y and z will be stored in the following registers as follows:
x: upper bits in $t lower bits in $t
y: upper bits in $t lower bits in $t
z: upper bits in $t lower bits in $t
Your main function call should read the values of x and y into the stack, invoke add and then return z on the stack.
Also, your function should generate an error only if there is an overflow in the overall bit addition and not if there is an overflow in the addition of the lower bit components
Problem :
Consider the following loop that takes calculates the sum of two arrays:
data
arr: word
arr: word
arrsum: space # equal to words
text
la $a arr
la $a arr
la $a arrsum
li $s # loop counter
loop:
beqz $t done
lw $t arr
lw $t arr
add $t $t $t
sw $t arrsum
addi $s $s
addi $a $a
addi $a $a
addi $a $a
b loop
done:
A Calculate the total number of clock cycles needed to run this program if the CPU does not use any pipelines. For simplicity, you may assume that each instruction in the above program is atomic and not a macro that can expand into multiple instructions such as li and la What is the CPI?
B Calculate the total number of clock cycles needed to run this program if the CPU uses pipelining and automatically inserts nop instructions where needed to avoid data hazards. You may also assume perfect branch prediction, ie there are no wasted clock cycles due to control hazards so you don't have to insert nop instructions due to beqz instruction
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
