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

Asked

Viewed 88 times

0

Okay, I have the following exercise:

Taking into account the values present in the registers $t0 = 0x0000001A, $t1 = 0x00000006 and the following code to be executed 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) Conditional deviation is carried out?

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

1 answer

1


Hello!

When I took the Computer Organization (Computer Architecture) course, I used MARS[1] as a simulator and there it says that the third argument of the instruction Branch on not Equal (BNE) must be a label, ie, a named loca to which your code should jump.

However, looking in the MIPS Instruction Reference[2], the syntax of the instruction Bne is presented as follows: bne $s, $t, offset. By offset, I understand it is an address offset even, which at the end of the day is what happens "underneath the scenes" when we use a label.

I ran your code on MARS just changing the -32 by a label and the condition of the bne is met and the jump happens. Therefore, I would reply that, yes, performs the deviation.

  1. http://courses.missouristate.edu/KenVollmar/mars/
  2. http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.