cmpb

Compare Bytes

cmpb RA, RS, RB

Compares bytes in two GPRs, result is byte mask.

Details

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.

Pseudocode 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.

Example

cmpb r4, r3, r5

Encoding

Binary Layout
31
0
RS
6
RA
11
RB
16
508
21
/
31
 
Format X-form
Opcode 0x7C0003F8
Extension Base

Operands

  • RA
    Target GPR
  • RS
    Src A
  • RB
    Src B