From 462639ade7db93536b3564d9eedcbd5f9668b1da Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Sat, 24 Apr 2021 18:24:42 +0200 Subject: [PATCH] Added run_ins method to debugger to run an instruction --- riscemu/debug.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/riscemu/debug.py b/riscemu/debug.py index 5798c99..9e6704d 100644 --- a/riscemu/debug.py +++ b/riscemu/debug.py @@ -4,10 +4,10 @@ RiscEmu (c) 2021 Anton Lydike SPDX-License-Identifier: MIT """ - import typing from .Registers import Registers from .colors import FMT_DEBUG, FMT_NONE +from .Executable import LoadedInstruction if typing.TYPE_CHECKING: from . import * @@ -40,6 +40,18 @@ def launch_debug_session(cpu: 'CPU', mmu: 'MMU', reg: 'Registers', prompt=""): print("Current instruction at 0x{:08X}:".format(cpu.pc)) return mmu.read_ins(cpu.pc) + def run_ins(name, *args: str): + if len(args) > 3: + print("Invalid arg count!") + return + bin = mmu.get_bin_containing(cpu.pc) + if bin is None: + print(FMT_DEBUG + '[Debugger] Not in a section, can\'t execute instructions!' + FMT_NONE) + return + ins = LoadedInstruction(name, list(args), bin) + print(FMT_DEBUG + "Running instruction " + ins + FMT_NONE) + cpu.run_instruction(ins) + def cont(verbose=False): cpu.continue_from_debugger(verbose)