cmpb
Compare Bytes
cmpb RA, RS, RB
Compares bytes in two GPRs, result is byte mask.
Encoding
Binary Layout
31
0:5
RS
6:10
RA
11:15
RB
16:20
508
21:30
/
31
Operands
-
RA
Target GPR -
RS
Src A -
RB
Src B
Example
cmpb r4, r3, r5
Related
More in Base
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
Compares each byte of register RS with the corresponding byte in register RB and stores a byte-mask result in register RA. For each byte, 0xFF is written to RA if the bytes are equal, and 0x00 is written if they differ. No condition register fields are updated.
Operation
for i in 0 to 7 do
if RS[i*8:i*8+7] = RB[i*8:i*8+7] then
RA[i*8:i*8+7] ← 0xFF
else
RA[i*8:i*8+7] ← 0x00
end
end
Programming Note
The cmpb instruction is useful for performing byte-wise comparisons between two registers. Ensure that the input registers (RS and RB) are properly aligned to avoid unexpected results. The output register (RA) will contain 0xFF in bytes where the comparison was equal, and 0x00 elsewhere. This instruction operates at user privilege level.