From 982387606ba23004ac2df50da72cca178be642c4 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Sat, 2 Mar 2013 02:48:23 +0400 Subject: [PATCH] assemble: Make emit_rex being a function Signed-off-by: Cyrill Gorcunov --- assemble.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/assemble.c b/assemble.c index 76b147fa..7ed08921 100644 --- a/assemble.c +++ b/assemble.c @@ -1200,14 +1200,20 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, return length; } -#define EMIT_REX() \ - if (!(ins->rex & REX_V) && (ins->rex & REX_REAL) && (bits == 64)) { \ - ins->rex = (ins->rex & REX_REAL)|REX_P; \ - out(offset, segment, &ins->rex, OUT_RAWDATA, 1, NO_SEG, NO_SEG); \ - ins->rex = 0; \ - offset += 1; \ +static inline unsigned int emit_rex(insn *ins, int32_t segment, int64_t offset, int bits) +{ + if (bits == 64) { + if ((ins->rex & REX_REAL) && !(ins->rex & REX_V)) { + ins->rex = (ins->rex & REX_REAL) | REX_P; + out(offset, segment, &ins->rex, OUT_RAWDATA, 1, NO_SEG, NO_SEG); + ins->rex = 0; + return 1; + } } + return 0; +} + static void gencode(int32_t segment, int64_t offset, int bits, insn * ins, const struct itemplate *temp, int64_t insn_end) @@ -1239,7 +1245,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, case 02: case 03: case 04: - EMIT_REX(); + offset += emit_rex(ins, segment, offset, bits); out(offset, segment, codes, OUT_RAWDATA, c, NO_SEG, NO_SEG); codes += c; offset += c; @@ -1252,7 +1258,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, break; case4(010): - EMIT_REX(); + offset += emit_rex(ins, segment, offset, bits); bytes[0] = *codes++ + (regval(opx) & 7); out(offset, segment, bytes, OUT_RAWDATA, 1, NO_SEG, NO_SEG); offset += 1; -- 2.11.4.GIT