mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-12 01:30:03 +00:00
Fix for newer binutils (2.17). Skip extraneous REX prefix (FIXME?) in disassembly,
fix decoding for pushq/popq.
This commit is contained in:
parent
5f0e7847d5
commit
1ad1f0a795
@ -44,6 +44,8 @@
|
|||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
static int verbose = 2;
|
||||||
|
|
||||||
#undef abort
|
#undef abort
|
||||||
#define abort() do { \
|
#define abort() do { \
|
||||||
fprintf(stderr, "ABORT: %s, line %d\n", __FILE__, __LINE__); \
|
fprintf(stderr, "ABORT: %s, line %d\n", __FILE__, __LINE__); \
|
||||||
@ -263,6 +265,20 @@ regnames[] = {
|
|||||||
#undef _
|
#undef _
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline char *find_blanks(char *p)
|
||||||
|
{
|
||||||
|
while (*p && !isspace(*p))
|
||||||
|
++p;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline char *skip_blanks(char *p)
|
||||||
|
{
|
||||||
|
while (*p && isspace(*p))
|
||||||
|
++p;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_reg(operand_t *op, int optype, char *buf)
|
static int parse_reg(operand_t *op, int optype, char *buf)
|
||||||
{
|
{
|
||||||
for (int i = 0; regnames[i].name; i++) {
|
for (int i = 0; regnames[i].name; i++) {
|
||||||
@ -335,6 +351,17 @@ static void parse_insn(insn_t *ii, char *buf)
|
|||||||
char *p = buf;
|
char *p = buf;
|
||||||
ii->clear();
|
ii->clear();
|
||||||
|
|
||||||
|
if (strncmp(p, "rex64", 5) == 0) {
|
||||||
|
char *q = find_blanks(p);
|
||||||
|
if (verbose > 1) {
|
||||||
|
char prefix[16];
|
||||||
|
memset(prefix, 0, sizeof(prefix));
|
||||||
|
memcpy(prefix, p, q - p);
|
||||||
|
fprintf(stderr, "Instruction '%s', skip REX prefix '%s'\n", buf, prefix);
|
||||||
|
}
|
||||||
|
p = skip_blanks(q);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; !isspace(*p); i++)
|
for (int i = 0; !isspace(*p); i++)
|
||||||
ii->name[i] = *p++;
|
ii->name[i] = *p++;
|
||||||
|
|
||||||
@ -557,8 +584,6 @@ static bool check_mem_reg(insn_t *ii, const char *name, uint32 D, int B, int I,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int verbose = 2;
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
static char buffer[1024];
|
static char buffer[1024];
|
||||||
@ -595,8 +620,8 @@ int main(void)
|
|||||||
GENA("inc", INC);
|
GENA("inc", INC);
|
||||||
GEN("callq", CALLs);
|
GEN("callq", CALLs);
|
||||||
GEN("jmpq", JMPs);
|
GEN("jmpq", JMPs);
|
||||||
GEN("pushl", PUSHQ); // FIXME: disass bug? wrong suffix
|
GEN(X86_TARGET_64BIT ? "pushq" : "pushl", PUSHQ);
|
||||||
GEN("popl", POPQ); // FIXME: disass bug? wrong suffix
|
GEN(X86_TARGET_64BIT ? "popq" : "popl", POPQ);
|
||||||
GEN("bswap", BSWAPL); // FIXME: disass bug? no suffix
|
GEN("bswap", BSWAPL); // FIXME: disass bug? no suffix
|
||||||
GEN("bswap", BSWAPQ); // FIXME: disass bug? no suffix
|
GEN("bswap", BSWAPQ); // FIXME: disass bug? no suffix
|
||||||
GEN("seto", SETO);
|
GEN("seto", SETO);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user