summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2013-03-02 02:48:23 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2013-03-02 02:59:29 +0400
commit982387606ba23004ac2df50da72cca178be642c4 (patch)
tree48154770727a70dc99f35ba574d8f318691f6e70
parent59df421af31c930aa467232e7c0b487c3f5f5621 (diff)
downloadnasm-982387606ba23004ac2df50da72cca178be642c4.tar.gz
nasm-982387606ba23004ac2df50da72cca178be642c4.tar.bz2
nasm-982387606ba23004ac2df50da72cca178be642c4.zip
assemble: Make emit_rex being a function
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--assemble.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/assemble.c b/assemble.c
index 76b147f..7ed0892 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;