mirror of
https://github.com/holub/mame
synced 2025-05-24 23:05:32 +03:00
Added -flipped option to unidasm to output with disassembly
first and address/data bytes afterwards in comment form.
This commit is contained in:
parent
8b430a357f
commit
721087eeeb
@ -81,6 +81,7 @@ struct _options
|
|||||||
UINT8 norawbytes;
|
UINT8 norawbytes;
|
||||||
UINT8 lower;
|
UINT8 lower;
|
||||||
UINT8 upper;
|
UINT8 upper;
|
||||||
|
UINT8 flipped;
|
||||||
int mode;
|
int mode;
|
||||||
const dasm_table_entry *dasm;
|
const dasm_table_entry *dasm;
|
||||||
};
|
};
|
||||||
@ -379,6 +380,8 @@ static int parse_options(int argc, char *argv[], options *opts)
|
|||||||
pending_arch = TRUE;
|
pending_arch = TRUE;
|
||||||
else if (tolower((UINT8)curarg[1]) == 'b')
|
else if (tolower((UINT8)curarg[1]) == 'b')
|
||||||
pending_base = TRUE;
|
pending_base = TRUE;
|
||||||
|
else if (tolower((UINT8)curarg[1]) == 'f')
|
||||||
|
opts->flipped = TRUE;
|
||||||
else if (tolower((UINT8)curarg[1]) == 'l')
|
else if (tolower((UINT8)curarg[1]) == 'l')
|
||||||
opts->lower = TRUE;
|
opts->lower = TRUE;
|
||||||
else if (tolower((UINT8)curarg[1]) == 'm')
|
else if (tolower((UINT8)curarg[1]) == 'm')
|
||||||
@ -445,7 +448,8 @@ static int parse_options(int argc, char *argv[], options *opts)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
usage:
|
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("\n");
|
||||||
printf("Supported architectures:");
|
printf("Supported architectures:");
|
||||||
numrows = (ARRAY_LENGTH(dasm_table) + 6) / 7;
|
numrows = (ARRAY_LENGTH(dasm_table) + 6) / 7;
|
||||||
@ -515,33 +519,7 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
numbytes = pcdelta >> opts.dasm->pcshift;
|
numbytes = pcdelta >> opts.dasm->pcshift;
|
||||||
|
|
||||||
// round to the nearest display chunk
|
// force upper or lower
|
||||||
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
|
|
||||||
if (opts.lower)
|
if (opts.lower)
|
||||||
{
|
{
|
||||||
for (p = buffer; *p != 0; p++)
|
for (p = buffer; *p != 0; p++)
|
||||||
@ -552,16 +530,24 @@ int main(int argc, char *argv[])
|
|||||||
for (p = buffer; *p != 0; p++)
|
for (p = buffer; *p != 0; p++)
|
||||||
*p = toupper((UINT8)*p);
|
*p = toupper((UINT8)*p);
|
||||||
}
|
}
|
||||||
printf("%s\n", buffer);
|
|
||||||
|
|
||||||
// output additional raw bytes
|
// round to the nearest display chunk
|
||||||
if (!opts.norawbytes && numchunks > maxchunks)
|
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 firstchunks = (numchunks < maxchunks) ? numchunks : maxchunks;
|
||||||
int chunknum, bytenum;
|
int chunknum, bytenum;
|
||||||
printf(" ");
|
|
||||||
for (chunknum = 0; chunknum < firstchunks; chunknum++)
|
for (chunknum = 0; chunknum < firstchunks; chunknum++)
|
||||||
{
|
{
|
||||||
for (bytenum = 0; bytenum < displaychunk; bytenum++)
|
for (bytenum = 0; bytenum < displaychunk; bytenum++)
|
||||||
@ -569,8 +555,54 @@ int main(int argc, char *argv[])
|
|||||||
printf(" ");
|
printf(" ");
|
||||||
oprom += displaychunk;
|
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
|
// advance
|
||||||
|
Loading…
Reference in New Issue
Block a user