assembly - IBM 的 lis 和 ori 指令如何工作?

标签 assembly powerpc instruction-set

我想知道lisori 指令是如何工作的?有描述 IBM description我不太明白。有人可以向我解释这个例子的结果是什么吗:

lis r1, 0x0028      
ori r1, r1, 0x776F  

最佳答案

lis在这里定义 ( http://www-01.ibm.com/support/knowledgecenter/api/content/nl/en-us/ssw_aix_53/com.ibm.aix.aixassem/doc/alangref/fixed_point_load.htm#idx175 )

Extended Mnemonic lis rx, value => Equivalent to addis rx, 0, value. aka Load Immediate Shifted

addis然后定义为:

Calculates an address from a concatenated offset and a base address and loads the result in a general-purpose register.

本页 (http://www.ibm.com/developerworks/library/l-ppc/) 描述了“立即加载”操作:

Conveniently, lis (meaning "load immediate shifted") will load directly into the high 16 bits of the GPR. Then all that's left to do is add in the lower bits.

所以 lis r1, 0x0028addis r1, 0, 0x0028 , 英文:设置寄存器r1内容的高16位到 0x0028。 (并将其他位归零,因为我们将 0x28 << 16 添加到 0 。)

我认为ori的定义很简单:

Logically ORs the lower 16 bits of the contents of a general-purpose register with a 16-bit unsigned integer and stores the result in another general-purpose register.

在您的示例中,ori r1, r1, 0x776F :

英语:获取寄存器 r1 中内容的低 16 位并将它们与 0x776F ( 1110111 01101111 ) 进行或运算,然后将其存储回 r1 中.


所以这两条指令形式 0x0028776F在注册r1 , 不依赖于之前的内容。

addis后低16位为0 , 所以对它们进行 ORing 只是将它们设置为 ori是即时的。

像这样的 2 指令序列(设置高位的特殊指令,然后是 addiori 设置低位)是典型的 RISC ISA,用于构造任意 32 位常量;一个 32 位指令字没有空间容纳整个 32 位立即数。

关于assembly - IBM 的 lis 和 ori 指令如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33316945/

相关文章:

c - 内联汇编中的 "matching constraint"是什么意思?

linux - SMP 中的 CPU 停顿

linux - 在 qemu 中引导 ppc linux 内核

c++ - 在 C++ 中,使用 std::min 或 if 分支来限制值是否更好?

assembly - x86 汇编代码的语法

optimization - 取消的分支与常规分支有何不同?

assembly 线困惑 $lea 0xffffffe8(%ebp)$

linux - 如何在Linux-Assembler中发出提示音?

operating-system - 操作系统权限级别与硬件权限级别

c++ - 转译为 C 与 C++ : range of CPU instructions