Range of immediates in lui instruction

2019-08-28 00:30发布

I'm not sure what is the range bound for the immediate in lui instruction.

When I assemble:

lui $t0,32768

It successfully went without errors.

However,

lui $t0,-32768 

notified that -32768 out of range.

1条回答
Summer. ? 凉城
2楼-- · 2019-08-28 01:00

In MIPS the immediate in I-type instructions is always 16-bit long. That means the range will be [0, 65535] if the assembler treats it as unsigned, and [-32768, 32767] for the signed case

However what you can use in the assembly depends on the assembler

For example some assemblers like shell-storm and WeMips accept constants in [-32768, 65535] which is a mix of both 16-bit signed and unsigned, MIPS Converter only accepts hexadecimal values but WebMIPSASM accepts even huge values like 9223372036854775807 and truncate the result to 16 bits

查看更多
登录 后发表回答