mirror of
https://github.com/mnaberez/py65.git
synced 2025-01-16 18:33:00 +00:00
Handle all syntax errors in immediate values
This commit is contained in:
parent
23bd9b9a39
commit
2dde6bdafe
@ -101,15 +101,15 @@ class Assembler:
|
||||
|
||||
# target is an immediate value
|
||||
if target.startswith('#'):
|
||||
if target[1] in ("'", '"'): # quoted ascii character
|
||||
try:
|
||||
try:
|
||||
if target[1] in ("'", '"'): # quoted ascii character
|
||||
number = ord(target[2])
|
||||
except IndexError:
|
||||
raise SyntaxError(statement)
|
||||
else:
|
||||
number = self._address_parser.number(target[1:])
|
||||
else:
|
||||
number = self._address_parser.number(target[1:])
|
||||
except IndexError:
|
||||
raise SyntaxError(statement)
|
||||
|
||||
if (number < 0x00) or (number > self._mpu.byteMask):
|
||||
if (number < 0) or (number > self._mpu.byteMask):
|
||||
raise OverflowError
|
||||
statement = before + '#$' + self._mpu.BYTE_FORMAT % number
|
||||
|
||||
|
@ -22,6 +22,8 @@ class AssemblerTests(unittest.TestCase):
|
||||
def test_assemble_bad_syntax_raises_syntaxerror(self):
|
||||
self.assertRaises(SyntaxError,
|
||||
self.assemble, 'foo')
|
||||
self.assertRaises(SyntaxError,
|
||||
self.assemble, 'lda #')
|
||||
self.assertRaises(SyntaxError,
|
||||
self.assemble, 'lda #"')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user