我正在尝试加载 32 位常量 0x1234ABCD 以在 MIPS 程序集中注册 $t0
。但是,我无法使用 lui
来执行此操作。我的直觉是使用两个 addi
,但我不知道该怎么做。我必然需要 2 位或更多位才能获取 32 位信息。我需要在没有 lui
的情况下以某种方式设置高位。在不使用 lui
的情况下复制它的好方法是什么?
最佳答案
例如,您可以使用 ori
与 sll
结合使用,在 3 条指令中加载 32 位常量,而无需使用 lui
:
ori $t1, $zero, 0x1234 # load the upper half in the lower bits of $t1
sll $t1, $t1, 16 # move them to the upper half
ori $t1, $t1, 0xABCD # combine with the lower half
关于assembly - 如何在不使用 LUI 的情况下将 32 位常量加载到寄存器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67909301/