# The EE Core's instruction set Sources, in order of authority (docs/sources-ee.md): - **TX79** = Toshiba, *TX System RISC TX79 Core Architecture*, Rev. 2.0, April 2001: the C790 core's public user's manual (tier 2). Cited as "TX79 §x.y". - **ECUM** = Sony, *EE Core User's Manual* 6.0 (2002), and **ECISM** = *EE Core Instruction Set Manual* 6.0 (2002): Sony's manuals, marked SCE CONFIDENTIAL, as distributed with the PS2 Linux kit (tier 2, facts only, cited by page). - **ps2tek** (PSI-Rockin; no licence, facts only, tier 3) for the decode tables in readable form. - **ps2autotests** (ISC; tier 1: outputs captured on a real PS2) as the judge of results. Nothing here is copied from those documents; it is our own summary of facts, with the page to check. ## What the core is The EE Core is Toshiba's C790 (TX79 family) as Sony configured it: a 2-way superscalar, in-order-issue, 64-bit MIPS processor with a 6-stage pipeline (ECUM §1.1, §1.3; TX79 §2.2). It decodes and issues up to two instructions a cycle, completes them in order, but lets data-cache misses, uncached loads, multiplies, divides, prefetches and coprocessor instructions retire out of order (ECUM §1.1, DOC). Little endian only (ECUM §1.1). Clock: 294.912 MHz (ps2tek "EE Architecture"; MAME 0.285 lists `maincpu` at 294,912,000 Hz, OBSERVED); the CPU bus runs at half that, 147.456 MHz (EE User's Manual §2.1.2 names 147.456 MHz as the bus clock; ECUM §6.3.3: a 4-qword refill is "4 bus cycles (8 CPU cycles)", DOC). ## Registers | Register | Width | Notes | Source | | --- | --- | --- | --- | | GPR0-31 | 128 bits | r0 reads zero. The upper 64 bits are used only by the multimedia (parallel) instructions and LQ/SQ | ECUM §1.4.1 | | HI, LO | 128 bits each | bits 63..0 are the MIPS HI/LO of the I0 pipe's MAC; bits 127..64 are **HI1/LO1**, used by MULT1, DIV1, MADD1 and friends (the I1 pipe's MAC) and by the parallel multiplies | ECUM §1.4.1, §3.1.2 | | SA | shift amount | for QFSRV (quadword funnel shift); written by MTSA/MTSAB/MTSAH, read by MFSA | ECUM §3.1.3 | | PC | 32 bits | | ECUM §3.1.4 | | FPR0-31, FCR0, FCR31, ACC | 32 bits | COP1; docs/fpu.md | ECUM §8.2 | | COP0 | 32 bits | docs/cop0-tlb-caches.md | ECUM §3.2 | **32-bit and 64-bit operations leave GPR bits 127..64 unchanged** (TEST ROM: ps2autotests `cpu/ee/alu.expected` prints all four words of `rd` after ADDU, and the upper two words keep the value the test planted, `0000133a 00001339`; ECISM marks the untouched part of the register as "unchanged" in its operation diagrams, DOC). 32-bit results are sign-extended into bits 63..32 as on any MIPS III (ECISM per instruction). ## Instruction groups | Group | What the EE Core has | Source | | --- | --- | --- | | MIPS I/II/III integer | loads and stores (byte to doubleword, LWL/LWR/LDL/LDR/SWL/SWR/SDL/SDR, LWU), ALU, 64-bit shifts and adds (DADD..DSRA32), traps, branches and branch-likely, J/JAL/JR/JALR, SYSCALL, BREAK, SYNC (with SYNC.L and SYNC.P forms) | ECUM §2.2.1, Table 2-x; ECISM | | **not supported** from MIPS III | DMULT, DMULTU, DDIV, DDIVU, LL, LLD, SC, SCD | ECUM §2.2.2 (DOC). What they do if executed (reserved instruction exception or something else) is **U1** | | MIPS IV subset | MOVN, MOVZ, PREF only | ECUM §2.8 | | EE-specific multiply/divide | three-operand MULT/MULTU (result also to `rd`), MADD/MADDU (HI:LO += rs x rt, `rd` = new LO), and the I1-pipe copies MULT1, MULTU1, DIV1, DIVU1, MADD1, MADDU1, MFHI1, MFLO1, MTHI1, MTLO1 | ECUM §2.11.1 | | Multimedia (MMI) | 93 mnemonics in ECUM Table 2-11: parallel add/subtract with and without saturation (byte, halfword, word), parallel multiply, multiply-add, divide (PMULTW, PMADDW, PDIVW, PMULTH, PMADDH, PHMADH, PDIVBW...), parallel shifts and QFSRV, abs/min/max, logic (PAND, POR, PXOR, PNOR), compares (PCGT*, PCEQ*), PLZCW, data rearrangement (PEXT*, PPAC*, PINT*, PCPY*, PREVH, PEXE*, PEXC*, PROT3W, PEXT5, PPAC5), MFSA/MTSA/MTSAB/MTSAH, LQ/SQ | ECUM §2.11.2; ECISM per instruction | | Interrupt control | EI, DI (COP0 function codes) | ECUM §2.11; ps2tek "TLB/Exception" table | | COP0 | MFC0/MTC0 (including the performance counter and breakpoint register forms), BC0F/BC0T/BC0FL/BC0TL, TLBR/TLBWI/TLBWR/TLBP, ERET, CACHE, EI/DI | ECUM §2.9, §5.3.2, ch. 6, 7, 9 | | COP1 | docs/fpu.md | ECUM ch. 8 | | COP2 (VU0 macro mode) | QMFC2/QMTC2/CFC2/CTC2 with the interlock bit, LQC2/SQC2, BC2F/BC2T/BC2FL/BC2TL, the macro operations (VADD..., VCALLMS, VCALLMSR) | ECUM §2.10.2-3; VU User's Manual ch. 5; docs/vu.md | **The encoding.** Primary opcode 1Ch is the MMI table; its function field selects MADD, MADDU, PLZCW, MULT1..., the parallel shifts, and four sub-tables MMI0..MMI3 selected by bits 10..6 (ps2tek "EE Instruction Decoding"; ECISM chapter 7, "OpCode Encoding", p. 395 on). LQ is 1Eh and SQ 1Fh; LQC2 36h, SQC2 3Eh; MTSAB/MTSAH sit in REGIMM (rt = 18h, 19h); MFSA/MTSA in SPECIAL (28h, 29h). The decode table in the specification is generated from ECISM's chapter 7 encoding tables (a fact table), and checked against ps2tek's maps and the disassembly MAME prints on the recipe's trace (docs/mame-oracle.md). **LQ and SQ ignore the low four address bits** (ECISM "LQ", p. 141: "the least-significant four bits of the effective address are masked to zero", so no alignment exception, DOC). ## Branches and the delay slot MIPS branch delay slots, and branch-likely nullifying the slot when not taken. Sequences the core forbids (ECUM §1.3.6, DOC): a branch or ERET in a branch's delay slot; and in a branch-likely's slot, SYNC.P, SYNC.L, CACHE (which must be preceded and followed by SYNC), MTSA/MTSAB/MTSAH, TLBR, TLBWI, TLBWR. What the hardware does with them is undefined by the manual; the specification raises nothing and logs a "forbidden sequence" event (decision E7), because games should not contain them. **The "short loop" erratum.** GNU as (binutils) has `-mfix-r5900`, added in 2018 for the PS2 Linux port, which inserts a NOP into the delay slot of loops of six instructions or fewer; `-march=r5900` turns it on. The conditions, as an old GCC 2.95 note quoted on the Linux MIPS list gives them: a loop of at most six instructions, the delay slot counted, with a single conditional branch at its end, and a delay slot that is not already a NOP (binutils and linux-mips mailing-list threads, 2018-2019, found by search 2026-11-26; tier 5 as to the hardware: toolchain authors' statements). No Sony or Toshiba manual we hold describes it, nor what the core then does wrong (**U2**, HYPOTHESIS). The specification does not invent a failure mode; it logs a "short-loop erratum shape" event, and a test ELF built with and without the fix decides once a console probe is possible. ## Multiply, divide and HI/LO - The I0 pipe's MAC owns HI/LO bits 63..0; the I1 pipe's MAC owns HI1/LO1. Both multiply in 4 cycles with a throughput of 2, divide in 37 (ECUM §2.12 latency table, DOC). Reading HI/LO before the result is ready interlocks (ECUM §1.3.1). - The parallel multiplies and divides use both MACs (I0+I1) and both halves of HI/LO (ECUM Table 1-1, §2.12). - **Divide by zero and the overflow case** (0x80000000 / -1): the results the EE leaves in HI/LO are not given by ECISM ("undefined" in MIPS terms). ps2autotests `cpu/ee/muldiv.expected` holds the hardware's values (TEST ROM); the specification takes them from there (**U3** until the test runs). ## What the specification needs to decide per instruction Each handler names: the operation (ECISM's pseudo-code as prose), which register bits it writes (64-bit or 128-bit), the physical pipe(s) it needs (ECUM Table 1-1), its latency and throughput class (ECUM §2.12; docs/pipeline-timing.md), and its exceptions. That is the JIT proposal's "timing as data" and "restricted semantics" (accepted 2026-11-25).