cmpeqb

Compare Equal Byte

cmpeqb RA, RS, RB

Compares the contents of bits 56:63 of register RA with each byte in register RB and sets the condition register field BF.

Encoding

Binary Layout
31
0:5
RS
6:10
RA
11:15
RB
16:20
224
21:30
/
31
 
Format X-form
Opcode 0x7C0001C0
Extension Base

Operands

  • RA
    Target GPR
  • RS
    Src A
  • RB
    Src B
  • BF
    Condition Register Field

Example

cmpeqb r4, r3, r5

Registers Altered

CR

Related

More in Base

Reference

Description

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.

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.