Skip to content

Commit

Permalink
Add byte list and word list
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberZHG committed Nov 28, 2021
1 parent b996a51 commit a492a82
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 48 deletions.
2 changes: 1 addition & 1 deletion asm_6502/__init__.py
@@ -1,4 +1,4 @@
from .grammar import *
from .assemble import *

__version__ = '0.1.0'
__version__ = '0.1.1'
45 changes: 34 additions & 11 deletions asm_6502/assemble.py
Expand Up @@ -215,9 +215,14 @@ def __repr__(self):

class Assembler(object):

def __init__(self, max_memory=0x10000, program_entry=0xfffc):
def __init__(self,
max_memory=0x10000,
program_entry=0xfffc,
brk_size=2):
self.max_memory = max_memory
self.program_entry = program_entry
self.brk_size = brk_size
assert brk_size in {1, 2}, 'The size of BRK should be in {1, 2}'

self.code_start = -1 # The offset of the first instruction that can be executed
self.code_offset = 0 # Current offset
Expand Down Expand Up @@ -341,7 +346,7 @@ def inner(self, index, addressing, *args, **kwargs):
return func(self, index, addressing, *args, **kwargs)
return inner

def _resolve_address_recur(self, arithmetic: Union[Integer, Arithmetic]) -> Integer:
def _resolve_address_recur(self, arithmetic: Union[Integer, Arithmetic]) -> Union[Integer, List[Integer]]:
if arithmetic is None:
return None
if isinstance(arithmetic, Integer):
Expand All @@ -366,6 +371,8 @@ def _resolve_address_recur(self, arithmetic: Union[Integer, Arithmetic]) -> Inte
return self._resolve_address_recur(arithmetic.param).low_byte()
if arithmetic.mode == Arithmetic.HIGH_BYTE:
return self._resolve_address_recur(arithmetic.param).high_byte()
if arithmetic.mode == Arithmetic.LIST:
return [self._resolve_address_recur(p) for p in arithmetic.param]

def _resolve_address(self, addressing: Addressing) -> Addressing:
return Addressing(mode=addressing.mode,
Expand Down Expand Up @@ -521,32 +528,48 @@ def gen_end(self, index, addressing: Addressing):
address = Integer(is_word=True, value=self.codes[-1][0])
self.codes[-1][1].extend([0x4C, address.low_byte().value, address.high_byte().value])

@_addressing_guard(allowed={Addressing.ADDRESS})
@_addressing_guard(allowed={Addressing.ADDRESS, Addressing.LIST})
def pre_byte(self, addressing: Addressing):
if addressing.mode == Addressing.LIST:
return len(addressing.address.param)
return 1

@_assemble_guard
def gen_byte(self, index, addressing: Addressing):
if addressing.address.value > 0xFF:
raise AssembleError(f"{hex(addressing.address.value)} can not fit in a byte at line {self.line_number}")
self._extend_byte(addressing.address.value)
if addressing.mode == Addressing.LIST:
for byte in addressing.address:
if byte.value > 0xFF:
raise AssembleError(f"{hex(byte.value)} can not fit in a byte "
f"at line {self.line_number}")
self._extend_byte(byte.value)
else:
if addressing.address.value > 0xFF:
raise AssembleError(f"{hex(addressing.address.value)} can not fit in a byte "
f"at line {self.line_number}")
self._extend_byte(addressing.address.value)

@_addressing_guard(allowed={Addressing.ADDRESS})
@_addressing_guard(allowed={Addressing.ADDRESS, Addressing.LIST})
def pre_word(self, addressing: Addressing):
if addressing.mode == Addressing.LIST:
return len(addressing.address.param) * 2
return 2

@_assemble_guard
def gen_word(self, index, addressing: Addressing):
self.codes[-1][1].extend([addressing.address.low_byte().value, addressing.address.high_byte().value])
if addressing.mode == Addressing.LIST:
for word in addressing.address:
self.codes[-1][1].extend([word.low_byte().value, word.high_byte().value])
else:
self.codes[-1][1].extend([addressing.address.low_byte().value, addressing.address.high_byte().value])

@_addressing_guard(allowed={Addressing.IMPLIED})
def pre_brk(self, addressing: Addressing):
return 2
return self.brk_size

@_assemble_guard
def gen_brk(self, index, addressing: Addressing):
self._extend_byte(0x00)
self._extend_byte(0x00)
for i in range(self.brk_size):
self._extend_byte(0x00)

@_addressing_guard(allowed={Addressing.IMPLIED, Addressing.IMMEDIATE, Addressing.ADDRESS, Addressing.INDEXED})
def pre_nop(self, addressing: Addressing):
Expand Down
30 changes: 25 additions & 5 deletions asm_6502/grammar.py
Expand Up @@ -56,17 +56,19 @@ class Addressing(namedtuple('Addressing', ['mode', 'address', 'register'], defau
IMMEDIATE = 'immediate'
IMPLIED = 'implied'
ADDRESS = 'address'
ZERO_PAGE = 'zero_page'
ZERO_PAGE_X = 'zero_page_x'
ZERO_PAGE_Y = 'zero_page_y'
ZERO_PAGE = 'zero page'
ZERO_PAGE_X = 'zero page X'
ZERO_PAGE_Y = 'zero page Y'
ABSOLUTE = 'absolute'
ABSOLUTE_X = 'absolute_x'
ABSOLUTE_Y = 'absolute_y'
ABSOLUTE_X = 'absolute X'
ABSOLUTE_Y = 'absolute Y'
INDIRECT = 'indirect'
INDEXED = 'indexed'
INDEXED_INDIRECT = 'indexed indirect'
INDIRECT_INDEXED = 'indirect indexed'

LIST = 'list'


class Arithmetic(namedtuple('Arithmetic', ['mode', 'param'], defaults=[None, None])):

Expand All @@ -82,6 +84,8 @@ class Arithmetic(namedtuple('Arithmetic', ['mode', 'param'], defaults=[None, Non
LOW_BYTE = 'low_byte'
HIGH_BYTE = 'high_byte'

LIST = 'list'


class Instruction(namedtuple('Instruction', ['label', 'op', 'addressing', 'line_num'])):

Expand Down Expand Up @@ -320,6 +324,22 @@ def p_stat_val_immediate(p):
return p


def p_stat_val_list(p):
"""stat_val : arithmetic_list"""
p[0] = Addressing(Addressing.LIST, address=p[1])
return p


def p_arithmetic_list(p):
"""arithmetic_list : arithmetic ',' arithmetic_list
| arithmetic"""
if len(p) == 2:
p[0] = Arithmetic(Arithmetic.LIST, [p[1]])
else:
p[0] = Arithmetic(Arithmetic.LIST, [p[1]] + p[3].param)
return p


def p_arithmetic_uminus(p):
"""arithmetic : '-' arithmetic %prec UMINUS"""
if isinstance(p[2], Integer):
Expand Down
61 changes: 32 additions & 29 deletions asm_6502/parsetab.py
Expand Up @@ -6,9 +6,9 @@

_lr_method = 'LALR'

_lr_signature = "left+-leftCUR/rightUMINUSBIN BIT CHAR CUR DEC HEX KEYWORD LABEL NEWLINE PSEUDO REGISTERstat : LABEL KEYWORD stat_valstat : KEYWORD stat_valstat : stat NEWLINE statstat :stat_val : REGISTERstat_val : arithmeticstat_val :stat_val : '(' arithmetic ')'stat_val : arithmetic ',' REGISTERstat_val : '(' arithmetic ',' REGISTER ')'stat_val : '(' arithmetic ')' ',' REGISTERstat_val : BIT arithmeticstat_val : '#' arithmeticarithmetic : '-' arithmetic %prec UMINUSarithmetic : integerarithmetic : LABELarithmetic : CURarithmetic : '[' arithmetic ']'arithmetic : arithmetic '+' arithmetic\n | arithmetic '-' arithmetic\n | arithmetic CUR arithmetic\n | arithmetic '/' arithmetic\n integer : DEC\n | HEX\n | BIN\n | CHAR\n "
_lr_signature = "left+-leftCUR/rightUMINUSBIN BIT CHAR CUR DEC HEX KEYWORD LABEL NEWLINE PSEUDO REGISTERstat : LABEL KEYWORD stat_valstat : KEYWORD stat_valstat : stat NEWLINE statstat :stat_val : REGISTERstat_val : arithmeticstat_val :stat_val : '(' arithmetic ')'stat_val : arithmetic ',' REGISTERstat_val : '(' arithmetic ',' REGISTER ')'stat_val : '(' arithmetic ')' ',' REGISTERstat_val : BIT arithmeticstat_val : '#' arithmeticstat_val : arithmetic_listarithmetic_list : arithmetic ',' arithmetic_list\n | arithmeticarithmetic : '-' arithmetic %prec UMINUSarithmetic : integerarithmetic : LABELarithmetic : CURarithmetic : '[' arithmetic ']'arithmetic : arithmetic '+' arithmetic\n | arithmetic '-' arithmetic\n | arithmetic CUR arithmetic\n | arithmetic '/' arithmetic\n integer : DEC\n | HEX\n | BIN\n | CHAR\n "

_lr_action_items = {'LABEL':([0,3,4,5,9,10,11,12,16,24,25,26,27,],[2,14,2,14,14,14,14,14,14,14,14,14,14,]),'KEYWORD':([0,2,4,],[3,5,3,]),'NEWLINE':([0,1,3,4,5,6,7,8,13,14,15,17,18,19,20,21,22,29,30,31,33,34,35,36,37,38,40,43,44,],[-4,4,-7,-4,-7,-2,-5,-6,-15,-16,-17,-23,-24,-25,-26,4,-1,-12,-13,-14,-9,-19,-20,-21,-22,-8,-18,-11,-10,]),'$end':([0,1,3,4,5,6,7,8,13,14,15,17,18,19,20,21,22,29,30,31,33,34,35,36,37,38,40,43,44,],[-4,0,-7,-4,-7,-2,-5,-6,-15,-16,-17,-23,-24,-25,-26,-3,-1,-12,-13,-14,-9,-19,-20,-21,-22,-8,-18,-11,-10,]),'REGISTER':([3,5,23,39,41,],[7,7,33,42,43,]),'(':([3,5,],[9,9,]),'BIT':([3,5,],[10,10,]),'#':([3,5,],[11,11,]),'-':([3,5,8,9,10,11,12,13,14,15,16,17,18,19,20,24,25,26,27,28,29,30,31,32,34,35,36,37,40,],[12,12,25,12,12,12,12,-15,-16,-17,12,-23,-24,-25,-26,12,12,12,12,25,25,25,-14,25,-19,-20,-21,-22,-18,]),'CUR':([3,5,8,9,10,11,12,13,14,15,16,17,18,19,20,24,25,26,27,28,29,30,31,32,34,35,36,37,40,],[15,15,26,15,15,15,15,-15,-16,-17,15,-23,-24,-25,-26,15,15,15,15,26,26,26,-14,26,26,26,-21,-22,-18,]),'[':([3,5,9,10,11,12,16,24,25,26,27,],[16,16,16,16,16,16,16,16,16,16,16,]),'DEC':([3,5,9,10,11,12,16,24,25,26,27,],[17,17,17,17,17,17,17,17,17,17,17,]),'HEX':([3,5,9,10,11,12,16,24,25,26,27,],[18,18,18,18,18,18,18,18,18,18,18,]),'BIN':([3,5,9,10,11,12,16,24,25,26,27,],[19,19,19,19,19,19,19,19,19,19,19,]),'CHAR':([3,5,9,10,11,12,16,24,25,26,27,],[20,20,20,20,20,20,20,20,20,20,20,]),',':([8,13,14,15,17,18,19,20,28,31,34,35,36,37,38,40,],[23,-15,-16,-17,-23,-24,-25,-26,39,-14,-19,-20,-21,-22,41,-18,]),'+':([8,13,14,15,17,18,19,20,28,29,30,31,32,34,35,36,37,40,],[24,-15,-16,-17,-23,-24,-25,-26,24,24,24,-14,24,-19,-20,-21,-22,-18,]),'/':([8,13,14,15,17,18,19,20,28,29,30,31,32,34,35,36,37,40,],[27,-15,-16,-17,-23,-24,-25,-26,27,27,27,-14,27,27,27,-21,-22,-18,]),')':([13,14,15,17,18,19,20,28,31,34,35,36,37,40,42,],[-15,-16,-17,-23,-24,-25,-26,38,-14,-19,-20,-21,-22,-18,44,]),']':([13,14,15,17,18,19,20,31,32,34,35,36,37,40,],[-15,-16,-17,-23,-24,-25,-26,-14,40,-19,-20,-21,-22,-18,]),}
_lr_action_items = {'LABEL':([0,3,4,5,9,10,11,13,17,24,25,26,27,28,44,],[2,15,2,15,15,15,15,15,15,15,15,15,15,15,15,]),'KEYWORD':([0,2,4,],[3,5,3,]),'NEWLINE':([0,1,3,4,5,6,7,8,12,14,15,16,18,19,20,21,22,23,30,31,32,34,35,36,37,38,39,40,41,43,47,48,],[-4,4,-7,-4,-7,-2,-5,-6,-14,-18,-19,-20,-26,-27,-28,-29,4,-1,-12,-13,-17,-16,-9,-15,-22,-23,-24,-25,-8,-21,-11,-10,]),'$end':([0,1,3,4,5,6,7,8,12,14,15,16,18,19,20,21,22,23,30,31,32,34,35,36,37,38,39,40,41,43,47,48,],[-4,0,-7,-4,-7,-2,-5,-6,-14,-18,-19,-20,-26,-27,-28,-29,-3,-1,-12,-13,-17,-16,-9,-15,-22,-23,-24,-25,-8,-21,-11,-10,]),'REGISTER':([3,5,24,42,45,],[7,7,35,46,47,]),'(':([3,5,],[9,9,]),'BIT':([3,5,],[10,10,]),'#':([3,5,],[11,11,]),'-':([3,5,8,9,10,11,13,14,15,16,17,18,19,20,21,24,25,26,27,28,29,30,31,32,33,34,37,38,39,40,43,44,],[13,13,26,13,13,13,13,-18,-19,-20,13,-26,-27,-28,-29,13,13,13,13,13,26,26,26,-17,26,26,-22,-23,-24,-25,-21,13,]),'CUR':([3,5,8,9,10,11,13,14,15,16,17,18,19,20,21,24,25,26,27,28,29,30,31,32,33,34,37,38,39,40,43,44,],[16,16,27,16,16,16,16,-18,-19,-20,16,-26,-27,-28,-29,16,16,16,16,16,27,27,27,-17,27,27,27,27,-24,-25,-21,16,]),'[':([3,5,9,10,11,13,17,24,25,26,27,28,44,],[17,17,17,17,17,17,17,17,17,17,17,17,17,]),'DEC':([3,5,9,10,11,13,17,24,25,26,27,28,44,],[18,18,18,18,18,18,18,18,18,18,18,18,18,]),'HEX':([3,5,9,10,11,13,17,24,25,26,27,28,44,],[19,19,19,19,19,19,19,19,19,19,19,19,19,]),'BIN':([3,5,9,10,11,13,17,24,25,26,27,28,44,],[20,20,20,20,20,20,20,20,20,20,20,20,20,]),'CHAR':([3,5,9,10,11,13,17,24,25,26,27,28,44,],[21,21,21,21,21,21,21,21,21,21,21,21,21,]),',':([8,14,15,16,18,19,20,21,29,32,34,37,38,39,40,41,43,],[24,-18,-19,-20,-26,-27,-28,-29,42,-17,44,-22,-23,-24,-25,45,-21,]),'+':([8,14,15,16,18,19,20,21,29,30,31,32,33,34,37,38,39,40,43,],[25,-18,-19,-20,-26,-27,-28,-29,25,25,25,-17,25,25,-22,-23,-24,-25,-21,]),'/':([8,14,15,16,18,19,20,21,29,30,31,32,33,34,37,38,39,40,43,],[28,-18,-19,-20,-26,-27,-28,-29,28,28,28,-17,28,28,28,28,-24,-25,-21,]),')':([14,15,16,18,19,20,21,29,32,37,38,39,40,43,46,],[-18,-19,-20,-26,-27,-28,-29,41,-17,-22,-23,-24,-25,-21,48,]),']':([14,15,16,18,19,20,21,32,33,37,38,39,40,43,],[-18,-19,-20,-26,-27,-28,-29,-17,43,-22,-23,-24,-25,-21,]),}

_lr_action = {}
for _k, _v in _lr_action_items.items():
Expand All @@ -17,7 +17,7 @@
_lr_action[_x][_k] = _y
del _lr_action_items

_lr_goto_items = {'stat':([0,4,],[1,21,]),'stat_val':([3,5,],[6,22,]),'arithmetic':([3,5,9,10,11,12,16,24,25,26,27,],[8,8,28,29,30,31,32,34,35,36,37,]),'integer':([3,5,9,10,11,12,16,24,25,26,27,],[13,13,13,13,13,13,13,13,13,13,13,]),}
_lr_goto_items = {'stat':([0,4,],[1,22,]),'stat_val':([3,5,],[6,23,]),'arithmetic':([3,5,9,10,11,13,17,24,25,26,27,28,44,],[8,8,29,30,31,32,33,34,37,38,39,40,34,]),'arithmetic_list':([3,5,24,44,],[12,12,36,36,]),'integer':([3,5,9,10,11,13,17,24,25,26,27,28,44,],[14,14,14,14,14,14,14,14,14,14,14,14,14,]),}

_lr_goto = {}
for _k, _v in _lr_goto_items.items():
Expand All @@ -27,30 +27,33 @@
del _lr_goto_items
_lr_productions = [
("S' -> stat","S'",1,None,None,None),
('stat -> LABEL KEYWORD stat_val','stat',3,'p_stat_with_label','grammar.py',209),
('stat -> KEYWORD stat_val','stat',2,'p_stat_without_label','grammar.py',215),
('stat -> stat NEWLINE stat','stat',3,'p_stat_repeat','grammar.py',221),
('stat -> <empty>','stat',0,'p_stat_empty','grammar.py',227),
('stat_val -> REGISTER','stat_val',1,'p_stat_val_accumulator','grammar.py',233),
('stat_val -> arithmetic','stat_val',1,'p_stat_val_direct','grammar.py',243),
('stat_val -> <empty>','stat_val',0,'p_stat_val_empty','grammar.py',249),
('stat_val -> ( arithmetic )','stat_val',3,'p_stat_val_indirect','grammar.py',255),
('stat_val -> arithmetic , REGISTER','stat_val',3,'p_stat_val_indexed','grammar.py',261),
('stat_val -> ( arithmetic , REGISTER )','stat_val',5,'p_stat_val_indexed_indirect','grammar.py',270),
('stat_val -> ( arithmetic ) , REGISTER','stat_val',5,'p_stat_val_indirect_indexed','grammar.py',279),
('stat_val -> BIT arithmetic','stat_val',2,'p_stat_val_immediate_bit','grammar.py',288),
('stat_val -> # arithmetic','stat_val',2,'p_stat_val_immediate','grammar.py',303),
('arithmetic -> - arithmetic','arithmetic',2,'p_arithmetic_uminus','grammar.py',309),
('arithmetic -> integer','arithmetic',1,'p_arithmetic_direct','grammar.py',318),
('arithmetic -> LABEL','arithmetic',1,'p_arithmetic_label','grammar.py',324),
('arithmetic -> CUR','arithmetic',1,'p_arithmetic_cur','grammar.py',330),
('arithmetic -> [ arithmetic ]','arithmetic',3,'p_arithmetic_paren','grammar.py',336),
('arithmetic -> arithmetic + arithmetic','arithmetic',3,'p_arithmetic_binary_op','grammar.py',342),
('arithmetic -> arithmetic - arithmetic','arithmetic',3,'p_arithmetic_binary_op','grammar.py',343),
('arithmetic -> arithmetic CUR arithmetic','arithmetic',3,'p_arithmetic_binary_op','grammar.py',344),
('arithmetic -> arithmetic / arithmetic','arithmetic',3,'p_arithmetic_binary_op','grammar.py',345),
('integer -> DEC','integer',1,'p_integer','grammar.py',362),
('integer -> HEX','integer',1,'p_integer','grammar.py',363),
('integer -> BIN','integer',1,'p_integer','grammar.py',364),
('integer -> CHAR','integer',1,'p_integer','grammar.py',365),
('stat -> LABEL KEYWORD stat_val','stat',3,'p_stat_with_label','grammar.py',226),
('stat -> KEYWORD stat_val','stat',2,'p_stat_without_label','grammar.py',232),
('stat -> stat NEWLINE stat','stat',3,'p_stat_repeat','grammar.py',238),
('stat -> <empty>','stat',0,'p_stat_empty','grammar.py',244),
('stat_val -> REGISTER','stat_val',1,'p_stat_val_accumulator','grammar.py',250),
('stat_val -> arithmetic','stat_val',1,'p_stat_val_direct','grammar.py',260),
('stat_val -> <empty>','stat_val',0,'p_stat_val_empty','grammar.py',266),
('stat_val -> ( arithmetic )','stat_val',3,'p_stat_val_indirect','grammar.py',272),
('stat_val -> arithmetic , REGISTER','stat_val',3,'p_stat_val_indexed','grammar.py',278),
('stat_val -> ( arithmetic , REGISTER )','stat_val',5,'p_stat_val_indexed_indirect','grammar.py',287),
('stat_val -> ( arithmetic ) , REGISTER','stat_val',5,'p_stat_val_indirect_indexed','grammar.py',296),
('stat_val -> BIT arithmetic','stat_val',2,'p_stat_val_immediate_bit','grammar.py',305),
('stat_val -> # arithmetic','stat_val',2,'p_stat_val_immediate','grammar.py',320),
('stat_val -> arithmetic_list','stat_val',1,'p_stat_val_list','grammar.py',326),
('arithmetic_list -> arithmetic , arithmetic_list','arithmetic_list',3,'p_arithmetic_list','grammar.py',332),
('arithmetic_list -> arithmetic','arithmetic_list',1,'p_arithmetic_list','grammar.py',333),
('arithmetic -> - arithmetic','arithmetic',2,'p_arithmetic_uminus','grammar.py',342),
('arithmetic -> integer','arithmetic',1,'p_arithmetic_direct','grammar.py',351),
('arithmetic -> LABEL','arithmetic',1,'p_arithmetic_label','grammar.py',357),
('arithmetic -> CUR','arithmetic',1,'p_arithmetic_cur','grammar.py',363),
('arithmetic -> [ arithmetic ]','arithmetic',3,'p_arithmetic_paren','grammar.py',369),
('arithmetic -> arithmetic + arithmetic','arithmetic',3,'p_arithmetic_binary_op','grammar.py',375),
('arithmetic -> arithmetic - arithmetic','arithmetic',3,'p_arithmetic_binary_op','grammar.py',376),
('arithmetic -> arithmetic CUR arithmetic','arithmetic',3,'p_arithmetic_binary_op','grammar.py',377),
('arithmetic -> arithmetic / arithmetic','arithmetic',3,'p_arithmetic_binary_op','grammar.py',378),
('integer -> DEC','integer',1,'p_integer','grammar.py',402),
('integer -> HEX','integer',1,'p_integer','grammar.py',403),
('integer -> BIN','integer',1,'p_integer','grammar.py',404),
('integer -> CHAR','integer',1,'p_integer','grammar.py',405),
]
22 changes: 22 additions & 0 deletions tests/asm_pseudo/test_asm_byte.py
Expand Up @@ -22,3 +22,25 @@ def test_byte_too_large(self):
with self.assertRaises(AssembleError) as e:
self.assembler.assemble(code)
self.assertEqual("AssembleError: 0xabcd can not fit in a byte at line 2", str(e.exception))

def test_bytes(self):
code = ".ORG $1000\n" \
".BYTE $AB,$CD+1"
results = self.assembler.assemble(code, add_entry=False)
self.assertEqual([
(0x1000, [0xAB, 0xCD + 1]),
], results)

code = ".ORG $1000\n" \
".BYTE $AB,$CD+1,$EF"
results = self.assembler.assemble(code, add_entry=False)
self.assertEqual([
(0x1000, [0xAB, 0xCD + 1, 0xEF]),
], results)

def test_bytes_too_large(self):
code = ".ORG $1000\n" \
".BYTE $AB,$CD+$EF"
with self.assertRaises(AssembleError) as e:
self.assembler.assemble(code)
self.assertEqual("AssembleError: 0x1bc can not fit in a byte at line 2", str(e.exception))
8 changes: 8 additions & 0 deletions tests/asm_pseudo/test_asm_word.py
Expand Up @@ -23,3 +23,11 @@ def test_word_with_arithmetic(self):
self.assertEqual([
(0x1000, [0x03, 0x10]),
], results)

def test_words(self):
code = ".ORG $1000\n" \
".WORD $ABCD, $EF42"
results = self.assembler.assemble(code, add_entry=False)
self.assertEqual([
(0x1000, [0xCD, 0xAB, 0x42, 0xEF]),
], results)
4 changes: 2 additions & 2 deletions tests/parse/test_parse_error.py
Expand Up @@ -26,10 +26,10 @@ def test_parse_comma(self):
self.assertEqual("ParseError: Syntax error at EOF", str(e.exception))

def test_parse_too_many_parameters(self):
code = 'LDA XXX,YYY,ZZZ'
code = 'LDA XXX,YYY,ZZZ ZZZ'
with self.assertRaises(ParseError) as e:
self.parser.parse(code)
self.assertEqual("ParseError: Syntax error at line 1, column 9: 'YYY'", str(e.exception))
self.assertEqual("ParseError: Syntax error at line 1, column 17: 'ZZZ'", str(e.exception))

def test_wrong_accumulator(self):
code = 'LSR X'
Expand Down

0 comments on commit a492a82

Please sign in to comment.