From 972a8ac8f107d8529ed2cccf62e672ef965bb5ed Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Tue, 7 Feb 2023 17:30:29 +0000 Subject: [PATCH] more asm test --- asm_test.py | 6 ++++++ creole_asm.py | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/asm_test.py b/asm_test.py index 481875b..016f634 100644 --- a/asm_test.py +++ b/asm_test.py @@ -12,6 +12,12 @@ class ProgramTest(unittest.TestCase): p.parse_asm_line("PUSH r134217727") b = p() self.assertEqual(b, b'\x01\xFC\x87\xbf\xbf\xbf\xbf\x00') + def test_two(self): + p = Program() + p.parse_asm_line("PUSH r1") + p.parse_asm_line("ADD r1 5 6") + b = p() + self.assertEqual(b, b'\x01\xC2\x81\x00\x03\xC2\x81\xC0\x85\xC0\x86\x00') if __name__ == "__main__": unittest.main() diff --git a/creole_asm.py b/creole_asm.py index 8f7ab22..8e87b58 100644 --- a/creole_asm.py +++ b/creole_asm.py @@ -130,10 +130,11 @@ class Line: def __call__(self): b = bytes([self.opcode]) for a in self.args: + l = 2 if a[1] < 0x80 else None if a[0] == ArgType.REG: - b = b + encode_pseudo_utf8(a[1],1,None) + b = b + encode_pseudo_utf8(a[1],1,l) else: - b = b + encode_pseudo_utf8(a[1],0,None) + b = b + encode_pseudo_utf8(a[1],0,l) return b + bytes([0]) class InstructionNotFoundException(Exception):