From 7d77e0747f19e6163e7fc792fd82b3b670c486dc Mon Sep 17 00:00:00 2001 From: flobernd Date: Sat, 24 Jun 2017 03:20:45 +0200 Subject: [PATCH] Minor improvements to the instruction-decoder - Set mask-mode to "merge" for all MVEX instructions - Set operand-action of EVEX dest-operands to RCW, if a merge write-mask is specified --- src/Decoder.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Decoder.c b/src/Decoder.c index 33df2cd..b0b191a 100644 --- a/src/Decoder.c +++ b/src/Decoder.c @@ -1908,6 +1908,19 @@ FinalizeOperand: ++operand; } + // Fix operand-action for EVEX instructions with merge-mask + if ((info->encoding == ZYDIS_INSTRUCTION_ENCODING_EVEX) && + (info->avx.maskMode == ZYDIS_MASK_MODE_MERGE) && + (info->operands[0].type == ZYDIS_OPERAND_TYPE_REGISTER) && + (info->operands[1].type == ZYDIS_OPERAND_TYPE_REGISTER) && + (info->operands[1].reg >= ZYDIS_REGISTER_K1) && + (info->operands[1].reg <= ZYDIS_REGISTER_K7)) + { + ZYDIS_ASSERT(info->operands[0].action == ZYDIS_OPERAND_ACTION_WRITE || + info->operands[0].action == ZYDIS_OPERAND_ACTION_READWRITE); + info->operands[0].action = ZYDIS_OPERAND_ACTION_READ_CONDWRITE; + } + return ZYDIS_STATUS_SUCCESS; } @@ -2727,6 +2740,7 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context, // Mask mode info->avx.maskMode = ZYDIS_MASK_MODE_MERGE + info->details.evex.z; + break; } case ZYDIS_INSTRUCTION_ENCODING_MVEX: @@ -3019,6 +3033,9 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context, info->avx.hasEvictionHint = ZYDIS_TRUE; } + // Mask mode + info->avx.maskMode = ZYDIS_MASK_MODE_MERGE; + break; } default: