SETcc

Set Byte on Condition

OpcodeInstructionOp/En64-Bit ModeCompat/Leg ModeDescription
0F 97SETA r/m8MValidValidSet byte if above (CF=0 and ZF=0).
REX + 0F 97SETA r/m81MValidN.E.Set byte if above (CF=0 and ZF=0).
0F 93SETAE r/m8MValidValidSet byte if above or equal (CF=0).
REX + 0F 93SETAE r/m81MValidN.E.Set byte if above or equal (CF=0).
0F 92SETB r/m8MValidValidSet byte if below (CF=1).
REX + 0F 92SETB r/m81MValidN.E.Set byte if below (CF=1).
0F 96SETBE r/m8MValidValidSet byte if below or equal (CF=1 or ZF=1).
REX + 0F 96SETBE r/m81MValidN.E.Set byte if below or equal (CF=1 or ZF=1).
0F 92SETC r/m8MValidValidSet byte if carry (CF=1).
REX + 0F 92SETC r/m81MValidN.E.Set byte if carry (CF=1).
0F 94SETE r/m8MValidValidSet byte if equal (ZF=1).
REX + 0F 94SETE r/m81MValidN.E.Set byte if equal (ZF=1).
0F 9FSETG r/m8MValidValidSet byte if greater (ZF=0 and SF=OF).
REX + 0F 9FSETG r/m81MValidN.E.Set byte if greater (ZF=0 and SF=OF).
0F 9DSETGE r/m8MValidValidSet byte if greater or equal (SF=OF).
REX + 0F 9DSETGE r/m81MValidN.E.Set byte if greater or equal (SF=OF).
0F 9CSETL r/m8MValidValidSet byte if less (SF≠ OF).
REX + 0F 9CSETL r/m81MValidN.E.Set byte if less (SF≠ OF).
0F 9ESETLE r/m8MValidValidSet byte if less or equal (ZF=1 or SF≠ OF).
REX + 0F 9ESETLE r/m81MValidN.E.Set byte if less or equal (ZF=1 or SF≠ OF).
0F 96SETNA r/m8MValidValidSet byte if not above (CF=1 or ZF=1).
REX + 0F 96SETNA r/m81MValidN.E.Set byte if not above (CF=1 or ZF=1).
0F 92SETNAE r/m8MValidValidSet byte if not above or equal (CF=1).
REX + 0F 92SETNAE r/m81MValidN.E.Set byte if not above or equal (CF=1).
0F 93SETNB r/m8MValidValidSet byte if not below (CF=0).
REX + 0F 93SETNB r/m81MValidN.E.Set byte if not below (CF=0).
0F 97SETNBE r/m8MValidValidSet byte if not below or equal (CF=0 and ZF=0).
REX + 0F 97SETNBE r/m81MValidN.E.Set byte if not below or equal (CF=0 and ZF=0).
0F 93SETNC r/m8MValidValidSet byte if not carry (CF=0).
REX + 0F 93SETNC r/m81MValidN.E.Set byte if not carry (CF=0).
0F 95SETNE r/m8MValidValidSet byte if not equal (ZF=0).
REX + 0F 95SETNE r/m81MValidN.E.Set byte if not equal (ZF=0).
0F 9ESETNG r/m8MValidValidSet byte if not greater (ZF=1 or SF≠ OF)
REX + 0F 9ESETNG r/m81MValidN.E.Set byte if not greater (ZF=1 or SF≠ OF).
0F 9CSETNGE r/m8MValidValidSet byte if not greater or equal (SF≠ OF).
REX + 0F 9CSETNGE r/m81MValidN.E.Set byte if not greater or equal (SF≠ OF).
0F 9DSETNL r/m8MValidValidSet byte if not less (SF=OF).
REX + 0F 9DSETNL r/m81MValidN.E.Set byte if not less (SF=OF).
0F 9FSETNLE r/m8MValidValidSet byte if not less or equal (ZF=0 and SF=OF).
REX + 0F 9FSETNLE r/m81MValidN.E.Set byte if not less or equal (ZF=0 and SF=OF).
0F 91SETNO r/m8MValidValidSet byte if not overflow (OF=0).
REX + 0F 91SETNO r/m81MValidN.E.Set byte if not overflow (OF=0).
0F 9BSETNP r/m8MValidValidSet byte if not parity (PF=0).
REX + 0F 9BSETNP r/m81MValidN.E.Set byte if not parity (PF=0).
0F 99SETNS r/m8MValidValidSet byte if not sign (SF=0).
REX + 0F 99SETNS r/m81MValidN.E.Set byte if not sign (SF=0).
0F 95SETNZ r/m8MValidValidSet byte if not zero (ZF=0).
REX + 0F 95SETNZ r/m81MValidN.E.Set byte if not zero (ZF=0).
0F 90SETO r/m8MValidValidSet byte if overflow (OF=1)
REX + 0F 90SETO r/m81MValidN.E.Set byte if overflow (OF=1).
0F 9ASETP r/m8MValidValidSet byte if parity (PF=1).
REX + 0F 9ASETP r/m81MValidN.E.Set byte if parity (PF=1).
0F 9ASETPE r/m8MValidValidSet byte if parity even (PF=1).
REX + 0F 9ASETPE r/m81MValidN.E.Set byte if parity even (PF=1).
0F 9BSETPO r/m8MValidValidSet byte if parity odd (PF=0).
REX + 0F 9BSETPO r/m81MValidN.E.Set byte if parity odd (PF=0).
0F 98SETS r/m8MValidValidSet byte if sign (SF=1).
REX + 0F 98SETS r/m81MValidN.E.Set byte if sign (SF=1).
0F 94SETZ r/m8MValidValidSet byte if zero (ZF=1).
REX + 0F 94SETZ r/m81MValidN.E.Set byte if zero (ZF=1).
  1. In 64-bit mode, r/m8 can not be encoded to access the following byte registers if a REX prefix is used: AH, BH, CH, DH.

