From 2880a59dbb84b3859061db41154d04c8cdc6d7f1 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Fri, 11 Feb 2022 18:53:26 +0100 Subject: [PATCH] fixed ascii escape sequences and section address calculation --- riscemu/assembler.py | 3 +++ riscemu/types.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/riscemu/assembler.py b/riscemu/assembler.py index ec63833..de29044 100644 --- a/riscemu/assembler.py +++ b/riscemu/assembler.py @@ -173,6 +173,9 @@ class AssemblerDirectives: @classmethod def add_text(cls, text: str, context: ParseContext, zero_terminate: bool = True): + # replace '\t' and '\n' escape sequences + text = text.replace('\\n', '\n').replace('\\t', '\t') + encoded_bytes = bytearray(text.encode('ascii')) if zero_terminate: encoded_bytes += bytearray(1) diff --git a/riscemu/types.py b/riscemu/types.py index b265cb9..e2895f0 100644 --- a/riscemu/types.py +++ b/riscemu/types.py @@ -65,7 +65,7 @@ class InstructionContext: global_symbol_dict: Dict[str, T_AbsoluteAddress] """ - A reference to the MMU for access to global symbols + A reference to the MMU's global symbol dictionary for access to global symbols """ def __init__(self): @@ -264,7 +264,7 @@ class Program: return base + self.context.labels.get('main') for sec in self.sections: if get_section_base_name(sec.name) == '.text' and sec.flags.executable: - return base + sec.base + return sec.base def loaded_trigger(self, at_addr: T_AbsoluteAddress): """