summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-10-31 19:46:55 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-10-31 19:46:55 +0000
commit721087eeeb933d4a46873870644e0762a158dbfd (patch)
treebb1133e6d0d92480944382f90cb50b3510f05c68 /src/tools
parent8b430a357f4c93b57e17b0476093268c38916d66 (diff)
Added -flipped option to unidasm to output with disassembly
first and address/data bytes afterwards in comment form.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/unidasm.c100
1 files changed, 66 insertions, 34 deletions
diff --git a/src/tools/unidasm.c b/src/tools/unidasm.c
index 49cdee36253..92f9844904b 100644
--- a/src/tools/unidasm.c
+++ b/src/tools/unidasm.c
@@ -81,6 +81,7 @@ struct _options
UINT8 norawbytes;
UINT8 lower;
UINT8 upper;
+ UINT8 flipped;
int mode;
const dasm_table_entry *dasm;
};
@@ -379,6 +380,8 @@ static int parse_options(int argc, char *argv[], options *opts)
pending_arch = TRUE;
else if (tolower((UINT8)curarg[1]) == 'b')
pending_base = TRUE;
+ else if (tolower((UINT8)curarg[1]) == 'f')
+ opts->flipped = TRUE;
else if (tolower((UINT8)curarg[1]) == 'l')
opts->lower = TRUE;
else if (tolower((UINT8)curarg[1]) == 'm')
@@ -445,7 +448,8 @@ static int parse_options(int argc, char *argv[], options *opts)
return 0;
usage:
- printf("Usage: %s <filename> -arch <architecture> [-basepc <pc>] [-mode <n>] [-norawbytes] [-upper] [-lower]\n", argv[0]);
+ printf("Usage: %s <filename> -arch <architecture> [-basepc <pc>] \n", argv[0]);
+ printf(" [-mode <n>] [-norawbytes] [-flipped] [-upper] [-lower]\n");
printf("\n");
printf("Supported architectures:");
numrows = (ARRAY_LENGTH(dasm_table) + 6) / 7;
@@ -515,33 +519,7 @@ int main(int argc, char *argv[])
else
numbytes = pcdelta >> opts.dasm->pcshift;
- // round to the nearest display chunk
- numbytes = ((numbytes + displaychunk - 1) / displaychunk) * displaychunk;
- if (numbytes == 0)
- numbytes = displaychunk;
- numchunks = numbytes / displaychunk;
-
- // output the address
- printf("%08X: ", curpc);
-
- // output the raw bytes
- if (!opts.norawbytes)
- {
- int firstchunks = (numchunks < maxchunks) ? numchunks : maxchunks;
- int chunknum, bytenum;
- for (chunknum = 0; chunknum < firstchunks; chunknum++)
- {
- for (bytenum = 0; bytenum < displaychunk; bytenum++)
- printf("%02X", oprom[displayendian ? (displaychunk - 1 - bytenum) : bytenum]);
- printf(" ");
- oprom += displaychunk;
- }
- for ( ; chunknum < maxchunks; chunknum++)
- printf("%*s ", displaychunk * 2, "");
- printf(" ");
- }
-
- // output the disassembly
+ // force upper or lower
if (opts.lower)
{
for (p = buffer; *p != 0; p++)
@@ -552,16 +530,24 @@ int main(int argc, char *argv[])
for (p = buffer; *p != 0; p++)
*p = toupper((UINT8)*p);
}
- printf("%s\n", buffer);
- // output additional raw bytes
- if (!opts.norawbytes && numchunks > maxchunks)
+ // round to the nearest display chunk
+ numbytes = ((numbytes + displaychunk - 1) / displaychunk) * displaychunk;
+ if (numbytes == 0)
+ numbytes = displaychunk;
+ numchunks = numbytes / displaychunk;
+
+ // non-flipped case
+ if (!opts.flipped)
{
- for (numchunks -= maxchunks; numchunks > 0; numchunks -= maxchunks)
+ // output the address
+ printf("%08X: ", curpc);
+
+ // output the raw bytes
+ if (!opts.norawbytes)
{
int firstchunks = (numchunks < maxchunks) ? numchunks : maxchunks;
int chunknum, bytenum;
- printf(" ");
for (chunknum = 0; chunknum < firstchunks; chunknum++)
{
for (bytenum = 0; bytenum < displaychunk; bytenum++)
@@ -569,8 +555,54 @@ int main(int argc, char *argv[])
printf(" ");
oprom += displaychunk;
}
- printf("\n");
+ for ( ; chunknum < maxchunks; chunknum++)
+ printf("%*s ", displaychunk * 2, "");
+ printf(" ");
+ }
+
+ // output the disassembly
+ printf("%s\n", buffer);
+
+ // output additional raw bytes
+ if (!opts.norawbytes && numchunks > maxchunks)
+ {
+ for (numchunks -= maxchunks; numchunks > 0; numchunks -= maxchunks)
+ {
+ int firstchunks = (numchunks < maxchunks) ? numchunks : maxchunks;
+ int chunknum, bytenum;
+ printf(" ");
+ for (chunknum = 0; chunknum < firstchunks; chunknum++)
+ {
+ for (bytenum = 0; bytenum < displaychunk; bytenum++)
+ printf("%02X", oprom[displayendian ? (displaychunk - 1 - bytenum) : bytenum]);
+ printf(" ");
+ oprom += displaychunk;
+ }
+ printf("\n");
+ }
+ }
+ }
+
+ // flipped case
+ else
+ {
+ // output the disassembly and address
+ printf("\t%-40s ; %08X", buffer, curpc);
+
+ // output the raw bytes
+ if (!opts.norawbytes)
+ {
+ int chunknum, bytenum;
+ printf(": ");
+ for (chunknum = 0; chunknum < numchunks; chunknum++)
+ {
+ for (bytenum = 0; bytenum < displaychunk; bytenum++)
+ printf("%02X", oprom[displayendian ? (displaychunk - 1 - bytenum) : bytenum]);
+ printf(" ");
+ oprom += displaychunk;
+ }
}
+ printf("\n");
}
// advance