Skip to content

Commit 997d2aa

Browse files
rootk1nsom
authored andcommitted
[FIX] Test: fix tinyfive test case lack of "load_asm"
Des: 1. Keep self._m = None. 2. Add a simple load_asm() function in StubProfiledMachine, responsible for saving valid assembly lines to _code_words. 3. Neither is it necessary to call the parent class's load_asm() method, nor to manipulate self._m. Signed-off-by: root <root@DESKTOP-HCT8BMP.localdomain>
1 parent 58e415a commit 997d2aa

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎scratchv/simulator/tinyfive.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@ def load_binary(self, words: list[int], origin: int = 0):
227227
self._pc = origin
228228
self._code_words = words
229229

230+
def load_asm(self, asm_lines: list[str], origin: int = 0x200):
231+
self._pc = origin
232+
self._code_words = []
233+
234+
for line in asm_lines:
235+
line = line.split("#")[0].strip()
236+
if not line or line.endswith(":"):
237+
continue
238+
self._code_words.append(line)
239+
230240
def load_data(self, data: bytes, addr: int):
231241
for i, b in enumerate(data):
232242
self.memory[addr + i] = b
@@ -279,7 +289,7 @@ def verify_assembly(asm_code: str, verbose: bool = False) -> dict:
279289
}
280290

281291
lines = asm_code.strip().split("\n")
282-
m.load_asm(lines, origin=0)
292+
load_asm(lines, origin=0)
283293

284294
try:
285295
m.run(instructions=100_000_000)

0 commit comments

Comments
 (0)