need to update onebyte_has_modrm or twobyte_has_modrm. */
#define MODRM_CHECK if (!need_modrm) abort ()
-static const char *names64[] = {
- "%rax","%rcx","%rdx","%rbx", "%rsp","%rbp","%rsi","%rdi",
+static const char **names64;
+static const char **names32;
+static const char **names16;
+static const char **names8;
+static const char **names8rex;
+static const char **names_seg;
+static const char **index16;
+
+static const char *intel_names64[] = {
+ "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
+};
+static const char *intel_names32[] = {
+ "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
+ "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
+};
+static const char *intel_names16[] = {
+ "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
+ "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"
+};
+static const char *intel_names8[] = {
+ "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
+};
+static const char *intel_names8rex[] = {
+ "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
+ "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"
+};
+static const char *intel_names_seg[] = {
+ "es", "cs", "ss", "ds", "fs", "gs", "?", "?",
+};
+static const char *intel_index16[] = {
+ "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx"
+};
+
+static const char *att_names64[] = {
+ "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
"%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
};
-static const char *names32[] = {
- "%eax","%ecx","%edx","%ebx", "%esp","%ebp","%esi","%edi",
+static const char *att_names32[] = {
+ "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
"%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
};
-static const char *names16[] = {
- "%ax","%cx","%dx","%bx","%sp","%bp","%si","%di",
+static const char *att_names16[] = {
+ "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
"%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
};
-static const char *names8[] = {
- "%al","%cl","%dl","%bl","%ah","%ch","%dh","%bh",
+static const char *att_names8[] = {
+ "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
};
-static const char *names8rex[] = {
- "%al","%cl","%dl","%bl","%spl", "%bpl", "%sil", "%dil",
+static const char *att_names8rex[] = {
+ "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
"%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
};
-static const char *names_seg[] = {
- "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
+static const char *att_names_seg[] = {
+ "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?",
};
-static const char *index16[] = {
- "%bx,%si","%bx,%di","%bp,%si","%bp,%di","%si","%di","%bp","%bx"
+static const char *att_index16[] = {
+ "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx"
};
static const struct dis386 grps[][8] = {
disassemble_info *info;
{
intel_syntax = 0;
+ names64 = att_names64;
+ names32 = att_names32;
+ names16 = att_names16;
+ names8 = att_names8;
+ names8rex = att_names8rex;
+ names_seg = att_names_seg;
+ index16 = att_index16;
open_char = '(';
close_char = ')';
separator_char = ',';
disassemble_info *info;
{
intel_syntax = 1;
+ names64 = intel_names64;
+ names32 = intel_names32;
+ names16 = intel_names16;
+ names8 = intel_names8;
+ names8rex = intel_names8rex;
+ names_seg = intel_names_seg;
+ index16 = intel_index16;
open_char = '[';
close_char = ']';
separator_char = '+';
int sizeflag ATTRIBUTE_UNUSED;
{
sprintf (scratchbuf, "%%st(%d)", rm);
- oappend (scratchbuf);
+ oappend (scratchbuf + intel_syntax);
}
/* capital letters in template are macros */
{
if (prefixes & PREFIX_CS)
{
- oappend ("%cs:");
used_prefixes |= PREFIX_CS;
+ oappend ("%cs:" + intel_syntax);
}
if (prefixes & PREFIX_DS)
{
- oappend ("%ds:");
used_prefixes |= PREFIX_DS;
+ oappend ("%ds:" + intel_syntax);
}
if (prefixes & PREFIX_SS)
{
- oappend ("%ss:");
used_prefixes |= PREFIX_SS;
+ oappend ("%ss:" + intel_syntax);
}
if (prefixes & PREFIX_ES)
{
- oappend ("%es:");
used_prefixes |= PREFIX_ES;
+ oappend ("%es:" + intel_syntax);
}
if (prefixes & PREFIX_FS)
{
- oappend ("%fs:");
used_prefixes |= PREFIX_FS;
+ oappend ("%fs:" + intel_syntax);
}
if (prefixes & PREFIX_GS)
{
- oappend ("%gs:");
used_prefixes |= PREFIX_GS;
+ oappend ("%gs:" + intel_syntax);
}
}
*obufp++ = separator_char;
*obufp = '\0';
}
- sprintf (scratchbuf, "%s", mode_64bit ? names64[index] : names32[index]);
+ sprintf (scratchbuf, "%s",
+ mode_64bit ? names64[index] : names32[index]);
}
else
- sprintf (scratchbuf, ",%s", mode_64bit ? names64[index] : names32[index]);
+ sprintf (scratchbuf, ",%s",
+ mode_64bit ? names64[index] : names32[index]);
oappend (scratchbuf);
}
if (!intel_syntax
/* Don't print zero displacements */
if (disp != 0)
{
+ if ((bfd_signed_vma) disp > 0)
+ {
+ *obufp++ = '+';
+ *obufp = '\0';
+ }
+
print_operand_value (scratchbuf, 0, disp);
oappend (scratchbuf);
}
;
else
{
- oappend (names_seg[3]);
+ oappend (names_seg[ds_reg - es_reg]);
oappend (":");
}
print_operand_value (scratchbuf, 1, disp);
switch (code)
{
case indir_dx_reg:
- s = "(%dx)";
+ if (intel_syntax)
+ s = "[dx]";
+ else
+ s = "(%dx)";
break;
case ax_reg: case cx_reg: case dx_reg: case bx_reg:
case sp_reg: case bp_reg: case si_reg: case di_reg:
switch (code)
{
case indir_dx_reg:
- s = "(%dx)";
+ if (intel_syntax)
+ s = "[dx]";
+ else
+ s = "(%dx)";
break;
case ax_reg: case cx_reg: case dx_reg: case bx_reg:
case sp_reg: case bp_reg: case si_reg: case di_reg:
op &= mask;
scratchbuf[0] = '$';
- print_operand_value (scratchbuf + !intel_syntax, 1, op);
- oappend (scratchbuf);
+ print_operand_value (scratchbuf + 1, 1, op);
+ oappend (scratchbuf + intel_syntax);
scratchbuf[0] = '\0';
}
op &= mask;
scratchbuf[0] = '$';
- print_operand_value (scratchbuf + !intel_syntax, 1, op);
- oappend (scratchbuf);
+ print_operand_value (scratchbuf + 1, 1, op);
+ oappend (scratchbuf + intel_syntax);
scratchbuf[0] = '\0';
}
scratchbuf[0] = '$';
print_operand_value (scratchbuf + 1, 1, op);
- oappend (scratchbuf);
+ oappend (scratchbuf + intel_syntax);
}
static void
int dummy ATTRIBUTE_UNUSED;
int sizeflag ATTRIBUTE_UNUSED;
{
- static char *sreg[] = {
- "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
- };
-
- oappend (sreg[reg]);
+ oappend (names_seg[reg]);
}
static void
seg = get16 ();
}
used_prefixes |= (prefixes & PREFIX_DATA);
- sprintf (scratchbuf, "$0x%x,$0x%x", seg, offset);
+ if (intel_syntax)
+ sprintf (scratchbuf, "0x%x,0x%x", seg, offset);
+ else
+ sprintf (scratchbuf, "$0x%x,$0x%x", seg, offset);
oappend (scratchbuf);
}
if (!(prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
| PREFIX_ES | PREFIX_FS | PREFIX_GS)))
{
- oappend (names_seg[3]);
+ oappend (names_seg[ds_reg - es_reg]);
oappend (":");
}
}
if (!(prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
| PREFIX_ES | PREFIX_FS | PREFIX_GS)))
{
- oappend (names_seg[3]);
+ oappend (names_seg[ds_reg - es_reg]);
oappend (":");
}
}
int sizeflag;
{
const char *s;
- oappend ("(");
+ if(intel_syntax)
+ oappend ("[");
+ else
+ oappend ("(");
+
USED_REX (REX_MODE64);
if (rex & REX_MODE64)
s = names64[code - eAX_reg];
else
s = names16[code - eAX_reg];
oappend (s);
- oappend (")");
+ if(intel_syntax)
+ oappend ("]");
+ else
+ oappend (")");
}
static void
int code;
int sizeflag;
{
- oappend ("%es:");
+ oappend ("%es:" + intel_syntax);
ptr_reg (code, sizeflag);
}
USED_REX (REX_EXTX);
if (rex & REX_EXTX)
add = 8;
- sprintf (scratchbuf, "%%cr%d", reg+add);
- oappend (scratchbuf);
+ sprintf (scratchbuf, "%%cr%d", reg + add);
+ oappend (scratchbuf + intel_syntax);
}
static void
USED_REX (REX_EXTX);
if (rex & REX_EXTX)
add = 8;
- sprintf (scratchbuf, "%%db%d", reg+add);
+ if (intel_syntax)
+ sprintf (scratchbuf, "db%d", reg+add);
+ else
+ sprintf (scratchbuf, "%%db%d", reg+add);
oappend (scratchbuf);
}
int sizeflag ATTRIBUTE_UNUSED;
{
sprintf (scratchbuf, "%%tr%d", reg);
- oappend (scratchbuf);
+ oappend (scratchbuf + intel_syntax);
}
static void
sprintf (scratchbuf, "%%xmm%d", reg + add);
else
sprintf (scratchbuf, "%%mm%d", reg + add);
- oappend (scratchbuf);
+ oappend (scratchbuf + intel_syntax);
}
static void
if (rex & REX_EXTX)
add = 8;
sprintf (scratchbuf, "%%xmm%d", reg + add);
- oappend (scratchbuf);
+ oappend (scratchbuf + intel_syntax);
}
static void
sprintf (scratchbuf, "%%xmm%d", rm + add);
else
sprintf (scratchbuf, "%%mm%d", rm + add);
- oappend (scratchbuf);
+ oappend (scratchbuf + intel_syntax);
}
static void
MODRM_CHECK;
codep++;
sprintf (scratchbuf, "%%xmm%d", rm + add);
- oappend (scratchbuf);
+ oappend (scratchbuf + intel_syntax);
}
static void