I am relatively new to assembly and PowerPC assembly in particular, so please bear with me on this question. I have looked around but haven't really found an accurate answer as to how exactly values are compared when appending a dot to an instruction, such as this:
clrlwi. r0, r0, 29 # clear left word immediate
Does this compare the original value of r0
with the value calculated after clearing the bits, or is it the equivalent of something like if (variable)
in a programming language? On this page, all it says is that appending a dot is the equivalent of
cmpwi rD, 0
But it's unclear to me what exactly this compares the register to because their syntax doesn't exactly show if a value is a register number or an immediate integer...
The dot means that the CR0
flags (bits 0..3 of CR
) will be updated based on the result of the instruction.
cr0
is used for the results of fixed-point computation instructions, which use non-immediate operands (with a few exceptions). The result of the computation is compared with zero, and the appropriate bits are set (negative, zero, or positive).
To indicate in a computational instruction that you want it to setcr0
, you simply add a period (.
) to the end of the instruction. For example,add 4, 5, 6
adds register 5 to register 6 and stores the result in register 4, without setting any status bits incr0
. However,add. 4, 5, 6
does the same thing, but sets the bits incr0
based on the computed value.
CR0
bits:
0: Negative (LT) - This bit is set when the result is negative
1: Positive (GT) - This bit is set when the result is positive (and not zero)
2: Zero (EQ) - This bit is set when the result is zero
3: Summary overflow (SO) - This is a copy of the final state of XER[SO] at completion of the instruction