# SPDX-License-Identifier: MIT """Rung 8: the tooling at the family bar: state, disassembler, debug session, trace, console, CLI. All of it is 6502-python's tooling subclassed through its hooks (``StepRecord``, ``DebugSession``, ``CommandDebugger``, the trace functions); these tests hold the hooks for each row. The disassembler is held against rung 0's tables (tier 2) and, as detectors, MAME's dispatch tables and cc65's ``da65``. """ import io import os import re import shutil import subprocess import sys from pathlib import Path import datasheet import pytest from w65c02_python import CMOS65C02, G65SC02, R65C02, W65C02S, CPUState, Lynx2Cell from w65c02_python._dispatch import BIT_OPCODES from w65c02_python.console import CommandError, W65C02Debugger from w65c02_python.debug import ( ACCESS_KINDS, BoundaryKind, StopReason, W65C02Record, W65C02Session, next_boundary, record_type, ) from w65c02_python.disasm import ( MODES, Instruction, decode_table, disassemble, disassemble_bytes, disassemble_range, operand_size, ) from w65c02_python.harness import ROWS, Harness from w65c02_python.trace import ( first_trace_divergence, read_trace, step_record_from_dict, write_trace, ) ROOT = Path(__file__).resolve().parents[1] MAME_TABLES = ROOT / "reference" / "src" / "mame" / "src" / "devices" / "cpu" / "m6502" #: cc65 2.19's da65: on PATH, or in the directory the CC65_BIN environment variable names. DA65 = ( Path(os.environ["CC65_BIN"]) / "da65" if os.environ.get("CC65_BIN") else Path(shutil.which("da65") or "da65") ) ALL_ROWS = (W65C02S, R65C02, G65SC02, Lynx2Cell) ROW_IDS = [row.__name__ for row in ALL_ROWS] ORG = 0x0200 def machine(row: type, *program: int, at: int = ORG) -> Harness: """A harness with ``program`` at ``at``, PC there, S = $FD.""" harness = Harness(row) harness.load(bytes(program), at) harness.cpu.pc = at harness.cpu.s = 0xFD return harness def session(harness: Harness, **options) -> W65C02Session: return W65C02Session(harness.cpu, peek_byte=harness.peek, **options) # -- the disassembler ------------------------------------------------------------------- @pytest.mark.parametrize("row", ALL_ROWS, ids=ROW_IDS) def test_all_256_opcodes_disassemble_to_the_mnemonic_and_length_of_rung_0(row: type) -> None: """Rung 8's exit: every opcode of every row disassembles to the mnemonic and length of the data sheets' tables (tests/datasheet.py; rung 0 holds the core's table to them).""" matrix = datasheet.ds_matrix() lengths = {"a": 3, "(a,x)": 3, "a,x": 3, "a,y": 3, "(a)": 3, "A": 1, "#": 2, "i": 1, "r": 2, "s": 1, "zp": 2, "(zp,x)": 2, "zp,x": 2, "zp,y": 2, "(zp)": 2, "(zp),y": 2} # fmt: skip nops = dict(datasheet.DS_NOPS) if not row.wai_stp: nops[0xCB] = nops[0xDB] = (1, 1) if not row.bit_instructions: nops.update({opcode: (1, 1) for opcode in BIT_OPCODES}) for opcode in range(256): instruction = disassemble_bytes( bytes([opcode, 0x12, 0x34][: 1 + operand_size(opcode, row)]), 0x1000, row ) if opcode in nops: assert instruction.mnemonic == "NOP" and not instruction.documented, f"${opcode:02X}" assert instruction.size == nops[opcode][0], f"${opcode:02X}" continue mnemonic, mode = matrix[opcode] assert instruction.mnemonic == mnemonic and instruction.documented, f"${opcode:02X}" if mnemonic[:3] in ("BBR", "BBS"): assert instruction.size == 3 # CL section 4 elif mnemonic == "BRK": assert instruction.size == datasheet.DS_BRK_BYTES else: assert instruction.size == lengths[mode], f"${opcode:02X}" def test_the_same_byte_disassembles_differently_on_different_rows() -> None: """The brief: `$07` is `RMB0` on an R65C02 and a one-byte NOP on a G65SC02; `$CB` is `WAI` only on the W65C02S.""" assert disassemble_bytes(b"\x07\x12", 0, R65C02).text == "RMB0 $12" assert disassemble_bytes(b"\x07", 0, G65SC02).text == "NOP" assert disassemble_bytes(b"\x07\x12", 0, Lynx2Cell).text == "RMB0 $12" assert disassemble_bytes(b"\xcb", 0, W65C02S).text == "WAI" assert disassemble_bytes(b"\xcb", 0, R65C02).text == "NOP" assert not disassemble_bytes(b"\xcb", 0, R65C02).documented assert operand_size(0x0F, R65C02) == 2 and operand_size(0x0F, G65SC02) == 0 assert decode_table(W65C02S) is decode_table(W65C02S) # built once per row class OwnRow(G65SC02): wai_stp = True assert disassemble_bytes(b"\xdb", 0, OwnRow).text == "STP" @pytest.mark.parametrize( ("code", "text", "mode", "target"), [ ((0xA9, 0x12), "LDA #$12", "immediate", None), ((0xA5, 0x12), "LDA $12", "zero_page", 0x12), ((0xB5, 0x12), "LDA $12,X", "zero_page_x", 0x12), ((0xB6, 0x12), "LDX $12,Y", "zero_page_y", 0x12), ((0xAD, 0x34, 0x12), "LDA $1234", "absolute", 0x1234), ((0xBD, 0x34, 0x12), "LDA $1234,X", "absolute_x", 0x1234), ((0xB9, 0x34, 0x12), "LDA $1234,Y", "absolute_y", 0x1234), ((0xA1, 0x12), "LDA ($12,X)", "zero_page_indexed_indirect", 0x12), ((0xB1, 0x12), "LDA ($12),Y", "zero_page_indirect_indexed", 0x12), ((0xB2, 0x12), "LDA ($12)", "zero_page_indirect", 0x12), ((0x6C, 0x34, 0x12), "JMP ($1234)", "absolute_indirect", 0x1234), ((0x7C, 0x34, 0x12), "JMP ($1234,X)", "absolute_indexed_indirect", 0x1234), ((0x0A,), "ASL A", "accumulator", None), ((0x1A,), "INC A", "accumulator", None), ((0xD0, 0xFE), "BNE $1000", "relative", 0x1000), ((0x80, 0x10), "BRA $1012", "relative", 0x1012), ((0x0F, 0x12, 0x10), "BBR0 $12,$1013", "zero_page_relative", 0x1013), ((0xF7, 0x12), "SMB7 $12", "zero_page", 0x12), ((0x00, 0x12), "BRK #$12", "immediate", None), ((0x64, 0x12), "STZ $12", "zero_page", 0x12), ((0x89, 0x12), "BIT #$12", "immediate", None), ((0xCB,), "WAI", "implied", None), ((0x02, 0x12), "NOP #$12", "immediate", None), ((0x44, 0x12), "NOP $12", "zero_page", 0x12), ((0x54, 0x12), "NOP $12,X", "zero_page_x", 0x12), ((0x5C, 0x34, 0x12), "NOP $1234", "absolute", 0x1234), ((0x03,), "NOP", "implied", None), ], ) def test_disassembly_text(code: tuple[int, ...], text: str, mode: str, target: int | None) -> None: instruction = disassemble_bytes(bytes(code), 0x1000) assert instruction.text == text assert (instruction.mode, instruction.target, instruction.size) == (mode, target, len(code)) assert instruction.mode in MODES and instruction.next_address == 0x1000 + len(code) def test_disassemble_reads_only_what_the_instruction_needs_and_wraps() -> None: seen = [] memory = {0xFFFF: 0xAD, 0x0000: 0x34, 0x0001: 0x12} instruction = disassemble(lambda address: seen.append(address) or memory[address], 0xFFFF) assert instruction.text == "LDA $1234" and seen == [0xFFFF, 0x0000, 0x0001] assert instruction.next_address == 0x0002 listing = disassemble_range(lambda address: 0xEA, 0x1000, 3) assert [item.address for item in listing] == [0x1000, 0x1001, 0x1002] with pytest.raises(ValueError, match="takes 2 operand bytes"): disassemble_bytes(b"\xad\x34") with pytest.raises(ValueError, match="non-byte"): disassemble(lambda address: 0x100, 0) with pytest.raises(ValueError, match="address"): Instruction(0x10000, b"\xea", "NOP") #: MAME's addressing suffixes -> operand bytes. MAME_OPERANDS = {"imp": 0, "acc": 0, "imm": 1, "zpg": 1, "zpx": 1, "zpy": 1, "idx": 1, "idy": 1, "zpi": 1, "rel": 1, "bzp": 1, "aba": 2, "abx": 2, "aby": 2, "adr": 2, "ind": 2, "iax": 2, "zpb": 2} # fmt: skip @pytest.mark.parametrize( ("table", "row", "expected"), [ ("dw65c02.lst", G65SC02, {}), # C5: MAME's Rockwell device has WAI and STP; RDS has neither. ("dr65c02.lst", R65C02, {0xCB: "wai", 0xDB: "stp"}), ("dw65c02s.lst", W65C02S, {}), ], ids=["w65c02", "r65c02", "w65c02s"], ) def test_disassembler_against_mames_dispatch_tables(table: str, row: type, expected: dict) -> None: """MAME 0.285 (emulator tier, a detector): the mnemonic and operand length of every opcode of its three CMOS dispatch tables, with the one difference a data sheet decides.""" path = MAME_TABLES / table if not path.is_file(): pytest.skip("MAME source not fetched: python -I scripts/fetch_references.py") names = [ name for line in path.read_text().splitlines() if not line.startswith("#") for name in line.split() if "_" in name and not name.startswith("reset") ] assert len(names) == 256 different = {} for opcode, name in enumerate(names): mnemonic, suffix = name.split("_")[0], name.rsplit("_", 1)[1] ours, _mode, operands, _template, _documented = decode_table(row)[opcode] if ours[:3].lower() != mnemonic: different[opcode] = mnemonic # MAME's BRK is one byte ("imp"); the instruction skips a second (DS Table 4-1 note 5). elif opcode != 0x00: assert operands == MAME_OPERANDS[suffix], f"${opcode:02X} {name}" assert different == expected @pytest.mark.parametrize(("cpu", "row"), [("65sc02", G65SC02), ("65c02", W65C02S)]) def test_disassembler_against_da65(cpu: str, row: type, tmp_path: Path) -> None: """cc65's da65 (a detector): mnemonic and length of every opcode it defines for its `65SC02` (the 178) and `65C02` (the 212) CPUs.""" if not DA65.is_file(): pytest.skip("cc65 2.19's da65 not found: put it on PATH or set CC65_BIN") image = tmp_path / "opcode.bin" defined = 0 for opcode in range(256): image.write_bytes(bytes([opcode, 0x12, 0x34])) listing = subprocess.run( [str(DA65), "--cpu", cpu, "--comments", "4", "-S", "0x1000", str(image)], capture_output=True, text=True, check=True, ).stdout # fmt: skip # " lda #$12 ; 1000 A9 12 .." line = next(text for text in listing.splitlines() if "; 1000 " in text) code, comment = line.split(";", 1) mnemonic = code.split()[0] ours, _mode, operands, _template, documented = decode_table(row)[opcode] if mnemonic == ".byte": assert not documented, f"${opcode:02X}" continue defined += 1 size = len(re.match(r" 1000((?: [0-9A-F]{2})+)", comment)[1].split()) assert documented and ours.lower() == mnemonic, f"${opcode:02X}" # da65 gives BRK one byte; the instruction skips a second (DS Table 4-1 note 5). assert 1 + operands == size + (opcode == 0x00), f"${opcode:02X}" assert defined == (178 if cpu == "65sc02" else 212) # -- state -------------------------------------------------------------------------------- @pytest.mark.parametrize("row", ALL_ROWS, ids=ROW_IDS) def test_state_round_trips_through_capture_and_restore(row: type) -> None: harness = machine(row, 0x58, 0xEA) # CLI; NOP cpu = harness.cpu cpu.a, cpu.x, cpu.y = 0x12, 0x34, 0x56 cpu.request_maskable_interrupt() cpu.step() # CLI: the poll remembers the old I state = cpu.capture_state() assert state.polled_i is True and state.maskable_interrupt_pending assert (state.a, state.x, state.y, state.s, state.pc) == (0x12, 0x34, 0x56, 0xFD, ORG + 1) other = machine(row, 0x58, 0xEA) other.cpu.restore_state(state) assert other.cpu.capture_state() == state assert next_boundary(state) is BoundaryKind.INSTRUCTION # the IRQ waits one instruction cpu.step() other.cpu.step() assert other.cpu.capture_state() == cpu.capture_state() assert next_boundary(cpu.capture_state()) is BoundaryKind.IRQ def test_state_holds_wai_and_stp_and_is_validated() -> None: harness = machine(W65C02S, 0xCB) harness.cpu.step() state = harness.cpu.capture_state() assert state.waiting and state.halted and not state.stopped assert next_boundary(state) is BoundaryKind.WAI restored = machine(W65C02S) restored.cpu.restore_state(state) assert restored.cpu.waiting and restored.cpu.halted harness = machine(W65C02S, 0xDB) harness.cpu.step() assert next_boundary(harness.cpu.capture_state()) is BoundaryKind.STP with pytest.raises(ValueError, match="bit 5"): CPUState(p=0x04) with pytest.raises(ValueError, match="bit 5"): CPUState(p=0x34) with pytest.raises(ValueError, match="halted"): CPUState(waiting=True) with pytest.raises(ValueError, match="both"): CPUState(waiting=True, stopped=True, halted=True) with pytest.raises(ValueError, match="pc"): CPUState(pc=0x10000) with pytest.raises(TypeError): harness.cpu.restore_state(object()) def test_next_boundary_decides_as_step_does() -> None: """Every kind of boundary, predicted from the state and then taken.""" harness = machine(W65C02S, 0xEA, 0xCB, 0xEA) harness.memory[0xFFFE:0x10000] = bytes([0x00, 0x90]) harness.memory[0xFFFA:0xFFFC] = bytes([0x00, 0xA0]) harness.memory[0x9000] = 0x40 # RTI harness.memory[0xA000] = 0xDB # STP cpu = harness.cpu cpu.p = 0x20 debug = session(harness) kinds = [] cpu.request_reset() kinds.append(debug.step().kind) # reset (the vector is zero: fix PC afterwards) cpu.pc, cpu.s, cpu.p = ORG, 0xFD, 0x20 kinds.append(debug.step().kind) # NOP kinds.append(debug.step().kind) # WAI kinds.append(debug.step().kind) # waiting cpu.request_maskable_interrupt() kinds.append(debug.step().kind) # the IRQ entry ends the wait cpu.clear_maskable_interrupt() kinds.append(debug.step().kind) # RTI cpu.request_non_maskable_interrupt() kinds.append(debug.step().kind) # NMI kinds.append(debug.step().kind) # STP kinds.append(debug.step().kind) # stopped assert [kind.value for kind in kinds] == [ "reset", "instruction", "instruction", "wai", "irq", "instruction", "nmi", "instruction", "stp", ] # fmt: skip # -- the debug session ------------------------------------------------------------------ @pytest.mark.parametrize("row", ALL_ROWS, ids=ROW_IDS) def test_step_records_decode_with_the_rows_table_and_track_every_cycle(row: type) -> None: harness = machine(row, 0x07, 0x44, 0xEA, 0xBD, 0xF8, 0x12) # RMB0 $44 or NOPs; LDA $12F8,X harness.cpu.x = 0x10 debug = session(harness, track_accesses=True) assert debug.row is row and debug.record_type is record_type(row) record = debug.step() assert type(record) is record_type(row) and isinstance(record, W65C02Record) assert record.kind is BoundaryKind.INSTRUCTION if row.bit_instructions: assert record.instruction.text == "RMB0 $44" and record.cycles == 5 assert [access[0] for access in record.accesses] == ["rs", "rf", "r", "r", "w"] else: assert record.instruction.text == "NOP" and record.cycles == 1 assert record.accesses == (("rs", ORG, 0x07),) while harness.cpu.pc != ORG + 3: debug.step() record = debug.step() assert record.instruction.text == "LDA $12F8,X" assert record.accesses == ( ("rs", ORG + 3, 0xBD), ("rf", ORG + 4, 0xF8), ("rf", ORG + 5, 0x12), ("r", ORG + 5, 0x12), ("r", 0x1308, 0x00), ) # fmt: skip assert all(kind in ACCESS_KINDS for kind, _address, _value in record.accesses) assert debug.total_cycles == sum(item.cycles for item in debug.history) debug.close() assert harness.cpu.read_byte == harness.read_byte # the bus is put back def test_run_stops_at_breakpoints_watchpoints_and_a_halted_cpu() -> None: harness = machine(W65C02S, 0xA9, 0x01, 0x85, 0x10, 0xA5, 0x10, 0xCB, 0xEA) debug = session(harness, track_accesses=True) debug.add_breakpoint(ORG + 4) result = debug.run(max_steps=100) assert result.reason is StopReason.BREAKPOINT and result.state.pc == ORG + 4 debug.remove_breakpoint(ORG + 4) debug.add_watchpoint(0x0010, "r") result = debug.run(max_steps=100) assert result.reason is StopReason.WATCHPOINT and result.hits == (("r", 0x0010, 0x01),) debug.remove_watchpoint(0x0010) result = debug.run(max_steps=100) # WAI runs; the next boundary is a waiting cycle assert result.reason is StopReason.HALTED and result.state.waiting assert W65C02Record.halted_kinds == {BoundaryKind.WAI, BoundaryKind.STP} result = debug.run(max_steps=5, stop_on_halt=False) assert result.reason is StopReason.STEP_LIMIT and result.instructions == 0 assert all(record.kind is BoundaryKind.WAI for record in debug.history[-5:]) with pytest.raises(ValueError, match="address"): debug.add_breakpoint(0x10000) def test_a_session_drives_a_board_that_wraps_the_cpu() -> None: """The target may be a board: an object with ``step``, ``capture_state`` and ``cpu``.""" harness = machine(G65SC02, 0xE8, 0xE8) class Board: cpu = harness.cpu ticks = 0 def step(self) -> int: cycles = self.cpu.step() self.ticks += 5 * cycles return cycles def capture_state(self) -> CPUState: return self.cpu.capture_state() board = Board() debug = W65C02Session(board, peek_byte=harness.peek) assert debug.row is G65SC02 debug.step() assert board.ticks == 10 and debug.history[-1].instruction.text == "INX" # -- traces ------------------------------------------------------------------------------- def trace_of(row: type, *program: int, steps: int = 6) -> tuple[str, list]: harness = machine(row, *program) debug = session(harness, track_accesses=True) out = io.StringIO() written = [debug.step() for _ in range(steps)] write_trace(written, out) return out.getvalue(), written @pytest.mark.parametrize("row", ALL_ROWS, ids=ROW_IDS) def test_a_trace_reads_back_equal_with_the_rows_decoder(row: type) -> None: text, written = trace_of(row, 0x07, 0x44, 0xEA, 0xA9, 0x55, 0x48, 0x68, 0xCB, 0xDB, 0xEA) back = list(read_trace(io.StringIO(text), row)) assert back == written assert all(type(record) is record_type(row) for record in back) assert first_trace_divergence(iter(written), iter(back)) is None first = step_record_from_dict(__import__("json").loads(text.splitlines()[0]), row) assert first == written[0] def test_a_trace_names_wai_and_the_access_kinds() -> None: text, written = trace_of(W65C02S, 0xCB, steps=3) assert [record.kind.value for record in written] == ["instruction", "wai", "wai"] assert '"kind":"wai"' in text.replace(" ", "") assert written[1].accesses == (("rf", ORG + 1, 0x00),) assert written[1].instruction is None def test_two_rows_traces_diverge_where_the_rows_differ() -> None: """The trace comparison finds the first boundary at which an R65C02 and a G65SC02 part.""" program = (0xA9, 0x01, 0x07, 0x44, 0xEA, 0xEA) _, rockwell = trace_of(R65C02, *program, steps=3) _, gte = trace_of(G65SC02, *program, steps=3) divergence = first_trace_divergence(iter(rockwell), iter(gte)) assert divergence is not None and divergence.position == 1 paths = {difference.path for difference in divergence.differences} assert "cycles" in paths and "after.pc" in paths # -- the console -------------------------------------------------------------------------- def test_the_console_runs_the_family_commands() -> None: harness = machine(R65C02, 0xA9, 0x12, 0x20, 0x10, 0x02, 0x07, 0x44, 0xCB, at=ORG) harness.load(bytes([0xE8, 0x60]), ORG + 0x10) # INX; RTS debugger = W65C02Debugger(session(harness, track_accesses=True)) assert debugger.prompt == "65c02> " lines = debugger.execute("registers").lines assert lines[0].startswith("PC=0200 A=00") and lines[0].endswith("R65C02") assert "WAI=0 STP=0" in lines[1] assert debugger.execute("disassemble 0x205 2").lines == ( "0205 07 44 RMB0 $44", "0207 CB NOP", ) assert "LDA #$12" in debugger.execute("step").lines[0] debugger.execute("over") # the JSR runs through to its return assert harness.cpu.pc == ORG + 5 and harness.cpu.x == 1 debugger.execute("break $207") assert "stopped=breakpoint" in debugger.execute("continue").lines[0] debugger.execute("set A 0x7f") assert harness.cpu.a == 0x7F debugger.execute("set P 0xff") assert harness.cpu.p == 0xEF # B is not a flip-flop assert debugger.execute("irq on").lines == ("IRQ asserted; it stays asserted until irq off",) assert "IRQ=1" in debugger.execute("regs").lines[1] assert debugger.execute("memory 0x200 4").lines == ("0200 A9 12 20 10",) assert any("help" in line for line in debugger.execute("help").lines) with pytest.raises(CommandError): debugger.execute("frobnicate") assert debugger.execute("quit").quit def test_the_console_shows_a_waiting_cpu() -> None: harness = machine(W65C02S, 0xCB) debugger = W65C02Debugger(session(harness)) debugger.execute("step") assert "WAI=1" in debugger.execute("registers").lines[1] assert "wai" in debugger.execute("step").lines[0] out = io.StringIO() debugger.interact(io.StringIO("registers\nquit\n"), out) assert out.getvalue().count("65c02> ") == 2 # -- the harness and python -m w65c02_python ----------------------------------------------------- def test_the_harness_runs_to_a_trap_or_a_halt() -> None: harness = Harness(G65SC02) harness.load(bytes([0xA2, 0x03, 0xCA, 0xD0, 0xFD, 0x4C, 0x05, 0x04]), 0x0400) harness.memory[0xFFFC:0xFFFE] = bytes([0x00, 0x04]) harness.start() result = harness.run(1_000) assert (result.reason, result.pc) == ("trap", 0x0405) and harness.cpu.x == 0 assert result.cycles == harness.cycles == 7 + 2 + 3 * 2 + 2 * 3 + 2 + 3 harness = Harness(W65C02S) harness.load(bytes([0xDB]), 0x0400) harness.start(0x0400) assert harness.run(1_000).reason == "halted" assert harness.run(10, until=lambda host: True).reason in ("halted", "condition") assert set(ROWS) == {"w65c02s", "r65c02", "g65sc02", "lynx2cell"} assert all(issubclass(row, CMOS65C02) for row in ROWS.values()) with pytest.raises(ValueError, match="64 KB"): harness.load(bytes(2), 0xFFFF) def run_module(*arguments: str) -> str: result = subprocess.run( [sys.executable, "-m", "w65c02_python", *arguments], capture_output=True, text=True, check=True, ) return result.stdout def test_python_m_runs_traces_and_debugs_an_image(tmp_path: Path) -> None: image = tmp_path / "program.bin" # $0400: LDA #$05; `$07 $EA` (RMB0 $EA, or a one-cycle NOP and a NOP); STA $11; JMP * image.write_bytes(bytes(0x400) + bytes([0xA9, 0x05, 0x07, 0xEA, 0x85, 0x11, 0x4C, 0x06, 0x04])) assert run_module(str(image), "--start", "0x400").strip() == "trap after 20 cycles at 0406" gte = run_module(str(image), "--start", "$400", "--row", "g65sc02").strip() assert gte == "trap after 18 cycles at 0406" # 1 + 2 cycles where the R65C02 takes 5 trace = tmp_path / "out.jsonl" run_module(str(image), "--start", "0x400", "--row", "r65c02", "--trace", str(trace)) with trace.open() as handle: records = list(read_trace(handle, R65C02)) assert [record.instruction.text for record in records] == [ "LDA #$05", "RMB0 $EA", "STA $11", "JMP $0406", ] # fmt: skip assert sum(record.cycles for record in records) == 13 out = run_module( str(image), "--start", "0x400", "--row", "lynx2cell", "--batch", "-c", "step 2", "-c", "disassemble", ) # fmt: skip assert "Lynx2Cell" in out and "RMB0 $EA" in out and "STA $11" in out assert "error" not in out