Computer Architecture (컴퓨터구조)

MIPS(I-type) immediate 값 범위 정리(주의!)

9taetae9 2023. 9. 23. 14:51
728x90

  In the MIPS instruction set architecture, the immediate value in I-format instructions is typically considered a signed 16-bit number. This means that the immediate value can range from 
대부분의 I-format 명령어들의 imm 값은 아래와 같은 signed 16-bit number이다.
 (-2^15) ~ (2^15-1) or -32,768 to 32,767 in decimal notation. 

 

For certain instructions, like addi, the immediate value is treated as a two's complement signed number. In such cases, if you provide a negative immediate value, it will be represented in two's complement form in the instruction encoding.

 

그러나 andi, ori, xori 등의 명령어는 예외적으로 unsigned value(즉 0~2^16-1)의 범위로 취급한다. (주의!)

However, for other I-format instructions like andi, ori, and xori, the immediate is treated as an unsigned value. This distinction is important when considering the operation being performed and how the immediate value is used.

So, while the immediate field is always 16 bits and often treated as signed, whether it's interpreted as signed or unsigned depends on the specific instruction.

728x90