From c69ebc34ca53c73e834a91e05e93ae3850a55c64 Mon Sep 17 00:00:00 2001 From: Mike Naberezny Date: Sat, 25 Jan 2014 21:30:27 -0800 Subject: [PATCH] Assembling now tolerates extra whitespace between opcode and operand --- CHANGES.txt | 2 ++ py65/assembler.py | 2 ++ py65/tests/test_assembler.py | 3 +++ 3 files changed, 7 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index d87736c..1af00cb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,8 @@ - Fixed BRK on 65C02 so it clears the decimal flag. On NMOS 6502, the decimal flag is unaffected on BRK. On 65C02, it is always cleared. + - Assembling now tolerates extra whitespace between opcode and operand. + 0.17 (2013-10-26) - Added support for Python 3.2 and 3.3 based on work by David Beazley. diff --git a/py65/assembler.py b/py65/assembler.py index 9dfbf1d..64505fd 100644 --- a/py65/assembler.py +++ b/py65/assembler.py @@ -145,6 +145,8 @@ class Assembler: and parsing the address part using AddressParser. The result of the normalization is a tuple of two strings (opcode, operand). """ + statement = ' '.join(str.split(statement)) + # normalize target in operand match = self.Statement.match(statement) if match: diff --git a/py65/tests/test_assembler.py b/py65/tests/test_assembler.py index 4c3be7c..6774bd9 100644 --- a/py65/tests/test_assembler.py +++ b/py65/tests/test_assembler.py @@ -15,6 +15,9 @@ class AssemblerTests(unittest.TestCase): self.assertRaises(KeyError, self.assemble, 'lda foo') + def test_assemble_tolerates_extra_whitespace(self): + self.assemble(' lda #$00 ') # should not raise + def test_assemble_bad_number_raises_overflowerror(self): self.assertRaises(OverflowError, self.assemble, 'lda #$fff')