diff --git a/esp32_ulp/assemble.py b/esp32_ulp/assemble.py index 07652b2..9182b18 100644 --- a/esp32_ulp/assemble.py +++ b/esp32_ulp/assemble.py @@ -129,9 +129,13 @@ def parse_line(self, line): opcode, args = opcode_args[0], () return label, opcode, args + def split_statements(self, lines): + for line in lines: + for statement in line.split(';'): + yield statement.rstrip() def parse(self, lines): - parsed = [self.parse_line(line) for line in lines] + parsed = [self.parse_line(line) for line in self.split_statements(lines)] return [p for p in parsed if p is not None] diff --git a/tests/assemble.py b/tests/assemble.py index e607ba2..7cb9265 100644 --- a/tests/assemble.py +++ b/tests/assemble.py @@ -244,6 +244,21 @@ def test_symbols(): assert st.resolve_absolute('const') == 123 +def test_support_multiple_statements_per_line(): + src = """ +label: nop; nop; + wait 42 +""" + + lines = Assembler().parse(src.splitlines()) + + assert lines == [ + ('label', 'nop', ()), + (None, 'nop', ()), + (None, 'wait', ('42',)) + ] + + test_parse_line() test_parse() test_assemble() @@ -254,4 +269,5 @@ def test_symbols(): test_assemble_evalulate_expressions() test_assemble_optional_comment_removal() test_assemble_test_regressions_from_evaluation() +test_support_multiple_statements_per_line() test_symbols() diff --git a/tests/compat/fixes.S b/tests/compat/fixes.S index 9e4d0ef..dee6092 100644 --- a/tests/compat/fixes.S +++ b/tests/compat/fixes.S @@ -25,4 +25,7 @@ entry: reg_rd 12, 7, 0 reg_rd 0x3ff48000, 7, 0 + # interpret ; as statement separator - this results in 2 NOP machine instructions + nop; nop; + halt