From 0a36604c8156cc070ae54dd7c20bb6bcafb5e9f1 Mon Sep 17 00:00:00 2001 From: Alexis Engelke Date: Fri, 24 Mar 2023 14:00:14 +0100 Subject: [PATCH] decode: Change REP flag values The new values allow for a more optimizable computation of the required flags from the decoded prefix. --- decode.c | 5 +---- fadec.h | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/decode.c b/decode.c index eabe11e..49d1a93 100644 --- a/decode.c +++ b/decode.c @@ -349,10 +349,7 @@ direct: instr->type = desc->type; instr->addrsz = addr_size; - instr->flags = prefix_rep == 0xf3 ? FD_FLAG_REP : - prefix_rep == 0xf2 ? FD_FLAG_REPNZ : 0; - if (mode == DECODE_64) - instr->flags |= FD_FLAG_64; + instr->flags = ((prefix_rep + 1) & 6) + (mode == DECODE_64 ? FD_FLAG_64 : 0); instr->address = address; for (unsigned i = 0; i < sizeof(instr->operands) / sizeof(FdOp); i++) diff --git a/fadec.h b/fadec.h index 4a1c338..03c4535 100644 --- a/fadec.h +++ b/fadec.h @@ -37,8 +37,8 @@ typedef enum { /** Internal use only. **/ enum { FD_FLAG_LOCK = 1 << 0, - FD_FLAG_REP = 1 << 1, - FD_FLAG_REPNZ = 1 << 2, + FD_FLAG_REP = 1 << 2, + FD_FLAG_REPNZ = 1 << 1, FD_FLAG_64 = 1 << 7, };