From 2d2e1acf279f2428925f6d5e65986295d93b1e4d Mon Sep 17 00:00:00 2001 From: flobernd Date: Sun, 18 Jun 2017 22:02:59 +0200 Subject: [PATCH] Added T1_4X tuple-type --- include/Zydis/InstructionInfo.h | 6 +++- .../Zydis/Internal/InstructionDefinitions.inc | 28 +++++++++---------- src/Decoder.c | 9 ++++++ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/include/Zydis/InstructionInfo.h b/include/Zydis/InstructionInfo.h index 73a98a0..4852c71 100644 --- a/include/Zydis/InstructionInfo.h +++ b/include/Zydis/InstructionInfo.h @@ -785,7 +785,11 @@ enum ZydisTupleTypes /** * @brief MOVDDUP */ - ZYDIS_TUPLETYPE_DUP + ZYDIS_TUPLETYPE_DUP, + /** + * @brief Tuple1 4x32 + */ + ZYDIS_TUPLETYPE_T1_4X }; /* ---------------------------------------------------------------------------------------------- */ diff --git a/include/Zydis/Internal/InstructionDefinitions.inc b/include/Zydis/Internal/InstructionDefinitions.inc index d782723..80863c4 100644 --- a/include/Zydis/Internal/InstructionDefinitions.inc +++ b/include/Zydis/Internal/InstructionDefinitions.inc @@ -3720,10 +3720,10 @@ const ZydisInstructionDefinitionVEX instructionDefinitionsVEX[] = const ZydisInstructionDefinitionEVEX instructionDefinitionsEVEX[] = { - /*0000*/ { ZYDIS_MNEMONIC_V4FMADDPS, 4, 0x0567, 0x00, ZYDIS_TUPLETYPE_INVALID, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*0001*/ { ZYDIS_MNEMONIC_V4FMADDSS, 4, 0x056B, 0x00, ZYDIS_TUPLETYPE_INVALID, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*0002*/ { ZYDIS_MNEMONIC_V4FNMADDPS, 4, 0x0567, 0x00, ZYDIS_TUPLETYPE_INVALID, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*0003*/ { ZYDIS_MNEMONIC_V4FNMADDSS, 4, 0x056B, 0x00, ZYDIS_TUPLETYPE_INVALID, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0000*/ { ZYDIS_MNEMONIC_V4FMADDPS, 4, 0x0567, 0x00, ZYDIS_TUPLETYPE_T1_4X, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0001*/ { ZYDIS_MNEMONIC_V4FMADDSS, 4, 0x056B, 0x00, ZYDIS_TUPLETYPE_T1_4X, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0002*/ { ZYDIS_MNEMONIC_V4FNMADDPS, 4, 0x0567, 0x00, ZYDIS_TUPLETYPE_T1_4X, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0003*/ { ZYDIS_MNEMONIC_V4FNMADDSS, 4, 0x056B, 0x00, ZYDIS_TUPLETYPE_T1_4X, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0004*/ { ZYDIS_MNEMONIC_VADDPD, 4, 0x018E, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0005*/ { ZYDIS_MNEMONIC_VADDPD, 4, 0x0364, 0x00, ZYDIS_TUPLETYPE_FV, 64, ZYDIS_EVEX_FUNC_BC, ZYDIS_MASK_POLICY_ALLOWED }, /*0006*/ { ZYDIS_MNEMONIC_VADDPD, 4, 0x0369, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, @@ -4900,10 +4900,10 @@ const ZydisInstructionDefinitionEVEX instructionDefinitionsEVEX[] = /*0499*/ { ZYDIS_MNEMONIC_VORPS, 4, 0x0387, 0x00, ZYDIS_TUPLETYPE_FV, 32, ZYDIS_EVEX_FUNC_BC, ZYDIS_MASK_POLICY_ALLOWED }, /*049A*/ { ZYDIS_MNEMONIC_VORPS, 4, 0x038C, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*049B*/ { ZYDIS_MNEMONIC_VORPS, 4, 0x0391, 0x00, ZYDIS_TUPLETYPE_FV, 32, ZYDIS_EVEX_FUNC_BC, ZYDIS_MASK_POLICY_ALLOWED }, - /*049C*/ { ZYDIS_MNEMONIC_VP4DPWSSD, 4, 0x0657, 0x00, ZYDIS_TUPLETYPE_INVALID, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*049D*/ { ZYDIS_MNEMONIC_VP4DPWSSD, 4, 0x065B, 0x00, ZYDIS_TUPLETYPE_INVALID, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*049E*/ { ZYDIS_MNEMONIC_VP4DPWSSDS, 4, 0x0657, 0x00, ZYDIS_TUPLETYPE_INVALID, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*049F*/ { ZYDIS_MNEMONIC_VP4DPWSSDS, 4, 0x065B, 0x00, ZYDIS_TUPLETYPE_INVALID, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*049C*/ { ZYDIS_MNEMONIC_VP4DPWSSD, 4, 0x0657, 0x00, ZYDIS_TUPLETYPE_T1_4X, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*049D*/ { ZYDIS_MNEMONIC_VP4DPWSSD, 4, 0x065B, 0x00, ZYDIS_TUPLETYPE_T1_4X, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*049E*/ { ZYDIS_MNEMONIC_VP4DPWSSDS, 4, 0x0657, 0x00, ZYDIS_TUPLETYPE_T1_4X, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*049F*/ { ZYDIS_MNEMONIC_VP4DPWSSDS, 4, 0x065B, 0x00, ZYDIS_TUPLETYPE_T1_4X, 32, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*04A0*/ { ZYDIS_MNEMONIC_VPABSB, 3, 0x0F1B, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*04A1*/ { ZYDIS_MNEMONIC_VPABSB, 3, 0x0F1E, 0x00, ZYDIS_TUPLETYPE_FVM, 8, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*04A2*/ { ZYDIS_MNEMONIC_VPABSB, 3, 0x0F21, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, @@ -5067,11 +5067,11 @@ const ZydisInstructionDefinitionEVEX instructionDefinitionsEVEX[] = /*0540*/ { ZYDIS_MNEMONIC_VPBLENDMW, 4, 0x06FF, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0541*/ { ZYDIS_MNEMONIC_VPBLENDMW, 4, 0x0703, 0x00, ZYDIS_TUPLETYPE_FVM, 16, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0542*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0EF1, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*0543*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F63, 0x00, ZYDIS_TUPLETYPE_INVALID, 8, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0543*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F63, 0x00, ZYDIS_TUPLETYPE_T1S, 8, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0544*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F66, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*0545*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F69, 0x00, ZYDIS_TUPLETYPE_INVALID, 8, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0545*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F69, 0x00, ZYDIS_TUPLETYPE_T1S, 8, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0546*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F6C, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*0547*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F6F, 0x00, ZYDIS_TUPLETYPE_INVALID, 8, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0547*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F6F, 0x00, ZYDIS_TUPLETYPE_T1S, 8, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0548*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F72, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0549*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F75, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*054A*/ { ZYDIS_MNEMONIC_VPBROADCASTB, 3, 0x0F78, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, @@ -5100,11 +5100,11 @@ const ZydisInstructionDefinitionEVEX instructionDefinitionsEVEX[] = /*0561*/ { ZYDIS_MNEMONIC_VPBROADCASTQ, 3, 0x0F9F, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0562*/ { ZYDIS_MNEMONIC_VPBROADCASTQ, 3, 0x0FA2, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0563*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x081F, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*0564*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FA5, 0x00, ZYDIS_TUPLETYPE_INVALID, 16, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0564*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FA5, 0x00, ZYDIS_TUPLETYPE_T1S, 16, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0565*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FA8, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*0566*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FAB, 0x00, ZYDIS_TUPLETYPE_INVALID, 16, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0566*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FAB, 0x00, ZYDIS_TUPLETYPE_T1S, 16, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0567*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FAE, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, - /*0568*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FB1, 0x00, ZYDIS_TUPLETYPE_INVALID, 16, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, + /*0568*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FB1, 0x00, ZYDIS_TUPLETYPE_T1S, 16, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*0569*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FB4, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*056A*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FB7, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, /*056B*/ { ZYDIS_MNEMONIC_VPBROADCASTW, 3, 0x0FBA, 0x00, ZYDIS_TUPLETYPE_INVALID, 0, ZYDIS_EVEX_FUNC_INVALID, ZYDIS_MASK_POLICY_ALLOWED }, diff --git a/src/Decoder.c b/src/Decoder.c index 323b684..391f03f 100644 --- a/src/Decoder.c +++ b/src/Decoder.c @@ -66,6 +66,9 @@ typedef struct ZydisDecoderContext_ * general has precedence over 0x66. */ uint8_t mandatoryCandidate; + + uint8_t prefixes[ZYDIS_MAX_INSTRUCTION_LENGTH]; + /** * @brief Contains the effective operand-size index. * @@ -764,6 +767,7 @@ static ZydisStatus ZydisCollectOptionalPrefixes(ZydisDecoderContext* context, } if (!done) { + context->prefixes[info->details.prefixes.count] = prefixByte; info->details.prefixes.data[info->details.prefixes.count++] = prefixByte; ZydisInputSkip(context, info); } @@ -2378,6 +2382,11 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context, ZYDIS_UNREACHABLE; } break; + case ZYDIS_TUPLETYPE_T1_4X: + ZYDIS_ASSERT(info->avx.elementSize == 32); + ZYDIS_ASSERT(context->cache.W == 0); + info->avx.compressedDisp8Scale = 16; + break; default: ZYDIS_UNREACHABLE; }