Added -flipped option to unidasm to output with disassembly

first and address/data bytes afterwards in comment form.
This commit is contained in:
Aaron Giles 2009-10-31 19:46:55 +00:00
parent 8b430a357f
commit 721087eeeb

View File

@ -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,12 +519,27 @@ int main(int argc, char *argv[])
else
numbytes = pcdelta >> opts.dasm->pcshift;
// force upper or lower
if (opts.lower)
{
for (p = buffer; *p != 0; p++)
*p = tolower((UINT8)*p);
}
else if (opts.upper)
{
for (p = buffer; *p != 0; p++)
*p = toupper((UINT8)*p);
}
// 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)
{
// output the address
printf("%08X: ", curpc);
@ -542,16 +561,6 @@ int main(int argc, char *argv[])
}
// output the disassembly
if (opts.lower)
{
for (p = buffer; *p != 0; p++)
*p = tolower((UINT8)*p);
}
else if (opts.upper)
{
for (p = buffer; *p != 0; p++)
*p = toupper((UINT8)*p);
}
printf("%s\n", buffer);
// output additional raw bytes
@ -572,6 +581,29 @@ int main(int argc, char *argv[])
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
curpc += pcdelta;