From 4836e3374e813e6719a8da764bcb20701e4931a0 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 30 Apr 2002 20:56:43 +0000 Subject: NASM 0.98p3.5 --- ndisasm.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'ndisasm.c') diff --git a/ndisasm.c b/ndisasm.c index a07a278..99e943a 100644 --- a/ndisasm.c +++ b/ndisasm.c @@ -12,6 +12,7 @@ #include #include +#include "insns.h" #include "nasm.h" #include "nasmlib.h" #include "sync.h" @@ -21,14 +22,15 @@ static const char *help = "usage: ndisasm [-a] [-i] [-h] [-r] [-u] [-b bits] [-o origin] [-s sync...]\n" -" [-e bytes] [-k start,bytes] file\n" +" [-e bytes] [-k start,bytes] [-p vendor] file\n" " -a or -i activates auto (intelligent) sync\n" " -u sets USE32 (32-bit mode)\n" " -b 16 or -b 32 sets number of bits too\n" " -h displays this text\n" " -r displays the version number\n" " -e skips bytes of header\n" -" -k avoids disassembling bytes from position \n"; +" -k avoids disassembling bytes from position \n" +" -p selects the preferred vendor instruction set (intel, amd, cyrix)\n"; static void output_ins (unsigned long, unsigned char *, int, char *); static void skip (unsigned long dist, FILE *fp); @@ -44,6 +46,7 @@ int main(int argc, char **argv) int autosync = FALSE; int bits = 16; int eof = FALSE; + unsigned long prefer = 0; int rn_error; long offset; FILE *fp; @@ -157,6 +160,24 @@ int main(int argc, char **argv) add_sync (nextsync, synclen); p = ""; /* force to next argument */ break; + case 'p': /* preferred vendor */ + v = p[1] ? p+1 : --argc ? *++argv : NULL; + if (!v) { + fprintf(stderr, "%s: `-p' requires an argument\n", pname); + return 1; + } + if ( !strcmp(v, "intel") ) { + prefer = 0; /* Default */ + } else if ( !strcmp(v, "amd") ) { + prefer = IF_AMD|IF_3DNOW; + } else if ( !strcmp(v, "cyrix") ) { + prefer = IF_CYRIX|IF_3DNOW; + } else { + fprintf(stderr, "%s: unknown vendor `%s' specified with `-p'\n", pname, v); + return 1; + } + p = ""; /* force to next argument */ + break; } } else if (!filename) { filename = p; @@ -213,7 +234,7 @@ int main(int argc, char **argv) nextsync = next_sync (offset, &synclen); } while (p > q && (p - q >= INSN_MAX || lenread == 0)) { - lendis = disasm (q, outbuf, bits, offset, autosync); + lendis = disasm (q, outbuf, bits, offset, autosync, prefer); if (!lendis || lendis > (p - q) || lendis > nextsync-offset) lendis = eatbyte (q, outbuf); -- cgit v1.2.3