Lui指令的立即数范围 [英] Range of immediates in lui instruction
问题描述
我不确定lui
指令中立即数的范围是什么.
I'm not sure what is the range bound for the immediate in lui
instruction.
我组装时:
lui $t0,32768
它成功运行,没有错误.
It successfully went without errors.
但是,
lui $t0,-32768
通知-32768超出范围.
notified that -32768 out of range.
推荐答案
在MIPS中,I型指令的立即数始终为16位长.这意味着如果汇编器将其视为未签名,则范围将为[0,65535],对于已签名的情况将范围为[-32768,32767]
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
例如,某些汇编程序,例如 shell-storm 和 WeMips 接受[-32768,65535]中的常量,这是两个16-位签名和未签名, MIPS转换器仅接受十六进制值,但 WebMIPSASM 甚至接受9223372036854775807之类的巨大值并将结果截断为16位
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
这篇关于Lui指令的立即数范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!