diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2022-05-11 21:48:10 -0400 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2022-05-11 21:48:20 -0400 |
commit | c452dcd0b596883f5110b94cb856a045c8a7a171 (patch) | |
tree | 37f484f0eee64d19dd7587df9fe327b31dcd7c74 | |
parent | f6b18012bc948438dd5dc5e1abf205c1aea43744 (diff) |
unidasm: Option-related changes
- Eliminate -mode option that has done nothing for years
- Allow -basepc address and -skip count to be specified in octal
-rw-r--r-- | src/tools/unidasm.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp index 708fc9bf7a1..46c835417e5 100644 --- a/src/tools/unidasm.cpp +++ b/src/tools/unidasm.cpp @@ -362,7 +362,6 @@ struct options uint8_t lower; uint8_t upper; uint8_t flipped; - int mode; const dasm_table_entry *dasm; uint32_t skip; uint32_t count; @@ -1109,7 +1108,6 @@ static int parse_options(int argc, char *argv[], options *opts) { bool pending_base = false; bool pending_arch = false; - bool pending_mode = false; bool pending_skip = false; bool pending_count = false; @@ -1121,7 +1119,7 @@ static int parse_options(int argc, char *argv[], options *opts) // is it a switch? if(curarg[0] == '-' && curarg[1] != '\0') { - if(pending_base || pending_arch || pending_mode || pending_skip || pending_count) + if(pending_base || pending_arch || pending_skip || pending_count) goto usage; if(tolower((uint8_t)curarg[1]) == 'a') @@ -1132,8 +1130,6 @@ static int parse_options(int argc, char *argv[], options *opts) opts->flipped = true; else if(tolower((uint8_t)curarg[1]) == 'l') opts->lower = true; - else if(tolower((uint8_t)curarg[1]) == 'm') - pending_mode = true; else if(tolower((uint8_t)curarg[1]) == 's') pending_skip = true; else if(tolower((uint8_t)curarg[1]) == 'c') @@ -1152,8 +1148,14 @@ static int parse_options(int argc, char *argv[], options *opts) } else if(pending_base) { // base PC int result; - if(curarg[0] == '0' && curarg[1] == 'x') - result = sscanf(&curarg[2], "%x", &opts->basepc); + if(curarg[0] == '0') { + if(tolower((uint8_t)curarg[1]) == 'x') + result = sscanf(&curarg[2], "%x", &opts->basepc); + else if(tolower((uint8_t)curarg[1]) == 'o') + result = sscanf(&curarg[2], "%o", &opts->basepc); + else + result = sscanf(&curarg[1], "%o", &opts->basepc); + } else if(curarg[0] == '$') result = sscanf(&curarg[1], "%x", &opts->basepc); else @@ -1162,12 +1164,6 @@ static int parse_options(int argc, char *argv[], options *opts) goto usage; pending_base = false; - } else if(pending_mode) { - // mode - if(sscanf(curarg, "%d", &opts->mode) != 1) - goto usage; - pending_mode = false; - } else if(pending_arch) { // architecture auto const arch = std::find_if( @@ -1182,8 +1178,16 @@ static int parse_options(int argc, char *argv[], options *opts) } else if(pending_skip) { // skip bytes int result; - if(curarg[0] == '0' && curarg[1] == 'x') - result = sscanf(&curarg[2], "%x", &opts->skip); + if(curarg[0] == '0') { + if(tolower((uint8_t)curarg[1]) == 'x') + result = sscanf(&curarg[2], "%x", &opts->skip); + else if(tolower((uint8_t)curarg[1]) == 'o') + result = sscanf(&curarg[2], "%o", &opts->skip); + else + result = sscanf(&curarg[1], "%o", &opts->skip); + } + else if(curarg[0] == '$') + result = sscanf(&curarg[1], "%x", &opts->skip); else result = sscanf(curarg, "%d", &opts->skip); if(result != 1) @@ -1207,7 +1211,7 @@ static int parse_options(int argc, char *argv[], options *opts) } // if we have a dangling option, error - if(pending_base || pending_arch || pending_mode || pending_skip || pending_count) + if(pending_base || pending_arch || pending_skip || pending_count) goto usage; // if no file or no architecture, fail @@ -1218,7 +1222,7 @@ static int parse_options(int argc, char *argv[], options *opts) usage: printf("Usage: %s <filename> -arch <architecture> [-basepc <pc>] \n", argv[0]); - printf(" [-mode <n>] [-norawbytes] [-xchbytes] [-flipped] [-upper] [-lower]\n"); + printf(" [-norawbytes] [-xchbytes] [-flipped] [-upper] [-lower]\n"); printf(" [-skip <n>] [-count <n>] [-octal]\n"); printf("\n"); printf("Supported architectures:"); |