1

How to write the following into MIPS instructions?

  • $t0=$t1
  • if ($t6<$t7) go to Label.
Gabe
  • 84,912
  • 12
  • 139
  • 238
user644441
  • 11
  • 3

3 Answers3

1

$t0 is not reserved for zero. $t0 is a temporary register that can store any value. The register $zero is reserved/hard-wired to zero. We would want to "branch" to "Label" if $t6 is "less than" $t7, so use the branch on less than instruction blt. The code would look like:

add $t0,$zero,$t1
blt $t6,$t7,Label

chrislgarry
  • 616
  • 5
  • 21
0

your following rubbish:

$t0=$t1

if ($t6 less than $t7) go to Label

would be converted to MIPS like:

move $t0,$t1 # or use instruction instead (add $t0,$zero,$t1)|(addi $t0,$t1,0)

slt $t2,$t6,$t7 # if $t6less than $t7 set $t2=1

bgtz $t2,foo # if $t2=0 goto foo, and foo is the label that you want to move to

Community
  • 1
  • 1
Snymeh
  • 255
  • 1
  • 3
  • 9
0

Assuming that the registers are already loaded with the right data.

So for $t2 = $t3, adding $t3 to register zero and storing it in $t2 will work so this is how it would look like :

add $t2,$t3,$t0 - assuming $t0 is reserved for zero like most versions of mips.

for if $t4, we need a branch statement, not sure what you want to compare it to, but look at this guide - should give enough instructions about how to write it.

Rakholiya Jenish
  • 3,165
  • 18
  • 28
Abraham Adam
  • 635
  • 1
  • 6
  • 16