Instruction Operand Encoding

Op/EnOperand 1Operand 2Operand 3Operand 4
MModRM:r/m (w)N/AN/AN/A

Description

Sets the destination operand to 0 or 1 depending on the settings of the status flags (CF, SF, OF, ZF, and PF) in the EFLAGS register. The destination operand points to a byte register or a byte in memory. The condition code suffix (cc) indicates the condition being tested for.

The terms “above” and “below” are associated with the CF flag and refer to the relationship between two unsigned integer values. The terms “greater” and “less” are associated with the SF and OF flags and refer to the relationship between two signed integer values.

Many of the SETcc instruction opcodes have alternate mnemonics. For example, SETG (set byte if greater) and SETNLE (set if not less or equal) have the same opcode and test for the same condition: ZF equals 0 and SF equals OF. These alternate mnemonics are provided to make code more intelligible. Appendix B, “EFLAGS Condition Codes,” in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1, shows the alternate mnemonics for various test conditions.

Some languages represent a logical one as an integer with all bits set. This representation can be obtained by choosing the logically opposite condition for the SETcc instruction, then decrementing the result. For example, to test for overflow, use the SETNO instruction, then decrement the result.

The reg field of the ModR/M byte is not used for the SETCC instruction and those opcode bits are ignored by the processor.

In IA-64 mode, the operand size is fixed at 8 bits. Use of REX prefix enable uniform addressing to additional byte registers. Otherwise, this instruction’s operation is the same as in legacy mode and compatibility mode.

Operation

IF condition
    THEN DEST := 1;
    ELSE DEST := 0;
FI;

Flags Affected

None.

Protected Mode Exceptions

#​​​​GP(0)If the destination is located in a non-writable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
If the DS, ES, FS, or GS register contains a NULL segment selector.
#​​​​​SS(0)If a memory operand effective address is outside the SS segment limit.
#​PF(fault-code)If a page fault occurs.
#​​​UDIf the LOCK prefix is used.

Real-Address Mode Exceptions

#​​​​GPIf a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
#​​​​​SSIf a memory operand effective address is outside the SS segment limit.
#​​​UDIf the LOCK prefix is used.

Virtual-8086 Mode Exceptions

#​​​​GP(0)If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
#​​​​​SS(0)If a memory operand effective address is outside the SS segment limit.
#​PF(fault-code)If a page fault occurs.
#​​​UDIf the LOCK prefix is used.

Compatibility Mode Exceptions

Same exceptions as in protected mode.

64-Bit Mode Exceptions

#​​​​​SS(0)If a memory address referencing the SS segment is in a non-canonical form.
#​​​​GP(0)If the memory address is in a non-canonical form.
#​PF(fault-code)If a page fault occurs.
#​​​UDIf the LOCK prefix is used.

This UNOFFICIAL, mechanically-separated, non-verified reference is provided for convenience, but it may be incomplete or broken in various obvious or non-obvious ways. Refer to Intel® 64 and IA-32 Architectures Software Developer’s Manual for anything serious.