与PowerPC寄存器的值混淆吗?

问题描述:

因此,我一直在学习PowerPC以便为Xbox进行简单的可逆项目,但是我总是会纠结于这样的事情.

So, I've been going along learning PowerPC for simple reversing projects for Xbox, but I always get tangled up on things like this.

    lwz       r11, 0(r29)   # Loads 0x34 from 0x10710 and stores in r11
    lwz       r10, 4(r29)   # Loads 0x64 from 0x10714 and stores in r10
    addi      r11, r11, 0x7F # r11 = 0x34 + 0x7F = r11 = 0xE3
    clrrwi    r10, r10, 7   # r10 = r10 (0x64) + 0xFFFFFF80
    clrrwi    r31, r11, 7   # r31 = r11 (0xE3) & 0xFFFFFF80

无论如何,我很难理解的是最后两行.寄存器如何具有一个值+另一个值?另一个寄存器怎么会有一个值&amp ;?其他?如果我要将加法作为下一行,那么我将增加什么值?抱歉,这是一个奇怪的过渡,因为我的母语是C ++和C#,尽管有很多麻烦,但我不想放弃它,因为它非常有趣.

Anyways, what I'm having trouble understanding is the last two lines. How could a register have one value + another? And how could another register have one value & another? And if I were to have addition as the next line, what value would I add to? Sorry, this is a weird transition since my native languages are C++ and C# and I don't feel like giving up on this one as it's so much fun despite the troubles I'm having.

我不理解注释#r10 = r10(0x64)+ 0xFFFFFF80"中的"+",可能是拼写错误.但是我了解下一行的注释,#r31 = r11(0xE3)& 0xFFFFFF80".

I don’t understand the ‘+’ in the comment "# r10 = r10 (0x64) + 0xFFFFFF80", and it could be a typo. But I understand the comment on the next line, "# r31 = r11 (0xE3) & 0xFFFFFF80".

如果您查看 PowerPC 2.02 Book 1文档对于立即旋转左单词然后与蒙版M格式进行并运算",它显示了对clrrwi实际执行的操作.

If you look at the PowerPC 2.02 Book 1 documentation for 'Rotate Left Word Immediate then AND with Mask M-form’, it shows what is actually done for clrrwi.

clrrwi Rx,Ry,n

clrrwi Rx,Ry,n

等效于

rlwinm Rx,Ry,0,0,31-n

rlwinm Rx,Ry,0,0,31-n

对于clrrwi,rlwinm会将单词0位左移,因此clrrwi指令不会进行旋转.它会生成一个掩码,其掩码在0-24位中为1,在其他位置为零(25-31位)中为零,因此,对于n = 7生成的掩码为0xFFFFFF80.旋转的数据与生成的掩码进行与"运算,因此这是第二个clrrwi的注释有意义的原因. clrrwi正在生成一个掩码来清除一个单词中的右n位,而0xFFFFFF80是用于清除的掩码.

For clrrwi, rlwinm rotates left the word 0 bits, so there is no rotate done for clrrwi instructions. It generates a mask with 1’s in bits 0-24 and zero elsewhere (bits 25-31), so the mask generated for n=7 is 0xFFFFFF80. The rotated data are ANDed with the generated mask, so this is the reason that the comment for the second clrrwi makes sense. clrrwi is generating a mask to clear the right n bits in a word, and 0xFFFFFF80 is the mask used to do the clear.

顺便说一下,0x34 + 0x7F = 0xB3.

By the way, 0x34+0x7F=0xB3.