From fe4b3efb6feb4357e71bb67e0114f891ec08c56d Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Thu, 31 Mar 2022 22:46:23 +0200 Subject: [PATCH] fixes #10 - fixed how preconfigured memory is handled --- riscemu/assembler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/riscemu/assembler.py b/riscemu/assembler.py index 59165bf..44a7113 100644 --- a/riscemu/assembler.py +++ b/riscemu/assembler.py @@ -6,7 +6,8 @@ from .colors import FMT_PARSE, FMT_NONE from riscemu.types.exceptions import ParseException, ASSERT_LEN from .helpers import parse_numeric_argument, align_addr, get_section_base_name from .tokenizer import Token -from .types import Program, T_RelativeAddress, InstructionContext, Instruction, BinaryDataMemorySection, InstructionMemorySection +from .types import Program, T_RelativeAddress, InstructionContext, Instruction, BinaryDataMemorySection, \ + InstructionMemorySection, Int32 INSTRUCTION_SECTION_NAMES = ('.text', '.init', '.fini') """ @@ -167,13 +168,13 @@ class AssemblerDirectives: cls.add_bytes(size, bytearray(size), context) @classmethod - def add_bytes(cls, size: int, content: Union[None, int, bytearray], context: ParseContext, unsigned=False): + def add_bytes(cls, size: int, content: Union[None, int, bytearray], context: ParseContext): ASSERT_IN_SECTION_TYPE(context, MemorySectionType.Data) if content is None: content = bytearray(size) if isinstance(content, int): - content = bytearray(content.to_bytes(size, 'little', signed=not unsigned)) + content = Int32(content).to_bytes(size) context.section.data += content