Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is the range of instruction addresses to which conditional branches, such as beq and bne can branch in MIPS ?

  • A.+/- \(2^{17}\)
  • B.+/- \(2^{16}\)
  • C.+/- \(2^{32}\)
  • D.+/- \(2^{8}\)

Answer: A

The range is +/- \(2^{17}\) bytes.

MIPS beq and bne are I-type instructions with a 16-bit signed immediate. The offset counts words (instructions), not bytes, and is added to PC + 4 after being shifted left by 2. A 16-bit signed field spans about \(\pm 2^{15}\) words, and since each word is 4 bytes:

\[ \pm 2^{15} \times 2^{2} = \pm 2^{17} \text{ bytes} \]

\(\pm 2^{16}\) would ignore either the sign bit or the word scaling, \(2^{32}\) is the whole address space, and \(2^{8}\) is far too small for a 16-bit field.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.