3.) Using the MIPS program below (including bugs), determine the instruction for
ID: 3550463 • Letter: 3
Question
3.) Using the MIPS program below (including bugs), determine the instruction format for each instruction and the hexadecimal values of each instruction field.
addi $v0, $zero, 0 # Initialize count
loop: lw $v1, 0($a0) # Read next word from source
sw $v1, 0($a1) # Write to the destination
2.) The following MIPS instruction sequence could be used to implement a new instruction that has two register operands. Give the instruction a name and describe what it does. Note that register $t0 is being used as a temporary.
bne$t0, $s1, Exit # go to Exit if save[i] <> k
addi$s0,$s0,1 #i=i+1
j Loop #go to loop
Exit:
Only poor compilers whould produce code with this loop overhead
a.)Rewrite the assembly code so that it uses at most one branch or jump each time through the loop(as opposed to two above)
b) How many instructions are executed before the optimization if the number of iterations of the loop is 10?
c.) How many instructions are exetcuted after the optimization if the number of titerations is 10?
Explanation / Answer
2.
dsrl $s0 $s1 # shift two registers right one position
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.