enter image description here

The above picture is an I-type format register. I am confused as to why the largest constant possible is $$2^{15}$$ Should the largest possible constant be $$2^{16} -1$$

  • 1
    \$\begingroup\$ Please can you edit your question and greatly improve it by details such as the CPU you're using and why. The better the quality of your question, the better the quality of the answers you will attract. \$\endgroup\$ – TonyM Mar 5 '18 at 22:39
  • \$\begingroup\$ Just guessing: This might be a MIPS instruction. In that case, it's 2¹⁵-1 because the value is sign-extended, not zero-extended. (It is treated as a signed 16-bit integer) \$\endgroup\$ – Jonathan S. Mar 5 '18 at 22:47
  • \$\begingroup\$ Yes, its a MIPS instruction \$\endgroup\$ – user3067059 Mar 5 '18 at 23:20

In the MIPS architecture, the immediate field of I-type instructions is a signed 16-bit value in two's complement. One of those 16 bits is the sign bit, the other 15 remain for the magnitude.

Therefore, the range is -2^15 (-32768) to 2^15-1 (32767); that's still 2^16 different values in total.

  • \$\begingroup\$ why is the max positive 1 less than max negative? \$\endgroup\$ – user3067059 Mar 5 '18 at 23:34
  • \$\begingroup\$ @user3067059 That's because of two's complement. Instead of having both a positive and a negative zero (which would be a waste and complicate computations), there's only one zero. That frees up a bit pattern for an additional number, in this case another negative one. There are other representations of signed numbers that handle this differently, but MIPS chose two's complement. \$\endgroup\$ – Jonathan S. Mar 5 '18 at 23:40
  • \$\begingroup\$ Zero does not have a -ve sign so they are equal. \$\endgroup\$ – Sunnyskyguy EE75 Mar 5 '18 at 23:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.