Question

Consider the following MIPS instruction: 1. Loop:    add $t1, $s1, $s2 2.          or...

  1. Consider the following MIPS instruction:

1. Loop:    add $t1, $s1, $s2

2.          or $s2, $s5, $s6

3.          bne $s2, $t8, Loop

4.          nop

Re-write the third instruction (bne) in binary.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Consider the following MIPS instruction:

Loop: add $t1, $s1, $s2

or $s2, $s5, $s6

bne $s2, $t8, Loop

nop

Re-writing Bne instruction in Binary:

Let's assume that Loop subroutine start at address 0x1000. So, writing instruction with addresses:

Loop: add St1, Ss1, Ss2 1000: 1004 1008: 100C: or Ss2, Ss5, Ss6 bne Ss2, St8, Loop nop

Instruction Format:

BNE - Branch on Not Equal

bne rs, rt, offset [I-type instruction]

Branch to specified offset if (rs != rt)

Given bne $s2, $t8, Loop: Branch to Loop if ($s2 != $t8)

Converting Given instruction bne to Binary:

31 26 25 21 20 16 15 Ss2 10010 St8 11000 Offset: Loop BNE 000101 6 bits 0001000000000000 5 bits 5bits 16 bits

Machine code for each field:

BNE: 000101 (6 bits)

$s2: 10010 (5 bits) ($s2 = $18 decimal value)

$t8: 11000 (5 bits) ($t8 = $24 decimal value)

Loop: 0001000000000000 (16 bits) (We have assume that Loop is at address 0x1000)

Binary of BNE instruction: bne $s2, $t8, Loop

Binary: 00010110010110000001000000000000

Hex: 0x16581000

Add a comment
Know the answer?
Add Answer to:
Consider the following MIPS instruction: 1. Loop:    add $t1, $s1, $s2 2.          or...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT