X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/976db69ffa80c4d499e53f6f22c26d784fdac0a1..18d57acbf4ccd7220e59fe1f2ac1556837c5da83:/avr/cmd_mem.c diff --git a/avr/cmd_mem.c b/avr/cmd_mem.c index 3e18770..85b5a44 100644 --- a/avr/cmd_mem.c +++ b/avr/cmd_mem.c @@ -23,6 +23,7 @@ #include "eval_arg.h" #include "timer.h" #include "z80-if.h" +#include "disas_z180.h" #include "debug.h" @@ -33,6 +34,7 @@ /* Display values from last command. * Memory modify remembered values are different from display memory. */ +static uint32_t disas_last_addr; static uint32_t dp_last_addr; static uint32_t dp_last_length = 0x100; static uint32_t mm_last_addr; @@ -66,6 +68,52 @@ command_ret_t do_mem_size(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int return CMD_RET_SUCCESS; } +/* +* Disassemble code from memory +* +* Usage: +* disassemble address [# of lines] +* + */ +command_ret_t do_disas(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]) +{ + (void) cmdtp; + + /* We use the last specified parameters, unless new ones are + * entered. + */ + uint32_t addr = disas_last_addr; + int length = 16; + int ret = CMD_RET_SUCCESS; + + if (argc < 2) + return CMD_RET_USAGE; + + if ((flag & CMD_FLAG_REPEAT) == 0) { + /* Address is specified since argc > 1 */ + addr = eval_arg(argv[1], NULL); + addr += base_address; + + /* If another parameter, it is the length (Number of lines) to display. */ + if (argc > 2) + length = (int) eval_arg(argv[2], NULL); + } + + z80_bus_request_or_exit(); + clear_ctrlc(); /* forget any previous Control-C */ + for (; length > 0; --length) { + addr = dis_decode(addr); + if (had_ctrlc() || ctrlc()) { + ret = CMD_RET_FAILURE; + break; + } + } + z80_bus_cmd(Release); + disas_last_addr = addr; + + return ret; +} + /* Memory Display * * Syntax: