fixed ascii escape sequences and section address calculation

assembly-parser-rework
Anton Lydike 3 years ago
parent 7904a4dae8
commit 2880a59dbb

@ -173,6 +173,9 @@ class AssemblerDirectives:
@classmethod @classmethod
def add_text(cls, text: str, context: ParseContext, zero_terminate: bool = True): 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')) encoded_bytes = bytearray(text.encode('ascii'))
if zero_terminate: if zero_terminate:
encoded_bytes += bytearray(1) encoded_bytes += bytearray(1)

@ -65,7 +65,7 @@ class InstructionContext:
global_symbol_dict: Dict[str, T_AbsoluteAddress] 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): def __init__(self):
@ -264,7 +264,7 @@ class Program:
return base + self.context.labels.get('main') return base + self.context.labels.get('main')
for sec in self.sections: for sec in self.sections:
if get_section_base_name(sec.name) == '.text' and sec.flags.executable: 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): def loaded_trigger(self, at_addr: T_AbsoluteAddress):
""" """

Loading…
Cancel
Save