-/*
- print the current state of the machine
- shows current cycle count, registers, and next instruction
-*/
-void dcpu16_state_print(struct dcpu16 *vm) {
- unsigned int i;
-
- if (!vm) return;
-
- printf(" ");
- for (i = 0; i < 8; i++)
- printf(" %s:0x%04x", dcpu16_reg_names[i], vm->reg[i]);
- printf("\n");
-
- printf("(0x%08llx) %2s:0x%04x %2s:0x%04x %2s:0x%04x %2s:0x%04x [%2s]:",
- vm->cycle_,
- dcpu16_reg_names[DCPU16_REG_EX], vm->reg[DCPU16_REG_EX],
- dcpu16_reg_names[DCPU16_REG_SP], vm->reg[DCPU16_REG_SP],
- dcpu16_reg_names[DCPU16_REG_PC], vm->reg[DCPU16_REG_PC],
- dcpu16_reg_names[DCPU16_REG_IA], vm->reg[DCPU16_REG_IA],
- "PC");
-
- dcpu16_disassemble_print(vm, vm->reg[DCPU16_REG_PC]);
- printf("\n");
-}
-
-/* dcpu16_dump_ram
- * print raw ram contents from start to stop
- */
-void dcpu16_dump_ram(struct dcpu16 *vm, DCPU16_WORD start, DCPU16_WORD end) {
- unsigned int i, j;
- const unsigned int n = 8; /* words per line */
-
- if (!vm) return;
-
- for (i = start, j = 0; i <= end; i++, j++) {
- if (j % n == 0)
- printf("0x%04x:\t", i);
- printf(" %04x%s", vm->ram[i], (j % n) == (n - 1) ? "\n" : "");
- }
- if ((j % n) != (n - 1))
- printf("\n");
-}