# HG changeset patch # User Mike Pavone # Date 1358481607 28800 # Node ID 7c227a8ec53d51207821b43921c73c7e55a7e207 # Parent f8955d33486db7edbd7cb30a444112a0562db47e Add instruction address logging to translator and support for reading an address log to the disassembler diff -r f8955d33486d -r 7c227a8ec53d 68kinst.c --- a/68kinst.c Thu Jan 17 08:19:29 2013 -0800 +++ b/68kinst.c Thu Jan 17 20:00:07 2013 -0800 @@ -448,7 +448,7 @@ return start+1; } istream = m68k_decode_op_ex(istream, opmode, reg, decoded->extra.size, &(decoded->dst)); - if (!istream) { + if (!istream || decoded->dst.addr_mode == MODE_IMMEDIATE) { decoded->op = M68K_INVALID; return start+1; } diff -r f8955d33486d -r 7c227a8ec53d blastem.c --- a/blastem.c Thu Jan 17 08:19:29 2013 -0800 +++ b/blastem.c Thu Jan 17 20:00:07 2013 -0800 @@ -803,12 +803,16 @@ int width = -1; int height = -1; int debug = 0; + FILE *address_log = NULL; for (int i = 2; i < argc; i++) { if (argv[i][0] == '-') { switch(argv[i][1]) { case 'd': debug = 1; break; + case 'l': + address_log = fopen("address.log", "w"); + break; default: fprintf(stderr, "Unrecognized switch %s\n", argv[i]); return 1; @@ -828,6 +832,7 @@ vdp_context v_context; init_x86_68k_opts(&opts); + opts.address_log = address_log; init_68k_context(&context, opts.native_code_map, &opts); init_vdp_context(&v_context); context.next_context = &v_context; diff -r f8955d33486d -r 7c227a8ec53d dis.c --- a/dis.c Thu Jan 17 08:19:29 2013 -0800 +++ b/dis.c Thu Jan 17 20:00:07 2013 -0800 @@ -82,6 +82,7 @@ deferred *def = NULL, *tmpd; for(uint8_t opt = 2; opt < argc; ++opt) { if (argv[opt][0] == '-') { + FILE * address_log; switch (argv[opt][1]) { case 'l': @@ -93,6 +94,26 @@ case 'o': only = 1; break; + case 'f': + opt++; + if (opt >= argc) { + fputs("-f must be followed by a filename\n", stderr); + exit(1); + } + address_log = fopen(argv[opt], "r"); + if (!address_log) { + fprintf(stderr, "Failed to open %s for reading\n", argv[opt]); + exit(1); + } + while (fgets(disbuf, sizeof(disbuf), address_log)) { + if (disbuf[0]) { + uint32_t address = strtol(disbuf, NULL, 16); + if (address) { + def = defer(address, def); + reference(address); + } + } + } } } else { uint32_t address = strtol(argv[opt], NULL, 16); diff -r f8955d33486d -r 7c227a8ec53d m68k_to_x86.c --- a/m68k_to_x86.c Thu Jan 17 08:19:29 2013 -0800 +++ b/m68k_to_x86.c Thu Jan 17 20:00:07 2013 -0800 @@ -3782,6 +3782,9 @@ exit(1); } do { + if (opts->address_log) { + fprintf(opts->address_log, "%X\n", address); + } do { if (dst_end-dst < MAX_NATIVE_SIZE) { if (dst_end-dst < 5) { diff -r f8955d33486d -r 7c227a8ec53d m68k_to_x86.h --- a/m68k_to_x86.h Thu Jan 17 08:19:29 2013 -0800 +++ b/m68k_to_x86.h Thu Jan 17 20:00:07 2013 -0800 @@ -1,4 +1,5 @@ #include +#include #include "68kinst.h" #define NUM_MEM_AREAS 4 @@ -30,6 +31,7 @@ uint8_t *cur_code; uint8_t *code_end; uint8_t **ram_inst_sizes; + FILE *address_log; } x86_68k_options; typedef struct {