summaryrefslogtreecommitdiff
path: root/avr/cmd_mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'avr/cmd_mem.c')
-rw-r--r--avr/cmd_mem.c48
1 files changed, 48 insertions, 0 deletions
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: