# Undocumented behaviour, quirks, and contradictions Sony's SPC700 manual is not public here, and no hardware-captured per-instruction corpus exists. Every rule below therefore rests on one of: test ROMs run on SNES hardware (gilyon's spctest, PeterLemon's CPU tests, blargg's experiments as anomie reports them), research documents (anomie, fullsnes), emulators built from those experiments that we may read (ares by byuu and others, ISC; MAME's `cpu/spc700`, BSD-3-Clause) or run as closed boxes (MAME 0.285 through `scripts/mame_trace.py`), and the corpus generated from one of them (SingleStepTests spc700, from higan's timings via JSMoo, MIT). GPL and LGPL sources (bsnes/higan, Mesen2, blargg's snes_spc in libgme, MAME's `machine/s_smp` and `sound/s_dsp`) are closed boxes: Wave 2 (2026-11-19, [provenance.md](provenance.md)) removed what earlier text said about their source and re-rested each claim on SST, anomie, ares or fullsnes. Each item names its sources and their tier; tier words are defined in [validation.md](validation.md). "Measured" means `scripts/sst_survey.py` or `scripts/mame_trace.py` was run on 2026-10-21 and the number is recorded in validation.md. Items U are behaviours a core must have; items C are places where sources disagree or are silent; items B are board-side (S-SMP) facts the core must not implement but must let the board implement. ## Behaviour items (U) **U1. Stores read their destination first, with three exceptions.** Every store to memory except `MOV dd, ds` ($FA) and `MOV (X)+, A` ($AF) reads the destination address immediately before writing it; `MOVW d, YA` ($DA) reads only the low byte's address. *Research documentation:* anomie ("Most of the MOV instructions targeting memory actually include a read cycle on the destination"; cycle-doc groups 10-17 "Verified by blargg" / "Yes, RMW even for MOV"), fullsnes "Memory Store". *Emulator, measured:* SingleStepTests, every case of `8F C4 C5 C6 C7 D4 D5 D7` (and the other stores), never for `AF`, for `FA` only when source = destination, low byte only for `DA`. The consequence on the S-SMP: a store to `$FD`-`$FF` clears that timer's counter (B2). **U2. Direct-page addressing wraps within the page.** `d+X`, `d+Y`, `[d+X]` and the high byte of every direct-page word (`[d]`, `MOVW`, `ADDW`, `SUBW`, `CMPW`, `INCW`, `DECW`) stay in `P*$100 + $00..$FF`. Absolute and stack addresses: absolute indexed adds across pages freely, the stack wraps within page 1, PC wraps at $FFFF. *Research:* anomie "OPCODES". *Emulator, measured:* SingleStepTests cases with the pointer at `$xxFF` read the high byte from `$xx00` (`87`, `BA`, `3A` checked). **U3. MUL sets N and Z from Y alone.** `MUL YA` (9 cycles): YA = Y × A; N and Z come from the high byte. *Research:* anomie, fullsnes ("NZ on Y only"). *Emulator:* ares ("result is set based on y (high-byte) only"), SST `cf.json`. **U4. DAA and DAS.** DAA: if C or A > $99, A += $60 and C ← 1; then if H or A & $0F > 9, A += $06. DAS: if !C or A > $99, A −= $60 and C ← 0; then if !H or A & $0F > 9, A −= $06. N Z from the result; H unchanged; V unchanged. Note the second test uses the A already adjusted by the first. *Research:* anomie ("DAA and DAS depend on C and H"), fullsnes. *Emulator, measured:* anomie's rule reproduces A and C on all 2,000 SingleStepTests cases of `DF`/`BE`. *Hardware-run tests:* gilyon's spctest has 9 DAA and 7 DAS cases (including non-BCD inputs, e.g. A = $91, C = 1 → $F1), and anomie's rule reproduces all 16 expected values; MAME 0.285 passes them (mame-oracle.md). **U5. DIV YA, X: the documented-weird results.** 12 cycles. When `YA / X < $200` the result is ordinary: A = quotient (low 8 bits), Y = remainder, **V = quotient > $FF** (so V can be set while A still holds the low 8 bits of a 9-bit quotient). Otherwise A and Y are "not helpful" (anomie) but deterministic, produced by the 9-step shift-subtract loop anomie gives: ```text uint17 yva = YA ; uint17 x = X << 9 loop 9 times { ROL yva (17-bit) ; if yva >= x: yva ^= 1 ; if yva & 1: yva -= x (mod 2^17) } Y = yva >> 9 (8 bits) ; V = bit 8 ; A = yva & $FF ``` H is set if `(Y & $0F) >= (X & $0F)` with the **original** Y and X (anomie "H is odd"); N Z from A. X = 0 is not special: YA = $0000, X = 0 gives A = $FF, Y = $00, V = 1, H = 1 (gilyon's first DIV test). ares uses a closed form instead (`A = 255 - (ya - (X<<9)) / (256 - X)`, `Y = X + (ya - (X<<9)) % (256 - X)` when `Y >= 2X`). *Measured:* anomie's loop and ares' closed form give the same A, Y and V on **all 16,777,216 inputs** (exhaustive, CPython, 30 s); anomie's loop reproduces A, Y, V on all 1,000 SingleStepTests `9E` cases and all 7 gilyon DIV tests. Tier: research documentation + hardware-run test ROM (gilyon) + emulators (ares, SST). **U6. TSET1 / TCLR1.** `(a) ← (a) | A` / `(a) ← (a) & ~A`; N Z as for `CMP A, (a)` using the value read **before** the write; the address is read twice before the write (6 cycles). *Research:* fullsnes, anomie group 22. fullsnes dismisses the claim that they only reach $0000-$7FFF ("that is nonsense"). *Emulator:* SST `0e.json`, `4e.json`. **U7. BRK, RET1, and the B and I flags.** BRK pushes PCH, PCL, PSW, then sets B and clears I, and loads PC from `$FFDE`/`$FFDF`, the same vector as `TCALL 0`. RET1 pops PSW then PC, so it restores B and I from the stack. *Research:* anomie table (flags `...1.0..`), fullsnes ("set BRK opcode"). *Emulator:* ares (`instructionBreak`, `instructions.cpp` l.148-159), SST `0f.json`. **U8. 16-bit arithmetic flags.** ADDW/SUBW: H is the carry from bit 11, V the signed overflow of the 16-bit operation (bit 15), C the carry/no-borrow out of bit 15, Z from all 16 bits, N bit 15. CMPW: N Z C only. INCW/DECW: N Z only. *Research:* fullsnes "For ADDW/SUBW, H is carry from bit11 to bit12"; anomie ("H on high byte"). *Emulator:* ares `algorithmADW`/`SBW` (two chained 8-bit ADC/SBC, Z recomputed on 16 bits), SST. **U9. The P flag gates TEST writes (board needs it).** A write to `$F0` has no effect while P = 1. *Research:* anomie ("writing this register seems to have no effect when the P flag is set"; "This register's behavior hasn't been thoroughly tested"). *Emulator:* ares (`sfc/smp/io.cpp` l.82 `if(r.p.p) break;`, ISC). The register is the board's, but the board must read the CPU's current P inside the write callback, so the core keeps `psw` current at every bus callback (it does anyway if flags are updated before the write that follows them). **U10. Executing from the I/O page.** Opcode fetches, operand fetches and the dummy reads of PC hit the I/O registers when PC is in `$00F0`-`$00FF`: a fetch from `$FD` clears timer 0's counter, a dummy read of PC can do the same. blargg's `exec_io_tests/1-test_exec_from_io.smc` (2010 archive) exercises it; no expected result is published. A core that makes every cycle a callback at the right address gets this for free; it is listed so nobody "optimises" the dummy reads away. **U11. No interrupts; SLEEP and STOP hang.** The S-SMP has no interrupt sources; `EI`/`DI` change I only; `SLEEP` and `STOP` stop the CPU until reset. *Research:* fullsnes (quoted in [start-here.md](start-here.md)). Bus activity while halted: C5. **U12. Reset values.** On reset PC ← word at `$FFFE` (the IPL ROM's `$FFC0`), P = B = I = 0 (fullsnes "/RESET ... ..00.0.."). Other registers before the IPL runs: unknown to hardware sources (ares, `spc700.cpp` l.32-40: A = X = Y = 0, SP = $EF, PSW = $02; other emulators were reported to differ, from reading their source under the old rule; closed box from now on, never a default). The IPL sets SP = $EF and leaves A = X = Y = 0, PSW = $02 for uploaded code (anomie "IPL BOOT ROM"). Make them settable; default to ares' values, which equal the post-IPL state except PC. **U13. Register transfers.** `MOV SP, X` sets no flags; `MOV X, SP` and every other register-to-register `MOV` set N Z; `POP r` sets no flags (`POP PSW` loads them). *Research:* anomie, fullsnes. *Emulator:* ares `instructionTransfer` (`if(&to == &S) return;`), SST. **U14. Calls push the address of the next instruction**, high byte first; RET pops low then high. Not the 6502's return-minus-one. *Research:* fullsnes. *Emulator:* SST `3f`, `4f`, `n1`, `6f`. **U15. Absolute-bit operands are 13-bit.** `m.b` = 16-bit operand, address `operand & $1FFF`, bit `operand >> 13`; the high three bits never reach the address bus. *Research:* anomie, fullsnes ("aaa.b ... [0000..1FFF] (13bit addr)"). *Emulator:* ares `instructionAbsoluteBitModify`, SST `0a 2a 4a 6a 8a aa ca ea`. ## Contradictions and silences (C) **C1. What is on the address bus during an internal cycle?** No source says. SingleStepTests records `wait` with address `null` for every internal cycle (195,940 of them); anomie writes `??`; ares' `idle()` takes no address. No S-SMP device is known to decode an address the CPU drives without a read or write. *Contract:* `idle()` takes no address ([the brief](handoff-brief.md)); if a die study ever shows otherwise, add it then. **C2. Is the second cycle of a one-byte opcode a read of PC, or internal?** ares and SingleStepTests (64,000 `D` cycles) make it a dummy read of the byte after the opcode; anomie writes "`??` IO" (address unknown); fullsnes counts it among an opcode's *internal* cycles in its wait-state table (NOP: "one internal cycle ... having RAM timings"). The two views differ only when that address is an I/O register (U10) or when TEST wait states differ between RAM and I/O. Unsettled; blargg's `1-test_exec_from_io` and `2-test_single_instr` look aimed at it but publish no expected values. *Default:* follow ares/SST (a real read callback), so the board sees it. **C3. Which wait states does an internal cycle take?** ares gives every internal cycle the I/O ("internal") wait states of TEST bits 6-7 (`sfc/smp/timing.cpp`). fullsnes gives a per-opcode count of internal cycles that take I/O waits, the rest taking RAM waits (bits 4-5), e.g. NOP 0 of 1, TCALL 3 of 3, DIV 10 of 11; reproduced in [timing.md](timing.md) "Every opcode". Only visible with TEST ≠ `$0A`, which no known software does. fullsnes' count for `PCALL` (3) exceeds the 2 internal cycles every other source gives it, so its table is not fully consistent with the cycle sequences either. *Contract:* `idle()` carries enough (the opcode and the index of the internal cycle within it, or a precomputed class) for the board to apply either model; the brief makes this an open decision. **C4. `[d]+Y` loads: where is the internal cycle?** ares and SingleStepTests: `R@PC+1, I, R@ptr, R@ptr+1, R@data` for the read forms ($17 $37 ... $F7), but `R@PC+1, R@ptr, R@ptr+1, I, R@data, W@data` for the store `MOV [d]+Y, A` ($D7). anomie (group 7, "most likely") puts the internal cycle after the pointer reads for both. Same count, so no timing test sees it; only the sub-instruction position of the pointer reads moves. *Default:* SST (rung 1 compares every cycle); flag the difference in the handler's comment. **C5. SLEEP and STOP bus activity.** SST records `R D I D I D I` (7 cycles): its generator emits three dummy-read/internal pairs and stops (`spc700_test_generator.js`: `SPC_GEN_WAIT_HOW_LONG = 6`). ares loops `read(PC); idle()` until reset (`instructionStop`, `instructions.cpp` l.558-563). No hardware source. *Default:* after the fetch, `stopped = True`; each later `step()` makes one `idle()` (so the board's clock keeps running) and returns 1; exclude `EF`/`FF` from rung 1's cycle comparison, compare registers only. **C6. Order of stack, vector and internal cycles in calls, returns, pushes and pops.** anomie's cycle doc puts the pushes of CALL, PCALL, TCALL and BRK on cycles 2-3 (before the operand or vector reads) and the pops of RET/RET1 on cycles 2-3, each marked "Order ... may be wrong" or "WTF with all the IO cycles?", and gives PUSH as "IO, S, IO" ("Or is it Data-IO-IO or IO-IO-Data?"). ares and SingleStepTests agree with one another on a different order: operands first, then `I`, then the pushes, then `I`s ([timing.md](timing.md)); BRK's first cycle after the fetch is a dummy read of PC in both (anomie: IO). fullsnes' internal-cycle count for PCALL (3) fits neither ordering's 2 (C3). *Default:* SST, since it has the most specific claim and ares agrees. **C7. Test-and-branch internal cycle position.** `CBNE d+X, r` ($DE): SST `R R I R I R (I I)`; anomie 31c `op, d, IO, data, r, IO (IO IO)` ("the rest is guesswork"). `DBNZ Y, r` ($FE): SST `D I R (I I)` (dummy read of PC, internal, then the offset); anomie 31e `op, r, IO, IO (IO IO)`. `BBS/BBC/CBNE d` agree. Same counts. *Default:* SST. **C8. Compare forms' last cycle.** `CMP d, #i` ($78), `CMP dd, ds` ($69) and `CMP (X), (Y)` ($79) do not write; anomie asks for the first two "does it IO or read again?" and says of the third "it is an IO cycle". ares and SST make all three an internal cycle. *Default:* internal; a re-read would be visible on `$FD`-`$FF` destinations, which nobody has reported testing. **C9. Corpus data on dummy reads is not uniform.** SingleStepTests records a dummy read's data as `null` except where its generator had already chosen a value for that address (e.g. `TCALL`'s dummy read of PC is recorded as a plain read with data, because the generator calls `read()` there). A core returns whatever memory holds; compare addresses and kinds always, data only where it is not null. **C10. MAME reads an ADC's memory destination twice.** (MAME's `cpu/spc700` is BSD-3-Clause, R. Belmont and Karl Stenerud; read.) `OP_ADCM` passes `read_8_DP(DST)` to the `SUBOP_ADC` macro, which expands it twice, so `ADC $F2,#$04` performs `R R W`. Found by rung 4 on Donkey Kong Country. anomie groups 10, 18, 19 ("Verified by blargg") and SingleStepTests have one read. A MAME artefact; visible on hardware only at `$FD`-`$FF`, where MAME's second read would return 0. *Default:* one read; the replay drops the repeat. ## Board-side S-SMP facts (B) Not the core's, recorded here because they shape the bus contract. **B1. CPU I/O ports.** `$F4`-`$F7` read the S-CPU's last writes to `$2140`-`$2143` and write the values the S-CPU reads; the two directions are separate latches. CONTROL bits 4/5 zero the input latches (every time a 1 is written, not on an edge: anomie). A simultaneous S-SMP write and S-CPU read returns the OR of old and new (anomie, fullsnes; not hardware-tested by a published ROM). ares splits the `$F4`-`$F7` read cycle in two halves (`sfc/smp/memory.cpp` l.15-22: "reads from $00f4-$00f7 require more time than internal reads"). **B2. Timers.** Three, stage 1 at 128 cycles (T0, T1) or 16 (T2); TnTARGET `$FA`-`$FC` (0 = 256); 4-bit TnOUT `$FD`-`$FF` cleared on **read**, including the read half of a store (U1) and a dummy read (C2, U10). Stage 2/3 reset on a 0→1 edge of the enable bit (anomie); fullsnes says "0=Disable, set TnOUT=0 & reload divider". ares (ISC) resets timers 0 and 1 on a 0→1 edge but timer 2 on every CONTROL write that is *not* a 0→1 edge of bit 2 (`sfc/smp/io.cpp` l.108, `if(!timer2.enable.raise(data.bit(2)))`), against anomie's 0→1 rule for all three: a contradiction for the board's tests (blargg's `test_timer_*` ROMs, 2010 archive). A race when writing TnTARGET just after a stage-1 tick is described in an email anomie cites but does not include. **B3. TEST (`$F0`).** Bit 0 timers off (1 = off), bit 3 timers on (must be 1), bit 1 RAM write enable, bit 2 "crash"/RAM read disable (ares returns $5A on reads, "0xff on mini-SNES"), bits 4-5 RAM wait states, 6-7 I/O wait states; writes ignored while P = 1 (U9); default `$0A`. The three documents name the bits differently (anomie `ssssTRrt` with a combined 4-bit speed field and a 16-entry rate table; fullsnes two 2-bit fields), but agree on the default. **B4. CONTROL (`$F1`) bit 7 maps the 64-byte IPL ROM at `$FFC0`-`$FFFF` for reads; writes there always go to RAM.** Writes to `$F0`-`$FF` also land in the RAM underneath (ares "even IO writes affect underlying RAM"; anomie). Power-on CONTROL: anomie and fullsnes' text say `$B0`, fullsnes' register table and MAME say `$80`. TCALL 15..0's vectors (`$FFC0`-`$FFDF`) and BRK's read through the overlay when it is mapped, so with the IPL ROM in, TCALL vectors are IPL code bytes. **B5. DSP ports.** `$F2` selects a DSP register, `$F3` reads/writes it; addresses $80-$FF read as mirrors of $00-$7F and ignore writes (anomie, fullsnes, ares). The DSP is snes-python's in-board module. ## Open items, in priority order 1. C2 and U10: whether the implied-opcode second cycle is a real read. A hardware run of blargg's `1-test_exec_from_io.smc` with its output recorded would settle it; none is published. 2. C3: the internal-cycle wait class, only with TEST ≠ `$0A`; blargg's `test_speed`/`speed_2_freezes2` ROMs and `notes.txt` are the only data. 3. C4, C6, C7: sub-instruction order where SST and anomie differ; visible only with TEST wait states or timer-read races. No die study of the S-SMP is known (searched 2026-10-21: no die shot or netlist found).