MIPS: Label with number (?) on Branch on Not Equal

0

Ok, I have the following exercise:

  

Considering the values in the registers $ t0 = 0x0000001A, $ t1 =   0x00000006, and the following code to be run by the MIPS processor, answer:

add $t2, $t0, $t1
srl $t3, $t2, 1
addi $t3, $t3, -8
div $t2, $t3
mfhi $t3
mflo $t4
sll $t3, $t3, 9
sub $v0, $t2, $t3
bne $t3, $t4, -32
jr $ra
  

(a) Is conditional deviation performed?

It may sound like a beast question, but I did not understand this "-32" in the penultimate line of the code. Is -32 indicating the address in memory? Which is? Or is it wrong on purpose for the answer to the question a) to be false?

    
asked by anonymous 30.09.2018 / 04:51

1 answer

1

Hello

When I did the Computer Organization (Computer Architecture) discipline, I used MARS [1] as a simulator and it says that the third argument of the Branch on not equal (BNE) statement should be a label , that is, a named location where your code should jump.

However, by looking in the MIPS Instruction Reference [2], the syntax of the bne statement is displayed as follows: bne $s, $t, offset . By offset, I understand that it is an address offset even, which in the end is what happens "under the covers" when we use a label.

I ran your code in MARS just by changing the -32 by a label and the bne condition is met and the jump happens. Therefore, I would answer that, yes, it does the deviation.

  • link
  • link
  • 20.12.2018 / 00:55