diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2024-04-14 15:10:43 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-04-14 15:10:43 +0300 |
| commit | 2f563af1c27f232abc0516348aa08e1f6e0a20f2 (patch) | |
| tree | b530381f88b4c8de1dac20ed0a1f416514ea7438 /test/utils.py | |
| parent | 492cc14054b243bfcc02b0c4a2289060aa4adb4f (diff) | |
Add bump allocator
Diffstat (limited to 'test/utils.py')
| -rw-r--r-- | test/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/utils.py b/test/utils.py index 873aa64..f7cd8a0 100644 --- a/test/utils.py +++ b/test/utils.py @@ -1,3 +1,6 @@ +from atk16_asm import assemble +from atk16_emu import Machine + def pad_bytearray(ba: bytearray, to_length: int = 64 * 1024) -> bytearray: """ Pads a bytearray with zeros until it reaches a specified length. @@ -23,3 +26,17 @@ def make_rom(words: list[int]) -> bytearray: bytes.append((word >> 8) & 0xFF) bytes.append(word & 0xFF) return pad_bytearray(bytearray(bytes)) + +def assemble_and_run_until_halted(filename: str) -> Machine: + with open(filename, "r") as f: + source = f.read() + + obj = assemble(source, filename) + rom_image = pad_bytearray(obj.program) + + machine = Machine() + machine.load_rom_image(rom_image) + machine.reset() + machine.run_until_halted() + + return machine
\ No newline at end of file |
