Assembly: Logical Operations, Branching/Loops, Procedures 1. (1 point) Provide t
ID: 3590951 • Letter: A
Question
Assembly: Logical Operations, Branching/Loops, Procedures 1. (1 point) Provide the minimal set of MIPS instructions that may be used to implement the following pseudoinstruction: not $t1, $t2 #flip bits 2. (1 point) Convert the following C code into its equivalent MIPS Code: C code: if (a-b) c = d-e; else c d+e; Assume a, b, c, d, e in $s4, $s5, $s6, $s7, $s8 3. (1.5 points) Assume that $t0 holds the value Ox00101001. What is the value of St2 after the following instructions? ADD COMMENTS TO EACH LINE IN THE FOLLOWING PROGRAM TO EXPLAIN YOUR REASONING! slt $t2, $0, $t0 bne $t2, $0, ELSE j DONE ELSE: addi $t2, $t2,4 DONE: 4. (1.5 points) Using procedures, what is the compiled MIPS assembly code for the following? ADD COMMENTS FOR EACH LINE OF CODE! Assume parameter variables a, b, c, and d correspond to the argument registers $a0, $al, Sa2, and $a3 and e corresponds to $s1. Assume the compiled program will start with the label of the procedure: int my_example (int a, int b, int c, int d) nt e; e= (a + b)-(c + d); return eExplanation / Answer
2.if(a==b) c=d-e;
else c =d+e;
bne $s4,$s5,label 1//if(a==b)
sub $s6,$s7,$s8//c=d-e
j label2:// next statement
add $s6,$s7,$s8//c =d+e
4.int my_example(int a,int b,int c,int d)
{
int e;
e=(a+b)-(c+d);
return e;
}
my_example:
li $a0,$a1,$a2,$a3//int a,int b,int c ,int d will be $a0, $a1, $a2, $a3
li $s1//int e
add $s0,$a1,$s2//a+b
add $s2,$a2,$s3//c+d
sub $s1,$s0,$s2//e=(a+b)-(c+d)
jr $s1// return e
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.