- Category pages linked each family as `<slug>.md`, relative to categories/, where no family page lives. They now link `../<category>/<slug>.md`. - Form pages linked a member into its *own* category directory, so every VMX128 sibling (`vsldoi128`) pointed at vmx128/ although its family page is under vmx/. They now link into the family's directory. - Hand-written "Related" and sibling mentions linked other categories' pages as if they were in the same directory. 109 are retargeted through the page index; 29 that pointed a family page at itself (`vrefp128` on vrefp.md) and 6 naming instructions the manual has no page for are plain text now. Regenerated at the existing Canary pin (f21ebd49e): upstream has moved on, and re-pinning belongs in its own change. The generator reports 0 family pages changed and is idempotent; the only dead links left are TEMPLATE.md's placeholders. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
4.8 KiB
4.8 KiB
addi — Add Immediate
Category: Integer ALU · Form: D · Opcode:
0x38000000
Assembler Mnemonics
| Mnemonic | XML entry | Flags | Description |
|---|---|---|---|
addi |
addi |
— | Add Immediate |
Syntax
addi [RD], [RA0], [SIMM]
Encoding
addi — form D
- Opcode word:
0x38000000 - Primary opcode (bits 0–5):
14 - 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 |
addi: read | Source GPR; when the encoded register number is 0 the operand is the literal 64-bit zero, not r0. |
SIMM |
addi: read | 16-bit signed immediate. Sign-extended to 64 bits before use. |
RD |
addi: write | Destination GPR. |
Register Effects
addi
- 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)
else RT <- (RA) + EXTS(SIMM)
C Translation Example
/* addi 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;
Implementation References
addi
- Canary XML:
tools/ppc-instructions.xml— search formnem="addi" - Canary emitter:
src/xenia/cpu/ppc/ppc_emit_alu.cc:103 - Sylpheed opcode:
crates/sylpheed-ppc/src/opcode.rs:10 - Sylpheed decoder:
crates/sylpheed-ppc/src/decoder.rs:453
Canary emitter (frozen snapshot @ f21ebd49e9)
int InstrEmit_addi(PPCHIRBuilder& f, const InstrData& i) {
// if RA = 0 then
// RT <- EXTS(SI)
// else
// RT <- (RA) + EXTS(SI)
Value* si = f.LoadConstantInt64(XEEXTS16(i.D.DS));
Value* v = si;
if (i.D.RA) {
v = f.Add(f.LoadGPR(i.D.RA), si);
}
f.StoreGPR(i.D.RT, v);
return 0;
}
Special Cases & Edge Conditions
RA0semantics. When the encodedRAfield is0the operand is the literal constant0, not the value ofr0. This letsaddi rT, 0, SIMMload a constant (theli rT, SIMMsimplified mnemonic). To user0's value you must use a register-register add (add RT, r0, RBthrough a temp) or an instruction withoutRA0semantics.- No flags written. Unlike
add,addicannot beRcorOE— no CR or XER update. Useaddicif you needXER[CA], oraddicx(addic.) if you need bothXER[CA]and a CR0 update. - Immediate is 16-bit signed (
SIMM, range−32768 … +32767), sign-extended to 64 bits before the add. No carry/overflow is produced regardless of the result. - Simplified mnemonics. Assemblers recognise several aliases that all assemble to
addi:li RT, SIMM≡addi RT, 0, SIMM(load immediate; relies onRA0).la RT, D(RA)≡addi RT, RA, D(load address; purely syntactic).subi RT, RA, SIMM≡addi RT, RA, −SIMM.
- PC-relative idiom.
addi RT, RA, Dis the low-half completion of a two-instruction address load preceded byaddisRT, 0, HI. The assembler emits@ha/@lrelocations so the low half can be negative without corrupting the high half (add-compensation).
Related Instructions
addis— same encoding family but the immediate is shifted left by 16 bits. Together they build any 32-bit constant or PC-relative address.addic,addicx— D-form adds that do setXER[CA](and CR0 for the record form).addx— the register-register form.subfic— reverse-subtract immediate (imm − RA) with carry.ori,oris— the alternative D-form constant-building instructions (but these don't add, they OR).