CONSOLIDATION.md Phase 6. Both lived untracked in the project root -- on one
disk, backed up by nothing.
tools/ppc-manual/ 393 files, 3.7 MB. 455 instructions, 350 family pages,
598 mnemonics resolvable through index.json, plus the
generator that produced them.
tools/run-canary.sh the oracle launcher.
🔴 THE LAUNCHER WAS BROKEN IN TWO WAYS AND IS REWRITTEN, not copied:
* it pointed at `xenia-rs/sylpheed.iso`, a SYMLINK. Wine cannot resolve one
and says "path invalid", which reads as a corrupt image rather than a path
problem -- it has cost a session before. It now points at the real file and
warns if handed a symlink.
* it hardcoded one machine's absolute paths, and named `xenia-rs`, which this
consolidation retires. Now derived from the script's own location, with
SYLPH_CANARY_BIN / SYLPH_ISO overrides and a check that each exists.
The standing constraints are in its header where someone will read them: one
emulator at a time, Canary runs MUTED, and never judge a crash or a hang from
a Bash-launched run -- a SIGKILL that looked like the binary was the editor's
process supervisor.
⚠️ The manual's GENERATOR reads the xenia-rs source tree, which is going away.
Its decoder now lives here as crates/sylpheed-ppc, so the generator must be
repointed before it is run again. Recorded in the README rather than left for
someone to discover; the manual's content is checked in and regenerates from
nothing implicitly.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
8.3 KiB
mfspr — Move from Special-Purpose Register
Category: Control / CR / SPR · Form: XFX · Opcode:
0x7c0002a6
Assembler Mnemonics
| Mnemonic | XML entry | Flags | Description |
|---|---|---|---|
mfspr |
mfspr |
— | Move from Special-Purpose Register |
Syntax
mfspr [RD], [SPR]
Encoding
mfspr — form XFX
- Opcode word:
0x7c0002a6 - Primary opcode (bits 0–5):
31 - Extended opcode:
339 - Synchronising: no
| Bits | Field | Meaning |
|---|---|---|
| 0–5 | OPCD |
primary opcode (31) |
| 6–10 | RT |
destination / source GPR |
| 11–20 | spr/tbr/FXM |
SPR/TBR number (byte-swapped halves) or CR field mask |
| 21–30 | XO |
extended opcode |
| 31 | — |
reserved |
Operands
| Field | Role | Description |
|---|---|---|
SPR |
mfspr: read | Special-Purpose-Register number. Encoded with the two 5-bit halves swapped (bits 11-15 become the high half, bits 16-20 the low half). |
RD |
mfspr: write | Destination GPR. |
Register Effects
mfspr
- Reads (always):
SPR - Reads (conditional): none
- Writes (always):
RD - Writes (conditional): none
Status-Register Effects
No condition-register or status-register effects.
Operation (pseudocode)
n <- spr_number(SPR) ; SPR field has its two 5-bit halves swapped
RT <- SPR(n)
C Translation Example
/* mfspr RT, SPR — SPR field has swapped halves */
uint32_t n = ((insn.SPR & 0x1F) << 5) | ((insn.SPR >> 5) & 0x1F);
switch (n) {
case 1: r[insn.RT] = xer_pack(); break; /* XER */
case 8: r[insn.RT] = lr; break; /* LR */
case 9: r[insn.RT] = ctr; break; /* CTR */
case 256: r[insn.RT] = vrsave; break; /* VRSAVE*/
case 268: r[insn.RT] = tb & 0xFFFFFFFFu; break; /* TBL */
case 269: r[insn.RT] = tb >> 32; break; /* TBU */
default: r[insn.RT] = 0; break;
}
Implementation References
mfspr
- xenia-canary XML:
tools/ppc-instructions.xml— search formnem="mfspr" - xenia-canary emit:
src/xenia/cpu/ppc/ppc_emit_control.cc:666 - xenia-rs opcode:
crates/xenia-cpu/src/opcode.rs:53 - xenia-rs decoder:
crates/xenia-cpu/src/decoder.rs:799 - xenia-rs interpreter:
crates/xenia-cpu/src/interpreter.rs:1567-1595
xenia-rs interpreter body (frozen snapshot)
PpcOpcode::mfspr => {
let spr = instr.spr();
ctx.gpr[instr.rd()] = match spr {
crate::context::spr::XER => ctx.xer() as u64,
crate::context::spr::LR => ctx.lr,
crate::context::spr::CTR => ctx.ctr,
crate::context::spr::DEC => ctx.dec as u64,
crate::context::spr::TBL => ctx.timebase & 0xFFFF_FFFF,
crate::context::spr::TBU => ctx.timebase >> 32,
crate::context::spr::VRSAVE => ctx.vrsave as u64,
// Xbox 360 Xenon processor signature (from canary).
crate::context::spr::PVR => 0x0071_0800,
// Benign SPRs — titles read these but we don't model them.
crate::context::spr::SPRG0
| crate::context::spr::SPRG1
| crate::context::spr::SPRG2
| crate::context::spr::SPRG3
| crate::context::spr::HID0
| crate::context::spr::HID1
| crate::context::spr::DAR
| crate::context::spr::DSISR
| crate::context::spr::PIR => 0,
_ => {
tracing::warn!("mfspr: unimplemented SPR {}", spr);
0
}
};
ctx.pc += 4;
}
SPR Number Encoding — the "halves swap"
The 10-bit spr field in the XFX form is stored in a transposed order: the bits that software names the high half (bits 5..9 of the SPR number) occupy instruction bits 16..20, and the low half (bits 0..4) occupies instruction bits 11..15. Software (and this manual) always refers to the logical, unswapped SPR number.
decoded_spr = ((field & 0x1F) << 5) | ((field >> 5) & 0x1F)
So a programmer writing mfspr RT, 8 (read LR) encodes spr-field = 0x100 — not 8. Assemblers handle this transparently; disassemblers reverse it. When writing a translator that parses raw instruction words, swap the halves explicitly.
SPR Map (Xenon subset modelled by xenia)
| Decoded # | Name | Meaning | xenia-rs behaviour |
|---|---|---|---|
| 1 | XER |
Fixed-point exception register (CA / OV / SO + length field) | packed with ctx.xer() |
| 8 | LR |
Link register | ctx.lr |
| 9 | CTR |
Count register | ctx.ctr |
| 18 | DSISR |
Data-storage interrupt syndrome | returns 0 (stubbed) |
| 19 | DAR |
Data-access register | returns 0 (stubbed) |
| 256 | VRSAVE |
Vector-register save mask | ctx.vrsave |
| 268 | TBL |
Time-base lower 32 bits | ctx.timebase & 0xFFFFFFFF |
| 269 | TBU |
Time-base upper 32 bits | ctx.timebase >> 32 |
| 272–275 | SPRG0..3 |
Software scratch registers (kernel) | returns 0 (stubbed) |
| 287 | PVR |
Processor-version register | 0x00710800 (Xenon signature) |
| 1008–1009 | HID0/1 |
Hardware implementation registers | returns 0 (stubbed) |
| 1023 | PIR |
Processor-ID register | returns 0 (stubbed) |
Unrecognised SPRs return 0 and log a warning. Games rarely read unmodelled SPRs; when they do it's usually clock-skew or sanity checks.
Special Cases & Edge Conditions
- Privilege. Some SPRs are privileged on real hardware (MSR, HID0/1, SPRG0..3, DSISR, DAR, PIR). Xbox 360 titles run in a mixed privilege model under the hypervisor; xenia exposes all SPRs without a privilege check because the captured title binaries never contain a real privileged read that should trap.
LRandCTRhave dedicated simplified mnemonics. Assemblers recognisemflr RT≡mfspr RT, 8andmfctr RT≡mfspr RT, 9. Similarlymfxer RT≡mfspr RT, 1. Disassemblers emit the simplified forms; the translation agent should map both forms to the same abstract operation.mftbvs.mfspr TBL/TBU. Reading the time-base has a dedicated X-form variantmftbthat uses a separate opcode. Post-Xbox-360 PowerISA deprecatedmfspr TBL/TBU, but xenia accepts both. Prefermftbin new translations.- Side-effect-free.
mfsprhas no effect on any register beyondRT. It can be freely reordered with non-SPR-touching instructions. - No
Rc/OE. This is an XFX-form instruction; bit 31 is reserved (0).
Related Instructions
mtspr— the inverse; write a GPR to an SPR.mftb— read time-base (preferred overmfspr TBL/TBU).mflr,mfctr,mfxer— simplified mnemonics of this instruction.mcrxr— moveXER[SO..CA]to a CR field and clear them.
Simplified Mnemonics
| Simplified | Expansion |
|---|---|
mfxer RT |
mfspr RT, 1 |
mflr RT |
mfspr RT, 8 |
mfctr RT |
mfspr RT, 9 |