From 6dd1e346d330e662e42dd8bc75d17317223908fd Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 24 Feb 2024 20:30:17 +0200 Subject: Add setup.py, fix bugs --- atk16_asm/assembler.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'atk16_asm/assembler.py') diff --git a/atk16_asm/assembler.py b/atk16_asm/assembler.py index 1451d47..993472e 100755 --- a/atk16_asm/assembler.py +++ b/atk16_asm/assembler.py @@ -9,6 +9,7 @@ from .asm_pass1 import pass_1 from .asm_pass2 import pass_2 from .asm_pass3 import pass_3 from .asm_pass4 import pass_4 +from .pad_bin import pad_binary def assemble(source: str, file_name: str) -> bytearray: src_lines = source.splitlines() @@ -41,7 +42,7 @@ def assemble(source: str, file_name: str) -> bytearray: return result -if __name__ == "__main__": +def main(): if len(sys.argv) != 3: print("usage: assembler.py # read from file") print(" assembler.py - # read from stdin") @@ -59,7 +60,13 @@ if __name__ == "__main__": src = f.read() result = assemble(src, infile_path) + with open(outfile_path, "wb") as f: f.write(result) - print(f"Wrote {len(result)} bytes to {outfile_path}") + pad_binary(outfile_path, 64 * 1024) + + print(f"Wrote 64 KB to {outfile_path} ({len(result)} B without padding)") + +if __name__ == "__main__": + main() -- cgit v1.3