cmpeqb
Compare Equal Byte
Compares the contents of bits 56:63 of register RA with each byte in register RB and sets the condition register field BF.
Details
Compares the least significant byte of register RS (bits 56:63) against each of the eight bytes in register RB, setting a byte in register RA to 0xFF where a match occurs and 0x00 where no match occurs. The instruction does not update condition registers directly but produces a byte-mask result in RA.
Pseudocode Operation
search_byte ← RS[56:63]
for i in 0 to 7 do
if RB[i*8:i*8+7] = search_byte then
RA[i*8:i*8+7] ← 0xFF
else
RA[i*8:i*8+7] ← 0x00
end
end
Programming Note
cmpeqb is useful for implementing character typing functions such as isspace() that are implemented by comparing the character to 1 or more values. A function such as isspace() can be implemented by loading the 6 byte codes corresponding to characters considered as whitespace (HT, LF, VT, FF, CR, and SP) and using the cmpeqb to compare the subject character to those 6 values to determine if any match occurs.
Example
Encoding
Operands
-
RA
Target GPR -
RS
Src A -
RB
Src B -
BF
Condition Register Field