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.

Details

The cmpeqb instruction compares the high-order byte (bits 56:63) of the source general-purpose register RA with each of the eight bytes in the source general-purpose register RB. If any match is found, the corresponding condition register field BF is set to indicate a match.

Pseudocode Operation

src1 ← GPR[RA].bit[56:63]
match ← (src1 = (RB)00:07) |
         (src1 = (RB)08:15) |
         (src1 = (RB)16:23) |
         (src1 = (RB)24:31) |
         (src1 = (RB)32:39) |
         (src1 = (RB)40:47) |
         (src1 = (RB)48:55) |
         (src1 = (RB)56:63)
CR4×BF+32:4×BF+35 ← 0b0 || match || 0b00

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

cmpeqb r4, r3, r5

Encoding

Binary Layout
31
0
RS
6
RA
9
RB
11
224
16
/
 
Format X-form
Opcode 0x7C0000E0
Extension Base
Registers Altered CR

Operands

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