beq, bne immediate value

632 views
Skip to first unread message

j.cal

unread,
Jun 13, 2007, 2:51:00 AM6/13/07
to UCSB ECE 15B
On the lecture slides the immediate value for beq is 3 because it says
to start at the next instruction and then go down to end, which is 3
instructions.

Loop:
beq $9,$0,End
addi $8,$8,$10
addi $9,$9,-1 ###1
j Loop ###2
End: ###3

But on the 2nd midterm, # 3, it has

run3:
add $s0, $s0, $t9
bne $s0, $0, run 3
j init3

So, if we start at the instruction after bne, which is j init3, and
then go back up 2 lines to the start of run3, isnt this -2, not -1?
Do we only go down one instruction if the jump is down and not up?
clarification please

Maria G. Medina

unread,
Jun 13, 2007, 3:00:13 AM6/13/07
to ucsb-e...@googlegroups.com
I have a question on that same part of the exam. Shouln't the binary
instruction number start with 0x141 not 0x160?
I don't undertand why it's -1. I think it should be -2.

"j.cal" <jc...@umail.ucsb.edu> wrote:

--
Maria Medina
mgme...@umail.ucsb.edu

Maria G. Medina

unread,
Jun 13, 2007, 3:09:18 AM6/13/07
to ucsb-e...@googlegroups.com
If we are asked to write the immediate for bne in hex, and we are
given the addresses like in problem 3 of miderm 2, Do we write the
adress that it's jumping to, or do we write -2 in hex? if we have to
write the adress, do we shift that by 2 to the right, (like we did for
the jump instruction)?

--
Maria Medina
mgme...@umail.ucsb.edu

nathan

unread,
Jun 13, 2007, 3:48:58 AM6/13/07
to UCSB ECE 15B
The answer is -2. It asks for the decimal value of each field except
for the address field in the J format instruction.

The immediate for the branches is always a number instructions and not
an absolute address.

j.cal

unread,
Jun 13, 2007, 7:37:19 PM6/13/07
to UCSB ECE 15B
this is a typo on the midterm solutions right?

Brett Brotherton

unread,
Jun 13, 2007, 9:27:04 PM6/13/07
to UCSB ECE 15B
Yes it should be -2 on the midterm solution
Reply all
Reply to author
Forward
0 new messages