Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Show the assembler instrctions equivalent to the following. a. $t0 = 1 - $t2

ID: 3547275 • Letter: 1

Question



1) Show the assembler instrctions equivalent to the following.


a. $t0 = 1 - $t2

b. $t1 = $t2 + (5+$t6) / $t3



2) Show the instructions equivalent to each of the following:


A. if ($t1<1 || $t2>=$t1)

     {

                  (1)

    }

else if ($t3!= 0)

{

(2)


}

else

{

(3)

}


(4)



B.    if ($t1<=$t2) {

   


            (1)


If ($t3==$t4 && St1> $t4 {



(2)


}


(3)


}

else

{


(4)


}


(5)



C.  for ($t1=100 ; $t1> $t2 ; $t1--)

      {

       print "Enter a number: "

       read num

       $t3 = $t1 + num

       if ($t3<=50)

       $t4=$t4+$t3

}


print $t3



Explanation / Answer

1)

a.

li $t0 , 1

sub $t0 , $t0 , $t2


b.

addi $t6 , $t6, 5

div $t1 , $t6 , $t3

add $t1 , $t2 , $t1



2)

A.


li $t7 , 1

blt $t1, $t7 , one

blt $t1, $t2 , one

beq $t1, $t2 , one

bnq $t3 , $zero , two

three: #Code of (3)

j exit

one: #Code of (1)

j exit

two: #Code of (2)

j exit

exit: #Code of (4)


B.


blt $t1, $t2 , one

beq $t1, $t2 , one

j next

one: #code of (1)

bnq $t3 , $t4 , three

blt $t1 , $t4 , three

beq $t1 , $t4 , three

two: #code of (2)

three: #code of (3)

j exit

next: #code of (4)

exit: #code of (5)


C.

print: .asciiz "Enter a number:"

.text

li $t7 , 100

li $t5 , 50

loop:

li $v0 , print

syscall

li $v0, 5

syscall

move $t0, $v0

add $t3 , $t1 , $t0

bgt $t3 , $t5 , next

add $t4, $t4 , $t3

subi $t1 , $t1 , 1

bgt $t1 , $t2 , loop

print2:

move $v0 , $t3

syscall