Bundles state that lives OUTSIDE the xenia-rs repo so a fresh clone on
another machine can be brought up to identical configuration via
migration/setup.sh:
- claude-memory/ ~/.claude/projects/-home-fabi-RE-Project-Sylpheed/memory/
(103 files, 1.1 MB - MEMORY.md + every
project_xenia_rs_*.md from audits
addis_signext through audit-058)
- project-root/dot-claude/ <project-root>/.claude/settings.json
(Stop hook + permissions)
- project-root/ppc-manual/ <project-root>/ppc-manual/
(PowerPC reference docs, 397 files, 3.7 MB)
- project-root/run-canary.sh <project-root>/run-canary.sh
- README.md Human-readable setup checklist
- setup.sh Idempotent installer (also reclones
xenia-canary at pinned HEAD 6de80dffe)
- MANIFEST.md Per-file mapping + per-file-not-bundled
restoration recipe
Excluded from bundle (not shippable via git):
- Sylpheed ISO (7.8 GB; copyright; manual copy required)
- sylpheed.db (395 MB; regenerable from XEX via analysis tooling)
- target/ build artifacts (rebuild on target)
- audit-runs probe firehoses (.log/.stdout/.stderr ~11 GB; rerun if needed)
- audit-runs memory dumps (.bin ~4.5 GB; rerun audit-026/027/029 if needed)
- xenia-canary checkout (setup.sh reclones from
git.mc02.dev/fabi/Xenia-Canary.git at HEAD 6de80dffe)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5.2 KiB
5.2 KiB
addis — Add Immediate Shifted
Category: Integer ALU · Form: D · Opcode:
0x3c000000
Assembler Mnemonics
| Mnemonic | XML entry | Flags | Description |
|---|---|---|---|
addis |
addis |
— | Add Immediate Shifted |
Syntax
addis [RD], [RA0], [SIMM]
Encoding
addis — form D
- Opcode word:
0x3c000000 - Primary opcode (bits 0–5):
15 - Extended opcode: —
- Synchronising: no
| Bits | Field | Meaning |
|---|---|---|
| 0–5 | OPCD |
primary opcode |
| 6–10 | RT |
destination GPR (or RS when storing) |
| 11–15 | RA |
source GPR (0 ⇒ literal 0 for RA0 forms) |
| 16–31 | D/SI/UI |
16-bit signed or unsigned immediate |
Operands
| Field | Role | Description |
|---|---|---|
RA0 |
addis: read | Source GPR; when the encoded register number is 0 the operand is the literal 64-bit zero, not r0. |
SIMM |
addis: read | 16-bit signed immediate. Sign-extended to 64 bits before use. |
RD |
addis: write | Destination GPR. |
Register Effects
addis
- Reads (always):
RA0,SIMM - Reads (conditional): none
- Writes (always):
RD - Writes (conditional): none
Status-Register Effects
No condition-register or status-register effects.
Operation (pseudocode)
if RA = 0 then RT <- EXTS(SIMM) << 16
else RT <- (RA) + (EXTS(SIMM) << 16)
C Translation Example
/* addis RT, RA, SIMM — RA=0 means literal 0 */
uint64_t base = (insn.RA == 0) ? 0 : r[insn.RA];
r[insn.RT] = base + ((uint64_t)(int64_t)(int16_t)insn.SIMM << 16);
Implementation References
addis
- xenia-canary XML:
tools/ppc-instructions.xml— search formnem="addis" - xenia-canary emit:
src/xenia/cpu/ppc/ppc_emit_alu.cc:138 - xenia-rs opcode:
crates/xenia-cpu/src/opcode.rs:8 - xenia-rs decoder:
crates/xenia-cpu/src/decoder.rs:339 - xenia-rs interpreter:
crates/xenia-cpu/src/interpreter.rs:121-134
xenia-rs interpreter body (frozen snapshot)
PpcOpcode::addis => {
// Xbox 360 user mode is 32-bit ABI (MSR.SF=0), so addis must
// produce a value whose upper 32 bits don't pollute downstream
// 64-bit arithmetic. The PPC ISA in 64-bit mode sign-extends
// simm16 before the shift, producing 0xFFFFFFFF_xxxx0000 for
// negative simm16 (high bit set). When this value flows into
// a 64-bit subfc against a zero-extended lwz value, the unsigned
// 64-bit comparison yields wrong CA. Truncate to 32 bits to
// simulate 32-bit ABI behavior.
let ra_val = if instr.ra() == 0 { 0u64 } else { ctx.gpr[instr.ra()] };
let result = ra_val.wrapping_add((instr.simm16() as i64 as u64) << 16);
ctx.gpr[instr.rd()] = result as u32 as u64;
ctx.pc += 4;
}
Special Cases & Edge Conditions
RA0semantics. When theRAfield encodes 0, the operand is the literal 64-bit zero, notr0. This makesaddis RT, 0, hi16the canonical "load high half" idiom. To user0's actual value as a base, copy it viamrfirst or use a different opcode.- Immediate is sign-extended then shifted left 16. So
addis r3, 0, 0x8000writes0xFFFFFFFF80000000, not0x000000008000_0000. The 32-bit sign extension surprise is the most common bug in hand-written PPC assembly. - Forms the high half of a 32-bit immediate. The classic
lis rT, hi; ori rT, rT, lo(orlis/addi) sequence builds a full 32-bit constant.lis rT, valis a simplified mnemonic foraddis rT, 0, val. - No
XER[CA], noXER[OV], noRc. This instruction has no status side-effects whatsoever. Useaddicoraddcxif a carry is required. - 64-bit
RAoperand. The shift-and-add is 64-bit on the Xenon; the immediate's sign-extension fills the high 48 bits. Soaddis r3, r4, -1adds0xFFFFFFFFFFFF0000to a 64-bitr4. - No overflow detection.
lis r3, 0x7FFF; addis r3, r3, 0x7FFFhappily wraps without comment.
Related Instructions
addi— D-form add immediate, no shift; sameRA0rule.addic,addicx— immediate adds that also writeXER[CA].oris,ori— pair withaddis/listo build 32-bit constants without affecting CR or XER.addx,addcx— XO-form register adds.lis(simplified) — assembler shorthand foraddis RT, 0, value.