summaryrefslogtreecommitdiff
path: root/disasm.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2013-09-27 16:53:51 -0700
committerJin Kyu Song <jin.kyu.song@intel.com>2013-11-20 11:29:41 -0800
commit0bc288f8b9ec5fb30fb816008e81282081d85e82 (patch)
treefe988470a8c69714e8ea9cac8d78c3dc6478a116 /disasm.c
parent9148fb5951ca9374a7fba4c586cac5e37562e019 (diff)
downloadnasm-0bc288f8b9ec5fb30fb816008e81282081d85e82.tar.gz
nasm-0bc288f8b9ec5fb30fb816008e81282081d85e82.tar.bz2
nasm-0bc288f8b9ec5fb30fb816008e81282081d85e82.zip
disasm: add support for emitting split EA format
Add support for emitting split EA format in the disassembler, indicated by the MIB instruction flag. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Diffstat (limited to 'disasm.c')
-rw-r--r--disasm.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/disasm.c b/disasm.c
index 9a5f9ad..f50ceb9 100644
--- a/disasm.c
+++ b/disasm.c
@@ -955,7 +955,7 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
uint8_t *origdata;
int works;
insn tmp_ins, ins;
- iflags_t goodness, best;
+ iflags_t goodness, best, flags;
int best_pref;
struct prefix_info prefix;
bool end_prefix;
@@ -1174,6 +1174,7 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
/* Pick the best match */
p = best_p;
length = best_length;
+ flags = (*p)->flags;
slen = 0;
@@ -1331,7 +1332,7 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
nasm_reg_names[(o->basereg-EXPR_REG_START)]);
started = true;
}
- if (o->indexreg != -1) {
+ if (o->indexreg != -1 && !(flags & IF_MIB)) {
if (started)
output[slen++] = '+';
slen += snprintf(output + slen, outbufsize - slen, "%s",
@@ -1395,6 +1396,18 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
"%s0x%"PRIx32"", prefix, offset);
}
}
+
+ if (o->indexreg != -1 && (flags & IF_MIB)) {
+ output[slen++] = ',';
+ slen += snprintf(output + slen, outbufsize - slen, "%s",
+ nasm_reg_names[(o->indexreg-EXPR_REG_START)]);
+ if (o->scale > 1)
+ slen +=
+ snprintf(output + slen, outbufsize - slen, "*%d",
+ o->scale);
+ started = true;
+ }
+
output[slen++] = ']';
} else {
slen +=