Comparison Instructions


The table below lists some comparison instructions. They are with the R-type format except slti and sltiu, which are with the I-type format.

These instructions perform a comparison rs op rt, where op is the comparison contained in the op-code of the instruction (eq—equal, ne—not equal, lt—less than, etc.), and sets the value of rd to 1 if the comparison is TRUE, and to 0 if FALSE. Most commonly, these are used in conjunction with the conditional branch instructions to make decisions.
Instruction Description
seq rd, rs, rt Set equal
sne rd, rs, rt Set not equal
slt rd, rs, rt Set less
sltu rd, rs, rt Set less unsigned
slti rd, rs, imm Set less immediate
sltiu rd, rs, imm Set less immediate unsigned
sle rd, rs, rt Set less or equal
sleu rd, rs, rt Set less or equal unsigned
sgt rd, rs, rt Set greater
sgtu rd, rs, rt Set greater unsigned
sge rd, rs, rt Set greater or equal
sgeu rd, rs, rt Set greater or equal unsigned
seq rd, rs, rt         # set equal
Compares two 32-bit values. If the contents of rs equal the contents of rt (or rs equals the immediate value) it sets the destination register to one; otherwise, it sets the destination register to zero.

sne rd, rs, rt         # set not equal
Compares two 32-bit values. If the contents of rs are not equal to the contents of rt (or rs is not equal to the immediate value), it sets the destination to one; otherwise, it sets the destination to zero.

slt rd, rs, rt         # set less
Compares two signed 32-bit values. If the contents of rs are less than the contents of rt (or rs is less than the immediate value), this instruction sets the destination register to 1; otherwise, it sets the destination register to 0.



      My mother is back on her feet after being sick for two weeks.