Question
a. Using MIPS conditional branch command, transform the following snippet of C code to assembly instruction. Store the value of t1 and t2 in registers
a. Using MIPS conditional branch command, transform the following snippet of C code to assembly instruction. Store the value of t1 and t2 in registers $t1 and $t2 respectively.
if (t2 < t1) t1++; else t1 = t2 t1;
b. Answer the following questions based on the given MIPS code snippet.
START: addi $t1, $t1, -2 addi $t2, $t2, 5 addi $t3, $t3, -2 bne $t1, $0, START li $v0, 10 syscall i. Add MIPS instruction to the given snippet to initialize register $t1, $t2 and $t3 with immediate values as following:
$t1 = 10, $t2 = 20, $t3 = 30
ii. What is the final value in register $t1, $t2 and $t3?
iii. For code snippet above, write the equivalent C/C++ code. Assume that the register $t1, $t2 and $t3 are integer t1, t2 and t3 respectively.
c. The following snippet program is a MIPS instruction with its memory address (in hexadecimal). By referring to MIPS Reference Data, convert the underlined assembly instructions to machine code. Explain how you get the answer. [00400028] sub $17, $18, $19 [0040002c] CONTINUE: beq $t6,$0,END [00400030] addi $t4,$t5,-1 [00400034] andi $s6,$s2, 1 [00400038] sub $s1,$s2,$s3 [0040003c] j CONTINUE [00400040] END: ori $s4, $s5, 10 [00400044] li $v0, 10 [00400048] syscall
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started