From b84f1657b32aee92808ef6cc4fdaded87963cc6b Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 5 Oct 2026 20:18:35 -0500 Subject: [PATCH] test_typed_target: restore A/X/Y around each hijacking call jsr() puts back PC/SP/FL after the call but leaves A/X/Y as the routine returned them. Every case after the first refusal resumes main_loop and then halts it at a random instruction. Halted on net_poll's `cmp #NET_TCP_CONNECTED` after a refused do_https_get, A is the driver's carry, 1 = NET_TCP_CONNECTED. The resume then polls a socket VICE does not have, net_poll latches net_tcp_state = ERROR, and cold_call's busy guard refuses every later prompt (COLD BANK FAIL, cold_err = 9). That is the 92/139 and 108/139 cascade on uci-comb, and the 139/139 runs where the halt missed that instruction. Test defect, not product: nothing on a real machine changes A between those two instructions. Red-green evidence: parking the CPU at net_poll+3 before a refused case gives net_tcp_state=2 and cold_err=9 on the next case (9/12) without this change, and 12/12 with net_tcp_state=0 with it. Full suite on uci-comb: 139/139, three runs out of three. Co-Authored-By: Claude Opus 5.5 (1M context) --- tools/test_typed_target.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/test_typed_target.py b/tools/test_typed_target.py index 8895bcc..3393f34 100644 --- a/tools/test_typed_target.py +++ b/tools/test_typed_target.py @@ -105,13 +105,23 @@ def screen_text(t) -> str: def call(t, target: int, timeout: float = 30.0) -> int: - """JSR *target* through a carry-latching driver; return C.""" + """JSR *target* through a carry-latching driver; return C. + + The call hijacks main_loop wherever the monitor halted it, and jsr() + puts back PC/SP/FL but not A/X/Y. Put those back too: halted on + net_poll's `cmp #NET_TCP_CONNECTED` with this driver's A = C = 1, the + next resume polls a socket that does not exist, net_poll latches + net_tcp_state = ERROR, and every later prompt is COLD BANK FAIL + (cold_call's busy guard) -- one random halt point, so a random case. + """ lo, hi = lohi(target) clo, chi = lohi(CARRY) write_bytes(t, DRIVER, bytes([0x20, lo, hi, 0xA9, 0x00, 0x2A, 0x8D, clo, chi, 0x60])) write_bytes(t, CARRY, bytes([POISON])) + saved = t.read_registers() jsr(t, DRIVER, timeout=timeout) + t.set_registers({k: saved[k] for k in ("A", "X", "Y")}) c = read_bytes(t, CARRY, 1)[0] if c not in (0, 1): raise RuntimeError(f"driver never returned (carry byte ${c:02X})")