What does the PowerPC instruction cmplw
mean and how do i reverse it here is the line.
cmplw cr6, r31, r10 ----------- r31 = 80 and r10 = 0
Please give me a quick tut on how to reverse this instruction :)
The contents of register r31 and r10 are compared to determine whether they are greater than, less than, equal, or whether there is a summary overflow condition, and the result is placed into the condition register (CR) field 6. The CR field bits are set according to 3.3.9 Fixed-Point Compare Instructions in the PowerPC User ISA Book 1. The CR field in this example is 6 and those fields are numbered such that field 0 is bits 0-3, field 1 is 4-7, and so on. So CR field 6 is bits 24-27 of the condition register, and that is where you'll find the result of greater than, less than, etc.
A CR field is used most commonly by a branch instruction (like bne, beq, blt, etc) to make a flow decision. Without the next related instructions that make a decision based on the CR field, it's hard to write code in C to illustrate what this instruction does. I would say the best estimate of C code for it is something like "r31 == r10", "r31 >= r10", "r31 < r10", and so on, where I can't determine the comparison operator. I also can't determine whether it is "if", "switch", or which conditional operation it would be based on the current information. It all depends on the next related instructions which use the contents of the CR field 6. If the next related instruction were a beq on CR6 then I would expect the C code could be a conditional like "if (r31==r10)". There are many possibilities.