UD2

Undefined Instruction

Opcodes

Hex Mnemonic Encoding Long Mode Legacy Mode Description
0F 0B UD2 A Valid Valid Raise invalid opcode exception.

Instruction Operand Encoding

Op/En Operand 0 Operand 1 Operand 2 Operand 3
A NA NA NA NA

Description

Generates an invalid opcode exception. This instruction is provided for software testing to explicitly generate an invalid opcode exception. The opcode for this instruction is reserved for this purpose.

Other than raising the invalid opcode exception, this instruction has no effect on processor state or memory.

Even though it is the execution of the UD2 instruction that causes the invalid opcode exception, the instruction pointer saved by delivery of the exception references the UD2 instruction (and not the following instruction).

This instruction's operation is the same in non-64-bit modes and 64-bit mode.

Pseudo Code

#UD (* Generates invalid opcode exception *);

Flags Affected

None.

Exceptions

64-Bit Mode Exceptions

Exception Description
#UD Raises an invalid opcode exception in all operating modes.

Compatibility Mode Exceptions

Exception Description
#UD Raises an invalid opcode exception in all operating modes.

Virtual-8086 Mode Exceptions

Exception Description
#UD Raises an invalid opcode exception in all operating modes.

Real-Address Mode Exceptions

Exception Description
#UD Raises an invalid opcode exception in all operating modes.

Protected Mode Exceptions

Exception Description
#UD Raises an invalid opcode exception in all operating modes.