Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thecl ECL address output with '-x' param #103

Merged
merged 3 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion thecl/thecl.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extern const thecl_module_t th10_ecl;
eclmap_t *g_eclmap = NULL;
bool g_ecl_rawoutput = false;
bool g_ecl_simplecreate = false;
bool g_ecl_hexdebug = false;
bool g_was_error = false;

thecl_t*
Expand Down Expand Up @@ -251,6 +252,7 @@ print_usage(void)
" -m use map file for translating mnemonics\n"
" -r output raw ECL opcodes, applying minimal transformations\n"
" -s use simple creation, which doesn't add any instructions automatically\n"
" -x add address information for ECL instructions\n"
"VERSION can be:\n"
" 6, 7, 8, 9, 95, 10, 103 (for Uwabami Breakers), 11, 12, 125, 128, 13, 14, 143, 15, 16, 165, 17, 18 or 185\n"
/* NEWHU: 185 */
Expand All @@ -276,7 +278,7 @@ main(int argc, char* argv[])
int opt;
int ind=0;
while(argv[util_optind]) {
switch(opt = util_getopt(argc, argv, ":c:h:d:Vm:rs")) {
switch(opt = util_getopt(argc, argv, ":c:h:d:Vm:rsx")) {
case 'c':
case 'd':
case 'h':
Expand Down Expand Up @@ -306,6 +308,9 @@ main(int argc, char* argv[])
case 's':
g_ecl_simplecreate = true;
break;
case 'x':
g_ecl_hexdebug = true;
break;
default:
util_getopt_default(&ind,argv,opt,print_usage);
}
Expand Down Expand Up @@ -362,6 +367,12 @@ main(int argc, char* argv[])
exit(1);
}
}
if (g_ecl_hexdebug) {
if (mode != 'd') {
fprintf(stderr, "%s: 'x' option cannot be used while compiling\n", argv0);
exit(1);
}
}
if (g_ecl_simplecreate) {
if (mode != 'c' && mode != 'h') {
fprintf(stderr, "%s: 's' option cannot be used while dumping\n", argv0);
Expand Down
4 changes: 4 additions & 0 deletions thecl/thecl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ typedef struct thecl_instr_t {

/* Used by ecsparse.y, not present anywhere in the compiled ECL files. */
unsigned int flags;

/* Used in developer dump mode */
uint32_t address;
} thecl_instr_t;

thecl_instr_t* thecl_instr_new(
Expand Down Expand Up @@ -261,6 +264,7 @@ extern int yyparse(parser_state_t*);

extern eclmap_t* g_eclmap;
extern bool g_ecl_rawoutput;
extern bool g_ecl_hexdebug;
extern bool g_ecl_simplecreate;
extern bool g_was_error;

Expand Down
9 changes: 7 additions & 2 deletions thecl/thecl06.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ th06_open(
instr->id = raw_instr->id;
instr->size = raw_instr->size;
instr->offset = (ptrdiff_t)raw_instr - (ptrdiff_t)raw_sub;
instr->address = instr->offset + header->offsets[timeline_count_max + s];

const char* format;

Expand All @@ -999,7 +1000,7 @@ th06_open(
raw_instr->size,
raw_instr->rank_mask,
raw_instr->param_mask
);
);

for (size_t d = 0; d < raw_instr->size - sizeof(th06_instr_t); d += 4) {
fprintf(stderr, " %08x (%d, %f)",
Expand Down Expand Up @@ -1181,7 +1182,11 @@ th06_dump(
fprintf(out, " %s(", ent->value);
}
else {
fprintf(out, " ins_%u(", instr->id);
if (g_ecl_hexdebug) {
fprintf(out, " %x: ins_%u(", instr->address, instr->id);
} else {
fprintf(out, " ins_%u(", instr->id);
}
}
thecl_param_t* param;
int first = 1;
Expand Down
6 changes: 5 additions & 1 deletion thecl/thecl10.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,7 @@ th10_open(
new_instr->id = instr->id;
new_instr->param_count = instr->param_count;
new_instr->offset = (ptrdiff_t)instr - (ptrdiff_t)raw_sub;
new_instr->address = (ptrdiff_t)new_instr->offset + sub_offsets[i];
list_init(&new_instr->params);

uint32_t param_mask = instr->param_mask;
Expand Down Expand Up @@ -1730,7 +1731,10 @@ th10_stringify_instr(
sprintf(string, "%s(", ent->value);
}
else {
sprintf(string, "ins_%u(", instr->id);
if(g_ecl_hexdebug)
sprintf(string, "%x: ins_%u(",instr->address, instr->id);
else
sprintf(string, "ins_%u(", instr->address, instr->id);
}

size_t removed = 0;
Expand Down