cmp $dest, $src1, $src2
Perform a comparison of two twos complement operand registers, and stores the result in register $dest.
Format
This is a RR format instrucion.
31 - 26 |
25 - 21 |
20 - 16 |
15 - 11 |
10 - 0 |
011100 |
dest |
src1 |
src2 |
00000000000 |
Functional Description
The cmp instruction compares two operands stored in register src1 and
src2. The operands are interpreted as twos complement signed integers. Based on
this comparison, the lowermost three bits of register dest are set, and
the remaining bits in the register are set to 0. The lowermost bits
are EQ(bit 0), LT (bit 1) and GT(bit 2). If registers src1 and src2 are
equal, the EQ bit is set to 1, otherwise 0. If register src1 is less than
src2, the LT bit is set to 1, otherwise the LT bit is set to zero. If
register src1 is greater than src2, the GT bit is set to 1, otherwise the GT
bit is set to 0.
if(src1 == src2) dest[0] = 1;
else dest[0] = 0;
if(src1 < src2) dest[1] = 1;
else dest[1] = 0;
if(src1 > src2) dest[2] = 1;
else dest[2] = 0;
dest[31:3] = 0;
Side Effects
None
Processor Mode
This is a user-level instruction.
Last modified: Sun Feb 25 12:46:53 CST 2001