From 9aaaf7313f1125c7b6fec90e1ad457ec405d9344 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Sun, 18 Apr 2021 10:38:36 +0200 Subject: [PATCH] added pseudo-op .set name val, and .global symb --- riscemu/ExecutableParser.py | 12 ++++++++++++ riscemu/MMU.py | 2 ++ 2 files changed, 14 insertions(+) diff --git a/riscemu/ExecutableParser.py b/riscemu/ExecutableParser.py index 0cfbd17..36e0ba7 100644 --- a/riscemu/ExecutableParser.py +++ b/riscemu/ExecutableParser.py @@ -18,6 +18,7 @@ class ExecutableParser: self.active_section: Optional[str] = None self.implicit_sections = False self.stack_pref: Optional[int] = None + self.globals: List[str] = list() def parse(self): for token in self.tokenizer.tokens: @@ -100,6 +101,17 @@ class ExecutableParser: size = parse_numeric_argument(op.args) self.stack_pref = size + def op_global(self, op: 'RiscVPseudoOpToken'): + ASSERT_LEN(op.args, 1) + name = op.args[1] + self.globals.append(name) + + def op_set(self, op: 'RiscVPseudoOpToken'): + ASSERT_LEN(op.args, 2) + name = op.args[0] + val = parse_numeric_argument(op.args[1]) + self.symbols[name] = ('_static_', val) + ## Section handler code def set_sec(self, name: str, flags: MemoryFlags, cls=MemorySection): if name not in self.sections: diff --git a/riscemu/MMU.py b/riscemu/MMU.py index e913fda..d96ca47 100644 --- a/riscemu/MMU.py +++ b/riscemu/MMU.py @@ -13,6 +13,8 @@ class MMU: binaries: List[LoadedExecutable] last_bin: Optional[LoadedExecutable] = None + global_symbols: Dict[str, int] + def __init__(self, conf: RunConfig): self.sections = list() self.binaries = list()