gpt4 book ai didi

c - 了解 PowerPC rlwinm 指令

转载 作者:太空狗 更新时间:2023-10-29 14:57:15 26 4
gpt4 key购买 nike

所以我终于说服自己尝试学习/使用 PowerPC (PPC)。一切进展顺利,大部分信息都是在网上找到的。但是,在查看一些示例时,我发现了这一点:

rlwinm    r3, r3, 0,1,1

我如何在 C 中执行此操作?我尝试做一些研究,但找不到任何对我有帮助的东西。提前致谢!

最佳答案

rlwinm 代表“Rotate Left Word Immediate then aNd with Mask,正确的用法是

rlwinm  RA, RS, SH, MB, ME

根据 description page :

  • RA Specifies target general-purpose register where result of operation is stored.
  • RS Specifies source general-purpose register for operation.
  • SH Specifies shift value for operation.
  • MB Specifies begin value of mask for operation.
  • ME Specifies end value of mask for operation.
  • BM Specifies value of 32-bit mask.

  • If the MB value is less than the ME value + 1, then the mask bits between and including the starting point and the end point are set to ones. All other bits are set to zeros.
  • If the MB value is the same as the ME value + 1, then all 32 mask bits are set to ones.
  • If the MB value is greater than the ME value + 1, then all of the mask bits between and including the ME value +1 and the MB value -1 are set to zeros. All other bits are set to ones.

因此在您的示例中,源和目标是相同的。移位量是0,所以没有移位。并且 MB=ME=1,因此适用第一种情况,这样掩码变为全零,位号 1 为 1,同时从 MSB=0 开始编号:0x40000000

在C中我们可以这么简单的写

a &= 0x40000000;

假设 a 是 32 位变量。

关于c - 了解 PowerPC rlwinm 指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30896622/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com