Question: Question 1: Assume the following MIPS code. Assume that $a0 is used for the input and initially contains n, a positive integer. Assume that $v0is
Question 1:
Assume the following MIPS code. Assume that $a0 is used for the input and initially contains n, a positive integer. Assume that $v0is used for the output
addi $t0, $zero,0 addi $t1, $zero,1 slt $t2, $a0, $t1 bne $t2, $zero, finish add $t0, $t0, $t1 addi $t1, $t1,2 j loop finish: add $v0, $t0, $zero Add comments to the code and describe each instruction. In one sentence, what does the code compute?
begin:
loop:
Question 2:
a) Provide the best equivalent sequence of MIPS instructions that could be used to implement the pseudo-instruction bgt, branch on $s0 > $s1.
bgt $s0, $s1, target You may use register $at for temporary results.
b) Provide the best equivalent sequence of MIPS instructions that could be used to implement the pseudo-instruction clear.
clear $t2
c) Show the single MIPS instruction or minimal sequence of instructions for this C statement:
A= b - 48;
Assume that a corresponds to register $t0 and b corresponds to register $t1
Question 3:
a) Assume $t0 holds the value 0x00011000. What is the value of $t2 after the following instructions? slt $t2, $0, $t0 bne $t2, $0, ELSE j DONE ELSE: addi $t2, $t2, 3 DONE:
b) Consider the following MIPS loop:
LOOP: slt $t2, $0, $t1 Beq $t2, $0, DONE subi $t1, $t1, 2 addi $s2, $s2, 2 j LOOP DONE:
1. Assume that the register $t1is initialized to the value 20. What is the value in register $s2 assuming $s2is initially zero?
2. For each of the loops above, write the equivalent C code routine. Assume that the registers $s1, $s2, $t1, and $t2are integers A, B,i,and temp, respectively.
3. For the loops written in MIPS assembly above, assume that the register $t1 is initialized to the value N. How many MIPS instructions are executed?
pleeeease solve it all
(estion 1: Assume the following MIPS code. Assume that $20 is used for the input and initally contains a positive Intezer. Assume that is used for the output Legir: $1.0, sero, and Sti. Szero, 1 Loop: 5- $t2. $20, $ti d310, DC, SL addi ti, 31.1.2 figisa: ada So Sto, Szero Add comments to the code and describe each instruction. In one sentence, whet does the code compute? (stion 2: al Provide the best equivalent sequence of MIPS instructions that could be used to implement the pseudo-irstruction ag, branch on 3 > 31 bg: $50.501, target You may use register sat for temporary results h Provide the best equivalent sequence of MIPS instructions that could be used to implement the Suid-ractioner clear sta 0 - Show the single MIPS instruction or minimal sequence of instructions for this statement Ab- 48 Assume that a corresponds to register to and corresponds to register $t 1 Cology of Crew Compagnie ta ITN 115, TACHI Irrk Question 3: al Assume Sto holds the value 0.00011000. What is the value of St2 after the foloving instructions? slt 3t2, 50, sto Er $12, 30, RIOR 6.53: 9, $123 IXON by Consider the following MIPS Icop: $12, 91, 911 $0, NR sabi ati. Sti, 2 addi 1. Absure that the register Stais initialized to the value 20. What is the value nregster 52 assuming Sc2is initially zero? 2. For each of the leaps above, write the equivalent Ccade routine. Assume that the registers $81,982, stl, and stare intep 4, 6, i,dt temeyectively 3. For the loops written in MIPS assembly above, assume that the register $1 binitialized to the value N. How many MIPS instructions are executed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
