1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-06 01:50:24 +00:00

Add hexdump command

This commit is contained in:
Peter Evans 2018-03-09 16:44:53 -06:00
parent 267171ea4a
commit 1ff5d17f19
3 changed files with 32 additions and 0 deletions

View File

@ -80,6 +80,7 @@ extern void vm_debug_unbreak_all();
extern DEBUG_CMD(break);
extern DEBUG_CMD(dblock);
extern DEBUG_CMD(disasm);
extern DEBUG_CMD(hdump);
extern DEBUG_CMD(help);
extern DEBUG_CMD(jump);
extern DEBUG_CMD(printaddr);

View File

@ -39,6 +39,8 @@ vm_debug_cmd cmdtable[] = {
"Disassemble a block of code", },
{ "disasm", "d", vm_debug_cmd_disasm, 0, "",
"Toggle disassembly", },
{ "hdump", "hd", vm_debug_cmd_hdump, 2, "<from> <to>",
"Hex dump memory in a given region", },
{ "help", "h", vm_debug_cmd_help, 0, "",
"Print out this list of commands", },
{ "jump", "j", vm_debug_cmd_jump, 1, "<addr>",
@ -454,3 +456,18 @@ DEBUG_CMD(dblock)
mos6502_dis_scan(cpu, stream, args->addr1, args->addr2);
}
/*
* Print a hex dump of a region of memory
*/
DEBUG_CMD(hdump)
{
if (args->addr1 > args->addr2) {
return;
}
mos6502 *cpu = (mos6502 *)vm_di_get(VM_CPU);
FILE *stream = log_stream();
vm_segment_hexdump(cpu->rmem, stream, args->addr1, args->addr2);
}

View File

@ -288,3 +288,17 @@ Test(vm_debug, cmd_dblock)
vm_debug_cmd_dblock(&args);
cr_assert_neq(strlen(buf), 0);
}
Test(vm_debug, cmd_hdump)
{
for (int i = 0; i < 16; i++) {
mos6502_set(mach->cpu, i, i + 0x30);
}
args.addr1 = 0;
args.addr2 = 32;
vm_debug_cmd_hdump(&args);
cr_assert_neq(strlen(buf), 0);
}