Skip to content

Unsupported opcode 5A (PHY) error during InitZobristTables execution #5

@barryw

Description

@barryw

Description

When running tests that call InitZobristTables (which fills 1536+ bytes of random data using a PRNG loop), the simulator reports an unsupported opcode error:

The OpCode 5A @ address 44F6 is not supported.

Steps to Reproduce

  1. Build the Chess project: make build

  2. Run any test that calls InitZobristTables, e.g.:

    docker run --rm -v "$PWD":/code ghcr.io/barryw/sim6502:v3.6.0 -s /code/tests/ai_zobrist.6502
    
  3. The first suite (Zobrist PRNG) passes, but when Zobrist Tables suite runs and calls InitZobristTables, the error occurs.

Analysis

  • Opcode $5A is PHY (Push Y to stack) - a 65C02 instruction
  • The code at address $44F6 in the symbol file is inside ZobristPRNG
  • The actual assembled code at that location is valid 6502 (lda $fb = $A5 $FB)
  • Tests that don't call InitZobristTables work fine
  • Tests that call only ZobristPRNG (without the full table init loop) also work

This suggests the issue may be related to:

  1. Execution reaching an unexpected memory location after many iterations
  2. Some state corruption during long-running loops
  3. Address calculation issue in the simulator

Expected Behavior

InitZobristTables should complete successfully - it's standard 6502 code with no 65C02 instructions.

Environment

  • sim6502 version: v3.6.0
  • Platform: macOS (ARM64, running via Docker with linux/amd64 emulation)
  • Source code: Standard 6502 assembly (no 65C02 mode)

Workaround

Tests that need Zobrist functionality can use ZobristPRNG directly or work with pre-seeded values rather than calling the full InitZobristTables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions