struct dis_private {
/* Points to first byte not fetched. */
- bfd_byte *max_fetched;
- bfd_byte the_buffer[MAX_MNEM_SIZE];
+ uint8_t *max_fetched;
+ uint8_t the_buffer[MAX_MNEM_SIZE];
bfd_vma insn_start;
int orig_sizeflag;
};
mode_64bit
};
-static const char *prefix_name (enum address_mode, int, int);
+static const char *prefix_name (enum address_mode, uint8_t, int);
enum x86_64_isa
{
int prefixes;
/* REX prefix the current instruction. See below. */
- unsigned char rex;
+ uint8_t rex;
/* Bits of REX we've already used. */
- unsigned char rex_used;
+ uint8_t rex_used;
bool need_modrm;
bool need_vex;
char obuf[MAX_OPERAND_BUFFER_SIZE];
char *obufp;
char *mnemonicendp;
- unsigned char *start_codep;
- unsigned char *insn_codep;
- unsigned char *codep;
- unsigned char *end_codep;
+ const uint8_t *start_codep;
+ uint8_t *insn_codep;
+ uint8_t *codep;
+ const uint8_t *end_codep;
signed char last_lock_prefix;
signed char last_repz_prefix;
signed char last_repnz_prefix;
#define MAX_CODE_LENGTH 15
/* We can up to 14 ins->prefixes since the maximum instruction length is
15bytes. */
- unsigned char all_prefixes[MAX_CODE_LENGTH - 1];
+ uint8_t all_prefixes[MAX_CODE_LENGTH - 1];
disassemble_info *info;
struct
to ADDR (exclusive) are valid. Returns true for success, false
on error. */
static bool
-fetch_code (struct disassemble_info *info, bfd_byte *until)
+fetch_code (struct disassemble_info *info, uint8_t *until)
{
int status = -1;
struct dis_private *priv = info->private_data;
}
ckprefix (instr_info *ins)
{
- int newrex, i, length;
+ int i, length;
+ uint8_t newrex;
i = 0;
length = 0;
if (!fetch_code (ins->info, ins->codep + 1))
return ckp_fetch_error;
newrex = 0;
- switch (*ins->codep & 0xff)
+ switch (*ins->codep)
{
/* REX prefixes family. */
case 0x40:
case 0x4e:
case 0x4f:
if (ins->address_mode == mode_64bit)
- newrex = *ins->codep & 0xff;
+ newrex = *ins->codep;
else
return ckp_okay;
ins->last_rex_prefix = i;
/* Rex is ignored when followed by another prefix. */
if (ins->rex)
return ckp_bogus;
- if ((*ins->codep & 0xff) != FWAIT_OPCODE)
- ins->all_prefixes[i++] = *ins->codep & 0xff;
+ if (*ins->codep != FWAIT_OPCODE)
+ ins->all_prefixes[i++] = *ins->codep;
ins->rex = newrex;
ins->codep++;
length++;
prefix byte. */
static const char *
-prefix_name (enum address_mode mode, int pref, int sizeflag)
+prefix_name (enum address_mode mode, uint8_t pref, int sizeflag)
{
static const char *rexes [16] =
{
case USE_3BYTE_TABLE:
if (!fetch_code (ins->info, ins->codep + 2))
return &err_opcode;
- vindex = *ins->codep++ & 0xff;
+ vindex = *ins->codep++;
dp = &three_byte_table[dp->op[1].bytemode][vindex];
ins->end_codep = ins->codep;
if (!fetch_modrm (ins))
}
ins->need_vex = true;
ins->codep++;
- vindex = *ins->codep++ & 0xff;
+ vindex = *ins->codep++;
dp = &xop_table[vex_table_index][vindex];
ins->end_codep = ins->codep;
}
ins->need_vex = true;
ins->codep++;
- vindex = *ins->codep++ & 0xff;
+ vindex = *ins->codep++;
dp = &vex_table[vex_table_index][vindex];
ins->end_codep = ins->codep;
/* There is no MODRM byte for VEX0F 77. */
}
ins->need_vex = true;
ins->codep++;
- vindex = *ins->codep++ & 0xff;
+ vindex = *ins->codep++;
dp = &vex_table[dp->op[1].bytemode][vindex];
ins->end_codep = ins->codep;
/* There is no MODRM byte for VEX 77. */
ins->need_vex = true;
ins->codep++;
- vindex = *ins->codep++ & 0xff;
+ vindex = *ins->codep++;
dp = &evex_table[vex_table_index][vindex];
ins->end_codep = ins->codep;
if (!fetch_modrm (ins))
goto out;
}
- ins.two_source_ops = ((*ins.codep & 0xff) == 0x62
- || (*ins.codep & 0xff) == 0xc8);
+ ins.two_source_ops = (*ins.codep == 0x62 || *ins.codep == 0xc8);
if ((ins.prefixes & PREFIX_FWAIT)
- && ((*ins.codep & 0xff) < 0xd8 || (*ins.codep & 0xff) > 0xdf))
+ && (*ins.codep < 0xd8 || *ins.codep > 0xdf))
{
/* Handle ins.prefixes before fwait. */
for (i = 0; i < ins.fwait_prefix && ins.all_prefixes[i];
goto out;
}
- if ((*ins.codep & 0xff) == 0x0f)
+ if (*ins.codep == 0x0f)
{
unsigned char threebyte;
ins.codep++;
if (!fetch_code (info, ins.codep + 1))
goto fetch_error_out;
- threebyte = *ins.codep & 0xff;
+ threebyte = *ins.codep;
dp = &dis386_twobyte[threebyte];
ins.need_modrm = twobyte_has_modrm[threebyte];
ins.codep++;
}
else
{
- dp = &dis386[*ins.codep & 0xff];
- ins.need_modrm = onebyte_has_modrm[*ins.codep & 0xff];
+ dp = &dis386[*ins.codep];
+ ins.need_modrm = onebyte_has_modrm[*ins.codep];
ins.codep++;
}
dofloat (instr_info *ins, int sizeflag)
{
const struct dis386 *dp;
- unsigned char floatop;
-
- floatop = ins->codep[-1] & 0xff;
+ unsigned char floatop = ins->codep[-1];
if (ins->modrm.mod != 3)
{
putop (ins, fgrps[dp->op[0].bytemode][ins->modrm.rm], sizeflag);
/* Instruction fnstsw is only one with strange arg. */
- if (floatop == 0xdf && (ins->codep[-1] & 0xff) == 0xe0)
+ if (floatop == 0xdf && ins->codep[-1] == 0xe0)
strcpy (ins->op_out[0], att_names16[0] + ins->intel_syntax);
}
else
{
if (!fetch_code (ins->info, ins->codep + 1))
return false;
- *res = (((bfd_vma) *ins->codep++ & 0xff) ^ 0x80) - 0x80;
+ *res = ((bfd_vma) *ins->codep++ ^ 0x80) - 0x80;
return true;
}
{
if (!fetch_code (ins->info, ins->codep + 2))
return false;
- *res = (bfd_vma) *ins->codep++ & 0xff;
- *res |= ((bfd_vma) *ins->codep++ & 0xff) << 8;
+ *res = *ins->codep++;
+ *res |= (bfd_vma) *ins->codep++ << 8;
return true;
}
{
if (!fetch_code (ins->info, ins->codep + 4))
return false;
- *res = *ins->codep++ & (bfd_vma) 0xff;
- *res |= (*ins->codep++ & (bfd_vma) 0xff) << 8;
- *res |= (*ins->codep++ & (bfd_vma) 0xff) << 16;
- *res |= (*ins->codep++ & (bfd_vma) 0xff) << 24;
+ *res = *ins->codep++;
+ *res |= (bfd_vma) *ins->codep++ << 8;
+ *res |= (bfd_vma) *ins->codep++ << 16;
+ *res |= (bfd_vma) *ins->codep++ << 24;
return true;
}
if (!fetch_code (ins->info, ins->codep + 8))
return false;
- a = *ins->codep++ & 0xff;
- a |= (*ins->codep++ & 0xff) << 8;
- a |= (*ins->codep++ & 0xff) << 16;
- a |= (*ins->codep++ & 0xffu) << 24;
- b = *ins->codep++ & 0xff;
- b |= (*ins->codep++ & 0xff) << 8;
- b |= (*ins->codep++ & 0xff) << 16;
- b |= (*ins->codep++ & 0xffu) << 24;
+ a = *ins->codep++;
+ a |= (unsigned int) *ins->codep++ << 8;
+ a |= (unsigned int) *ins->codep++ << 16;
+ a |= (unsigned int) *ins->codep++ << 24;
+ b = *ins->codep++;
+ b |= (unsigned int) *ins->codep++ << 8;
+ b |= (unsigned int) *ins->codep++ << 16;
+ b |= (unsigned int) *ins->codep++ << 24;
*res = a + ((uint64_t) b << 32);
return true;
}
case b_mode:
if (!fetch_code (ins->info, ins->codep + 1))
return false;
- op = *ins->codep++ & 0xff;
+ op = *ins->codep++;
break;
case v_mode:
USED_REX (REX_W);
{
if (ins->intel_syntax)
{
- switch (ins->codep[-1] & 0xff)
+ switch (ins->codep[-1])
{
case 0x6d: /* insw/insl */
intel_operand_size (ins, z_mode, sizeflag);
{
if (ins->intel_syntax)
{
- switch (ins->codep[-1] & 0xff)
+ switch (ins->codep[-1])
{
case 0x6f: /* outsw/outsl */
intel_operand_size (ins, z_mode, sizeflag);
place where an 8-bit immediate would normally go. ie. the last
byte of the instruction. */
ins->obufp = ins->mnemonicendp;
- mnemonic = Suffix3DNow[*ins->codep++ & 0xff];
+ mnemonic = Suffix3DNow[*ins->codep++];
if (mnemonic)
ins->obufp = stpcpy (ins->obufp, mnemonic);
else
if (!fetch_code (ins->info, ins->codep + 1))
return false;
- cmp_type = *ins->codep++ & 0xff;
+ cmp_type = *ins->codep++;
if (cmp_type < ARRAY_SIZE (simd_cmp_op))
{
char suffix[3];
if (!fetch_code (ins->info, ins->codep + 1))
return false;
- reg = *ins->codep++ & 0xff;
+ reg = *ins->codep++;
if (bytemode != x_mode && bytemode != scalar_mode)
abort ();
if (!fetch_code (ins->info, ins->codep + 1))
return false;
- cmp_type = *ins->codep++ & 0xff;
+ cmp_type = *ins->codep++;
/* There are aliases for immediates 0, 1, 2, 4, 5, 6.
If it's the case, print suffix, otherwise - print the immediate. */
if (cmp_type < ARRAY_SIZE (simd_cmp_op)
if (!fetch_code (ins->info, ins->codep + 1))
return false;
- cmp_type = *ins->codep++ & 0xff;
+ cmp_type = *ins->codep++;
if (cmp_type < ARRAY_SIZE (xop_cmp_op))
{
char suffix[3];
if (!fetch_code (ins->info, ins->codep + 1))
return false;
- pclmul_type = *ins->codep++ & 0xff;
+ pclmul_type = *ins->codep++;
switch (pclmul_type)
{
case 0x10: