Range of immediates in lui instruction

﹥>﹥吖頭↗ 提交于 2019-12-13 04:03:33

问题


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:


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



来源:https://stackoverflow.com/questions/53467887/range-of-immediates-in-lui-instruction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!