加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

了解PowerPC rlwinm指令

发布时间:2020-12-16 09:58:19 所属栏目:百科 来源:网络整理
导读:所以我终于说服自己尝试学习/使用PowerPC(PPC). 一切进展顺利,大多数信息都是在网上找到的. 但是,在查看一些示例时,我发现了这个: rlwinm r3,r3,1,1 我怎么用C做这个? 我尝试做一些研究,但找不到任何帮助我的东西. 提前致谢! 解决方法 rlwinm代表“立即旋
所以我终于说服自己尝试学习/使用PowerPC(PPC).
一切进展顺利,大多数信息都是在网上找到的.
但是,在查看一些示例时,我发现了这个:

rlwinm    r3,r3,1,1

我怎么用C做这个?
我尝试做一些研究,但找不到任何帮助我的东西.
提前致谢!

解决方法

rlwinm代表“立即旋转左字然后使用蒙版aNd,它的正确用法是

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,因此第一种情况适用,使得掩码变为全为0,位号1为1,而编号从MSB = 0:0x40000000.

在C中我们可以像写一样简单

a &= 0x40000000;

假设a是32位变量.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读