# Undocumented behaviour (U) and contradictions (C) Nothing about this chip is documented by its maker, so "undocumented" here means **not in fullsnes, or only guessed there**. Tiers (validation.md): fullsnes and the HLE authors' notes are **research**; byuu's model as published in ares (ISC; bsnes carries the same core, but bsnes is GPL-3 and a closed box) is **emulator**; Mesen2 (GPL-3) run as a closed box through `scripts/cx4_probe.py` or the rung 4 recordings is **OBSERVED** (an emulator's behaviour, never a hardware fact, overruled by any document); the shipped program is **program** evidence (what the code needs to make sense); the game's built-in Cx4 test is **hardware-designed self-test** (it passes on real chips). Rewritten in Wave 2 (2026-11-19, docs/provenance.md). Earlier versions cited bsnes, Mesen2 and the MiSTer Cx4 by file and line under the old rule "read and cited, never copied". Those readings are gone: bsnes citations are re-pointed to ares (found by searching ares, whose files carry the same core); what only Mesen2's source said was either re-established by a closed-box run (OBSERVED, with the probe named) or is marked **read from source under the old rule; closed box from now on; never a default**; what only MiSTer's sources said (no licence; not runnable here) is removed. ares paths below are under `ares/component/processor/hg51b/` unless they name `hitachidsp/` (`ares/sfc/coprocessor/ hitachidsp/`); the pin is in `scripts/pinned_repos.json`. ## U: behaviour the sources agree on | # | Behaviour | Evidence (tier) | | --- | --- | --- | | U1 | One 16-bit little-endian instruction per clock; a taken jump, call or return costs 2 more clocks, a taken skip 1 more | ares `instructions.cpp` l.174-187 (`step(2)` in JMP/JSR), l.260-269 (RTS, SKIP) [emulator]; every probe trace's `CC` column agrees [OBSERVED] | | U2 | Two 256-word cache pages, filled from `base + PB x 512`; lookup tries the current page, then the other, then loads into an unlocked page; both locked and a miss halts. PC wrapping past FFh moves to page 1 with PB = P; a wrap on page 1 halts | ares `hg51b.cpp` l.55-96 (`advance`, `cache`) [emulator]; fullsnes "Program RAM is 2x256x16-bit" [research] | | U3 | Data RAM is 3,072 bytes addressed with 12 bits; C00h-FFFh fold onto 800h-BFFh (subtract 400h) | ares `instructions.cpp` l.232-242, 324-342 (`RDRAM`, `WRRAM`) [emulator] | | U4 | RDROM reads word `x & 3FFh`; the ROM buffer holds 24 bits | ares `instructions.cpp` l.244-250 [emulator]; fullsnes [research] | | U5 | Operand codes 70h-7Fh mirror R0-R15; bit 7 of a register operand is ignored; undefined codes read 0 | ares `registers.cpp` l.1-63 (`readRegister`; its last line carries a "verified" comment, which is a program comment, not a published measurement: **provisional**) [emulator]; the `ldp` probe reads 76h and E6h as R6 and 06h, 86h as 0 [OBSERVED] | | U6 | The sixteen constant registers 50h-5Fh | fullsnes [research], ares `registers.cpp` l.26-41 [emulator]: identical; the game's IMMEDIATE REGISTER test (0E:5C) copies them to RAM and checks them [self-test] | | U7 | The shift sub-field is A, A<<1, A<<8, A<<16 | fullsnes [research], ares `instruction.cpp` (`shifts`) [emulator] | | U8 | MUL: signed 24 x 24 -> 48 bits, MH = 47-24, ML = 23-0; MUL imm treats the byte as unsigned | fullsnes ("smul ... signed 48bit") [research], ares `instructions.cpp` l.53-55, 213-219 [emulator]; the MALU test (0E:54, square) [self-test] | | U9 | Flags N Z C V; SUB/CMP carry = no borrow | fullsnes "Carry Flag is CLEARED on borrow" [research]; ares `instructions.cpp` l.88-95 [emulator] | | U10 | The external bus: an access starts when operand 2Eh (ROM wait) or 2Fh (RAM wait) is read (to MDR) or written (from MDR) at address MAR; the read value is 0, the data lands in MDR when the wait has passed; WAIT (1C00h) stalls until then; INC MAR adds 1 (24 bits). The program's idiom `612Eh / 4000h / 1C00h` (fullsnes) | fullsnes "Reading data bytes from SNES ROM" [research]; ares `registers.cpp` l.12-23, 76-87, `hg51b.cpp` l.35-46 [emulator]; 16 uses in the program [program]; the `bus` probe shows MDR 0 after the start and the byte after WAIT [OBSERVED] | | U11 | S-CPU map: data RAM at $6000-$6BFF (mirrored $7000-$7BFF), I/O $7F40-$7F5F, vectors $7F60-$7F7F, R0-R15 bytes at $7F80-$7FAF (mirror $7FC0-$7FEF), banks 00-3F/80-BF | fullsnes "I/O Map" [research]; ares `hitachidsp/memory.cpp` l.88-181 [emulator] | | U12 | $7F4F (when halted) starts at PB:PC from $7F4D-$7F4F; $7F47 starts a DMA; $7F48 selects a cache page and preloads PB; $7F5E bit 6 = running (cache, DMA, bus or executing), bit 7 = busy (cache, DMA or bus) | ares `hitachidsp/memory.cpp` l.164-166, 183-229, `hg51b.cpp` l.117-123 [emulator]; fullsnes ("bit6=busy, set upon [7F47],[7F48],[7F4F] writes") [research]; every probe's host stream: C2h while a start's page loads, 42h while it runs, 02h after [OBSERVED] | | U13 | HALT stops execution; if $7F51 bit 0 = 0 the chip raises the S-CPU's IRQ and sets its own IRQ flag (status bit 1); writing $7F51 = 1 disables and drops the IRQ; writing $7F5E clears the flag but not the IRQ line | ares `hitachidsp/hitachidsp.cpp` l.28-31, `hitachidsp/memory.cpp` l.236-262 (the $7F5E comment "does not deassert CPU IRQ line") [emulator]; the games disable it [program, MAME host log] | | U14 | $7F55-$7F5C suspend the chip 0 (until $7F5D), 32, 64 ... 224 clocks; $7F5D resumes | ares `hitachidsp/memory.cpp` l.250-258, `hg51b.cpp` l.65-70 [emulator, one model]; fullsnes lists $7F53-$7F5D as unknown [research] | | U15 | DMA copies `length` bytes from source to target through the chip's own bus (ROM, SRAM, data RAM at 00-3F:6000-6BFF); ROM to ROM or RAM to RAM locks the chip until $7F53 | ares `hg51b.cpp` l.98-113 [emulator]; the `dma-*` probes (C3) [OBSERVED] | | U16 | While the chip owns the ROM bus (cache load, DMA, bus access) the S-CPU cannot read ROM, and $00:FFE0-$FFFF return the vector bytes $7F60-$7F7F | fullsnes "ROM (disabled when CX4 is busy)", "Exception Vectors" [research]; ares `hitachidsp/memory.cpp` l.42-52 [emulator]; C12 | | U17 | CLEAR (F800h) zeroes A, P, the RAM buffer and DPR | ares `instructions.cpp` l.143-148 only [emulator]; the `clear` probe: a NOP in Mesen2 (C10) [OBSERVED]; unused by the program | | U18 | RDRAM/WRRAM byte lane 3 is a NOP | ares `instruction.cpp` (no binding for lane 3) [emulator] | | U19 | SXB/SXW sign-extend A from bit 7/15 and set N, Z | fullsnes "sign-expand" [research], ares `instructions.cpp` l.97-101, 311-317 [emulator] | | U20 | Power-on: halted, cache empty, waits ROM 3 / RAM 3, registers 0, IRQ enabled | ares `hg51b.hpp` l.139-149, `hg51b.cpp` l.125-128 [emulator]; unknown on hardware (the games set every register they use first: $7F52, vectors, $7F50, $7F51, base, $7F4C) | | U21 | **The data ROM is computable**: all 1,024 words equal floor(formula), saturated at FFFFFFh, for fullsnes' six formulas; the bytes' SHA-1 is MAME's dump `cx4.bin` (a002f4ef..., CRC b6e76a6a, from MAME's CC0 `hash/snes.xml`); its byte sum is 054336h, the value the game's IMMEDIATE ROM test (0E:89) checks | `data_rom.py`, `tests/test_data_rom.py` [research formula + a real chip's dump hash + self-test checksum]; `scripts/check_data_rom.py` compares a player's own dump; IEEE double gets one word wrong (tan 45 deg), the nearest other entry is 7.2e-4 from an integer | ## C: contradictions, each with its default The probe numbers are `scripts/cx4_probe.py` runs on Mesen2 2.1.1 `b9fa69dd` (closed box, 2026-11-19), replayed by `tests/test_mesen_probes.py`. | # | Question | Sources | Program / test evidence | Default (switch) | | --- | --- | --- | --- | --- | | C1 | **Shift counts 24-31** (SHR/ASR/ROR/SHL by register or imm) | ares: `if(s > 24) s = 0` (24 shifts out everything, 25-31 do nothing) (`instructions.cpp` l.46, 65, 73, 81) [emulator]. OBSERVED (`shift`, 640 words in three runs, A = 800000h and 7FFFFFh, counts 22-31 by immediate and by register): SHR, ASR and SHL by 24 leave A unchanged with N and Z set from it (12 rows differ from ares); 25-31 agree; ROR agrees throughout | immediates never >= 24; 11 shifts by register, counts seen in the rung 4 windows | ares (`SHIFT_LIMIT = "ares"`; `"mesen2-observed"` is the observed rule) | | C2 | **A<