4.6.1 Compare Byte
Format:
CMPBGE | Ra.rq,Rb.rq,Rc.wq | !Operate format |
CMPBGE | Ra.rq,#b.ib,Rc.wq | !Operate format |
Operation:
FOR i FROM 0 TO 7
temp<8:0> ← 0 Rav<i*8+7:i*8>} + {0 NOT Rbv<i*8+7:i*8>} + 1 Rc<i> ← temp<8>
END
Rc<63:8> ← 0
Exceptions:
None
Instruction mnemonics:
CMPBGE | Compare Byte |
Qualifiers:
None
Description:
CMPBGE does eight parallel unsigned byte comparisons between corresponding bytes of Rav and Rbv, storing the eight results in the low eight bits of Rc. The high 56 bits of Rc are set to zero. Bit 0 of Rc corresponds to byte 0, bit 1 of Rc corresponds to byte 1, and so forth. A result bit is set in Rc if the corresponding byte of Rav is greater than or equal to Rbv (unsigned).
Notes:
The result of CMPBGE can be used as an input to ZAP and ZAPNOT.
To scan for a byte of zeros in a character string:
<initialize R1 to aligned QW address of string> LOOP:
LDQ | R2, | 0(R1) | ; Pick up 8 bytes |
LDA | R1, | 8(R1) | ; Increment string pointer |
CMPBGE | R31, | R2,R3 | ; If NO bytes of zero, R3<7:0>=0 |
BEQ | R3, | LOOP | ; Loop if no terminator byte found |
... |
|
| ; At this point, R3 can be used to |
|
|
| ; determine which byte terminated |
Instruction Descriptions