cmpb

Compare Bytes

cmpb RA, RS, RB

Compares bytes in two GPRs, result is byte mask.

Details

The cmpb instruction compares each byte of the contents of register RS to the corresponding byte in register RB. If the bytes are equal, the corresponding byte in RA is set to 0xFF; otherwise, it is set to 0x00.

Pseudocode Operation

do n = 0 to 7
    if RS8×n:8×n+7 = (RB)8×n:8×n+7 then
        RA8×n:8×n+7 ←81
    else
        RA8×n:8×n+7 ←80

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