# The 80960KB and 80960KA: what the core must model Sources (scripts/pinned_files.json; full list in [sources.md](sources.md)): the 80960KB Programmer's Reference Manual, March 1988 (**KBPRM**), the 80960KB Hardware Designer's Reference Manual, March 1988 (**KBHDRM**), the 80960MC Programmer's Reference Manual, July 1988 (**MCPRM**, a cross-check), and the 80960KA/KB Specification Update, June 1997 (**SPECUPD**). Page numbers are the manuals' own. Everything below is tagged DOC unless it says otherwise; nothing has been measured on a chip. ## Which part, and why the KB - Sega's Model 2 (every revision: original, 2A-CRX, 2B-CRX, 2C-CRX) has one i960 as its main CPU. MAME 0.285 names it "Intel 80960KB" at 25 MHz (50 MHz crystal / 2) for all 89 Model 2 sets (OBSERVED: `mame -listxml`, model2-python census). - The KA is the KB without the on-chip floating-point unit; the KBPRM says most of the manual also covers the KA (KBPRM, Preface). A core with a `has_fpu` variant flag covers both. The MC adds memory management, tagged memory and multiprocessing (MCPRM), and the later CA/CF/Jx/Hx parts are different microarchitectures; none is in scope. - Whether Model 2's chip is the KB or the KA, and which stepping, is not established by a board photograph we hold (U1 in the handoff brief). MAME says KB; whether the games use floating-point instructions at all is a question the first traces can answer (count opcodes in the REG-format FP range). ## Programming model (KBPRM ch. 3-4) - **Registers.** 16 global registers g0-g15 (g15 is the frame pointer, FP), 16 local registers r0-r15 per procedure (r0 = previous frame pointer PFP, r1 = stack pointer SP, r2 = return instruction pointer RIP), four 80-bit floating-point registers fp0-fp3 (KB only), and the control registers: instruction pointer IP, arithmetic controls AC, process controls PC, trace controls TC (KBPRM 3-1 to 3-10). **Trap for oracle work:** MAME's debugger calls the process controls `pc` and the instruction pointer `ip` (docs/mame-oracle.md). - **The procedure call mechanism and the local register cache.** Each `call`/`callx`/ `calls` allocates a new set of local registers; the KB keeps **four** sets on chip and spills the oldest set to the procedure stack in memory when a fifth is needed, filling it back on return (KBPRM 4-3). The spills and fills are bus traffic a bus-exact core must reproduce in order and timing. SPECUPD erratum 4 adds **undocumented flushes on interrupt return**: returning from an interrupt flushes every cached set except the interrupted procedure's (SPECUPD p. 9-10). Whether Model 2's chip has this behaviour depends on its stepping (U2). - **Instruction formats.** REG, COBR, CTRL, MEMA and MEMB (KBPRM appendix B). Instructions are one word, or two for MEMB with a 32-bit displacement (KBPRM 3-6, against the overview's "all instructions are 32 bits long", KBPRM 2-3: C1, a wording conflict only). - **Instruction cache:** 512 bytes, read-only, purged by an instruction (KBPRM 2-2, 3-11, 13-9). Its line size and replacement are not stated in the chapters read so far (U3). Self- modifying code needs an explicit purge on the chip, so a core that ignores the cache can run code a real KB would not (the board's copro upload path writes data, not code, HYPOTHESIS). - **Register scoreboarding:** a load sets scoreboard bits on its destination registers and instructions that do not touch them proceed, so loads can overlap execution (KBPRM 3-5; detail in appendix C, table C-1). - **Faults and interrupts:** a fault table and an interrupt table in memory, located through the initial memory image (IMI) and the PRCB the processor reads at initialisation (KBPRM ch. 7-9); an interrupt table of 248 vectors, 240 for general use, taken as an implicit call on a separate interrupt stack (KBPRM 2-3), and a processor priority from 0 to 31 in the process controls (KBPRM 7-4). On the hardware side the KB offers four direct interrupt pins or an 8259A-style interface (KBHDRM 3-31, 5-5). - **Floating point (KB):** single, double and 80-bit extended real, IEEE-754 semantics with rounding control, normalising mode and fault masks in AC (KBPRM ch. 12). Values in global and local registers are converted to extended format in fp0-fp3. ## Bus (KBHDRM ch. 3) The L-bus is a multiplexed 32-bit address/data bus with burst transfers of up to four words (KBHDRM 3-12 to 3-14), `CLK2` at twice the processor clock (KBHDRM 3-8, 3-15), bus arbitration for a second master (KBHDRM 3-20 to 3-23). Model 2's own wait states are unknown (model2-python U-list; MAME's driver notes that Sega Rally's car placement "seems to be affected by i960 clock speed, may need wait state emulation": OBSERVED, model2.cpp header). ## Timing as data (KBPRM appendix C) Intel publishes the KB's instruction timing: the pipeline (appendix C, C-3 to C-8), tables of clock counts by class (logical, bit, scan/span, move, arithmetic, multiply/divide, branch, call/return, decimal, simple and complex floating point: tables C-2 to C-13) and the scoreboard rules (table C-1). That is a tier-2 timing source, which the R3000A and VR4300 Phase 0s did not have. It fits the JIT proposal's "timing as data" and the late-era method's L7 directly: the core states each instruction's cost and stall rule as a table. What the tables leave out, and so stays open: instruction-cache miss costs on Sega's bus, the register-cache spill/fill cost with Sega's memory, interrupt latency in clocks. Intel's own average: 7.5 MIPS at 20 MHz and 10 MIPS at 25 MHz (KBPRM 2-6). MAME's i960 retires 606,796 instructions in 910,199 cycles over the first two frames of `vf2` (0.67 per clock; OBSERVED, docs/mame-oracle.md). MAME's per-instruction cycle counts are its own approximation, not Intel's tables (C2). ## Errata (SPECUPD) Four errata for the C ("Shrink") stepping: ALE# in secondary bus master mode, HLDA/ADS# with asynchronous logic, breakpoint register initialisation, and the interrupt-return flushes above (SPECUPD pp. 8-10). Only the last is visible to software on a single-master board like Model 2's.