AESKEYGENASSIST: AES Round Key Generation Assist

For information about interpreting this page, see the help page.
Opcode and MnemonicEncoding16 bit Mode32 bit Mode64 bit ModeCPUID Feature FlagDescription
66 0F 3A DF /r ib
AESKEYGENASSIST xmm1, xmm2/m128, imm8
RMIInvalidValidValidAESAssist in AES round key generation using an 8 bit round constant (RCON) specified in the immediate byte and 128 bits of data specified in xmm2/m128. Stores the result in xmm1.
VEX.128.66.0F3A.WIG DF /r ib
VAESKEYGENASSIST xmm1, xmm2/m128, imm8
RMIInvalidValidValidAES
AVX
Assist in AES round key generation using an 8 bit round constant (RCON) specified in the immediate byte and 128 bits of data specified in xmm2/m128. Stores the result in xmm1.

Encoding

EncodingOperand 1Operand 2Operand 3
RMIModRM.reg[w]ModRM.r/m[r]imm8

Description

The (V)AESKEYGENASSIST instruction assists in expanding the AES cipher key using an 8 bit round constant (RCON) and 128 bits of data from the source operand. The result is stored in the destination operand.

The VEX form of this instruction reserves VEX.vvvv (i.e. it must be set to 0b1111). Failure to do so will result in a #UD exception.

Operation

This pseudo-code uses C# syntax. A list of the types used is available here.
public void AESKEYGENASSIST(SimdU32 dest, SimdU32 src, byte roundConstant)
{
  uint x0 = src[0];
  uint x1 = src[1];
  uint x2 = src[2];
  uint x3 = src[3];
  uint rcon = roundConstant;

  dest[0] = SubWord(x1);
  dest[1] = RotWord(SubWord(x1)) ^ rcon;
  dest[2] = SubWord(x3);
  dest[3] = RotWord(SubWord(x3)) ^ rcon;
  // dest[4..Simd.MAX] (unmodified)
}

public void VAESKEYGENASSIST_Vex128(SimdU32 dest, SimdU32 src, byte roundConstant)
{
  uint x0 = src[0];
  uint x1 = src[1];
  uint x2 = src[2];
  uint x3 = src[3];
  uint rcon = roundConstant;

  dest[0] = SubWord(x1);
  dest[1] = RotWord(SubWord(x1)) ^ rcon;
  dest[2] = SubWord(x3);
  dest[3] = RotWord(SubWord(x3)) ^ rcon;
  dest[4..Simd.MAX] = 0;
}

C Intrinsics

Exceptions

SIMD Floating-Point

None

Other

See Exceptions Type 4.

#UD
If VEX.vvvv is not 0b1111.