diff --git a/riscemu/colors.py b/riscemu/colors.py index 8b5ddbb..c2a7182 100644 --- a/riscemu/colors.py +++ b/riscemu/colors.py @@ -26,3 +26,4 @@ FMT_PARSE = FMT_CYAN + FMT_BOLD FMT_CPU = FMT_BLUE + FMT_BOLD FMT_SYSCALL = FMT_YELLOW + FMT_BOLD FMT_DEBUG = FMT_MAGENTA + FMT_BOLD +FMT_CSR = FMT_ORANGE + FMT_BOLD \ No newline at end of file diff --git a/riscemu/priv/CSR.py b/riscemu/priv/CSR.py index 1327315..ef67696 100644 --- a/riscemu/priv/CSR.py +++ b/riscemu/priv/CSR.py @@ -3,6 +3,8 @@ from collections import defaultdict from .privmodes import PrivModes from .Exceptions import InstructionAccessFault from ..helpers import to_unsigned +from ..colors import FMT_CSR, FMT_NONE + from .CSRConsts import CSR_NAME_TO_ADDR, MSTATUS_LEN_2, MSTATUS_OFFSETS class CSR: @@ -109,3 +111,13 @@ class CSR: return func return inner + + def dump_mstatus(self): + print(FMT_CSR + "[CSR] dumping mstatus:") + i = 0 + for name in MSTATUS_OFFSETS: + print(" {:<5} {}".format(name, self.get_mstatus(name)), end="") + if i % 6 == 5: + print() + i += 1 + print(FMT_NONE)