# `norx` — NOR > **Category:** [Integer ALU](../categories/alu.md) · **Form:** [X](../forms/X.md) · **Opcode:** `0x7c0000f8` ## Assembler Mnemonics | Mnemonic | XML entry | Flags | Description | | --- | --- | --- | --- | | `nor` | `norx` | — | NOR | | `nor.` | `norx` | Rc=1 | NOR | ## Syntax ```asm nor[Rc] [RA], [RS], [RB] ``` ## Encoding ### `norx` — form `X` - **Opcode word:** `0x7c0000f8` - **Primary opcode (bits 0–5):** `31` - **Extended opcode:** `124` - **Synchronising:** no | Bits | Field | Meaning | | --- | --- | --- | | 0–5 | `OPCD` | primary opcode | | 6–10 | `RT/FRT/VRT` | destination | | 11–15 | `RA/FRA/VRA` | source A | | 16–20 | `RB/FRB/VRB` | source B | | 21–30 | `XO` | extended opcode (10 bits) | | 31 | `Rc` | record-form flag | ## Operands | Field | Role | Description | | --- | --- | --- | | `RS` | norx: read | Source GPR (alias for RD in some stores). | | `RB` | norx: read | Source GPR. | | `RA` | norx: write | Source GPR (`r0`–`r31`). | | `CR` | norx: write (conditional) | Condition-register update. When `Rc=1`, CR field 0 (or CR6 for vector compares, CR1 for FPU) is updated from the result. | ## Register Effects ### `norx` - **Reads (always):** `RS`, `RB` - **Reads (conditional):** _none_ - **Writes (always):** `RA` - **Writes (conditional):** `CR` ## Status-Register Effects - `norx`: **CR0** ← signed-compare(result, 0) with `SO ← XER[SO]`, when `Rc=1`. ## Operation (pseudocode) ``` RA <- ~((RS) | (RB)) ``` ## C Translation Example ```c /* No hand-written C yet. Translate the Canary emitter snapshot */ /* under Implementation References; its HIR maps directly: */ /* f.LoadGPR(n) / f.StoreGPR(n, v) -> r[n] / r[n] = v */ /* f.LoadFPR / StoreFPR, f.LoadVR / StoreVR -> f[n], v[n] */ /* f.Load(ea, T), f.Store(ea, v) -> raw read / write; emitters */ /* wrap them in f.ByteSwap for the big-endian guest value */ /* f.UpdateCR(n, v) -> CR field n from v's LOW 32 BITS vs 0 */ /* f.LoadCA / f.StoreCA -> xer.CA; f.StoreSAT -> vscr.SAT */ /* i.XO.RA, i.D.DS, ... -> the bit-fields listed under Operands */ /* The Register Effects and Status-Register Effects tables above */ /* enumerate every side effect a faithful translation must emit. */ ``` ## Implementation References **`norx`** - Canary XML: [`tools/ppc-instructions.xml` — search for `mnem="norx"`](https://github.com/xenia-canary/xenia-canary/blob/f21ebd49e979e44f081f474df78c3fbfee9cb3f2/tools/ppc-instructions.xml) - Canary emitter: [`src/xenia/cpu/ppc/ppc_emit_alu.cc:763`](https://github.com/xenia-canary/xenia-canary/blob/f21ebd49e979e44f081f474df78c3fbfee9cb3f2/src/xenia/cpu/ppc/ppc_emit_alu.cc#L763) - Sylpheed opcode: [`crates/sylpheed-ppc/src/opcode.rs:198`](../../../crates/sylpheed-ppc/src/opcode.rs#L198) - Sylpheed decoder: [`crates/sylpheed-ppc/src/decoder.rs:892`](../../../crates/sylpheed-ppc/src/decoder.rs#L892)
Canary emitter (frozen snapshot @ f21ebd49e9) ```cpp int InstrEmit_norx(PPCHIRBuilder& f, const InstrData& i) { // RA <- ¬((RS) | (RB)) Value* ra = f.Not(f.Or(f.LoadGPR(i.X.RT), f.LoadGPR(i.X.RB))); f.StoreGPR(i.X.RA, ra); if (i.X.Rc) { f.UpdateCR(0, ra); } return 0; } ```
## Special Cases & Edge Conditions - **`RA ← ~(RS OR RB)`.** Bit-wise NOR. The canonical idiom for one-instruction NOT: **`not RA, RS` is the simplified mnemonic for `nor RA, RS, RS`** — both source operands the same yields `~RS`. Almost every disassembly contains this pattern. - **Operand convention** is X-form (`RA` destination, `RS`/`RB` sources). - **64-bit operation** on Xenon; full 64-bit complement via `!` on `u64`. - **No `OE` or `XER` side effects.** - **`Rc=1` CR0 update truncates to 32 bits in xenia-rs.** [`interpreter.rs:372`](https://git.mc02.dev/fabi/xenia-rs/src/commit/8401d4d5112849bf7b0f78f9d620f3620b1ce58d/crates/xenia-cpu/src/interpreter.rs) uses `as i32 as i64`. Note that NOR almost always produces results with high bits set (since the OR rarely covers all 64 bits), so the truncated CR0 is usually `LT` (negative low half) where spec might give a different signed compare for the full 64-bit value. - **`nor.` after a clear-low operation is a common pattern** for testing whether some high-bit mask is empty. ## Related Instructions - [`orx`](orx.md), [`orcx`](orcx.md) — base OR family. - [`andx`](andx.md), [`andcx`](andcx.md), [`nandx`](nandx.md) — AND family. - [`eqvx`](eqvx.md) — NXOR. - [`xorx`](xorx.md) — XOR. - `not` (simplified mnemonic for `nor RA, RS, RS`). ## IBM Reference - [AIX 7.3 — `nor` (NOR)](https://www.ibm.com/docs/en/aix/7.3.0?topic=set-nor-instruction) - [AIX 7.3 — `not` (simplified mnemonic)](https://www.ibm.com/docs/en/aix/7.3.0?topic=mnemonics-not-complement-register)