Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 如何在不使用LUI的情况下将32位常量加载到寄存器_Assembly_Mips - Fatal编程技术网

Assembly 如何在不使用LUI的情况下将32位常量加载到寄存器

Assembly 如何在不使用LUI的情况下将32位常量加载到寄存器,assembly,mips,Assembly,Mips,我正在尝试加载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 $

我正在尝试加载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

通常,我们会执行lui$t0 0x1234
ori$t0,0xABCD
。如何在不加载高位立即数的情况下加载高位?是否查看了指令集?你不理解文档的哪一部分?要有想象力:我们可以对较小的常数使用加法、减法、移位、乘法来获得较大的常数。@ErikEidt我不知道这有多强大。谢谢这很有效,谢谢!另一种说法是,可以使用
ori
/
sll
-by-16精确模拟
lui
。或者使用
addiu
,因为您要移出高半部,所以从哪里得到零或符号扩展到高半部并不重要。