#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """The crate's opcode table against the reference's ``_dispatch.OPCODES``. check_tables.py TRACE_BINARY ``TRACE_BINARY --tables`` prints the crate's 256 (handler, mode) pairs; each must name the reference's handler and mode for that opcode. Run it with the reference's interpreter. """ import json import subprocess import sys from w65c816._dispatch import OPCODES def main() -> int: table = json.loads(subprocess.run([sys.argv[1], "--tables"], capture_output=True, text=True, check=True).stdout) # fmt: skip differ = [f"{opcode:02X}: crate {table[opcode]}, reference {list(OPCODES[opcode])}" for opcode in range(256) if table[opcode] != list(OPCODES[opcode])] # fmt: skip if differ: print("\n".join(differ)) return 1 print("opcode table: all 256 entries equal the reference's") return 0 if __name__ == "__main__": sys.exit(main())