# `vnor` — Vector Logical NOR > **Category:** [VMX (Altivec)](../categories/vmx.md) · **Form:** [VX](../forms/VX.md) · **Opcode:** `0x10000504` ## Assembler Mnemonics | Mnemonic | XML entry | Flags | Description | | --- | --- | --- | --- | | `vnor` | `vnor` | — | Vector Logical NOR | | `vnor128` | `vnor128` | — | Vector128 Logical NOR | ## Syntax ```asm vnor [VD], [VA], [VB] vnor128 [VD], [VA], [VB] ``` ## Encoding ### `vnor` — form `VX` - **Opcode word:** `0x10000504` - **Primary opcode (bits 0–5):** `4` - **Extended opcode:** `1284` - **Synchronising:** no | Bits | Field | Meaning | | --- | --- | --- | | 0–5 | `OPCD` | primary opcode (4) | | 6–10 | `VRT/VD` | destination vector register | | 11–15 | `VRA/VA` | source A vector register | | 16–20 | `VRB/VB` | source B vector register | | 21–31 | `XO` | extended opcode (11 bits) | ### `vnor128` — form `VX128` - **Opcode word:** `0x14000290` - **Primary opcode (bits 0–5):** `5` - **Extended opcode:** `656` - **Synchronising:** no | Bits | Field | Meaning | | --- | --- | --- | | 0–5 | `OPCD` | primary opcode (4 or 5) | | 6–10 | `VD128l` | destination low 5 bits | | 11–15 | `VA128l` | source A low 5 bits | | 16–20 | `VB128l` | source B low 5 bits | | 21 | `VA128H` | source A high bit | | 22 | `—` | reserved | | 23–25 | `VC` | optional VC / XO sub-field | | 26 | `VA128h` | source A middle bit | | 27 | `—` | reserved | | 28–29 | `VD128h` | destination high 2 bits | | 30–31 | `VB128h` | source B high 2 bits | ## Operands | Field | Role | Description | | --- | --- | --- | | `VA` | vnor: read; vnor128: read | Source A vector register. | | `VB` | vnor: read; vnor128: read | Source B vector register. | | `VD` | vnor: write; vnor128: write | Destination vector register. | ## Register Effects ### `vnor` - **Reads (always):** `VA`, `VB` - **Reads (conditional):** _none_ - **Writes (always):** `VD` - **Writes (conditional):** _none_ ### `vnor128` - **Reads (always):** `VA`, `VB` - **Reads (conditional):** _none_ - **Writes (always):** `VD` - **Writes (conditional):** _none_ ## Status-Register Effects _No condition-register or status-register effects._ ## Operation (pseudocode) ``` ; Pseudocode derives directly from the xenia-rs interpreter ; arm (see Implementation References). Operation semantics: ; - Read source operands from the fields listed under Operands. ; - Apply the arithmetic / logical / memory action described ; in the Description field above. ; - Write results to the destination register(s); update any ; status bits enumerated under Status-Register Effects. ; Consult the IBM AIX reference link under IBM Reference for ; canonical PPC-style pseudocode where xenia's expression is ; terse. ``` ## C Translation Example ```c /* C translation: the xenia-rs interpreter arm below in */ /* Implementation References is the authoritative semantic */ /* snapshot. Translate it line-by-line: */ /* - ctx.gpr[N] -> r[N] (or f[]/v[] for FPRs/VRs) */ /* - mem.read_u*/write_u* -> mem_read_u*_be / mem_write_u*_be */ /* - ctx.update_cr_signed(fld, v) -> update_cr_signed(fld, v) */ /* - ctx.xer_ca / xer_ov / xer_so -> xer.CA / xer.OV / xer.SO */ /* The Register Effects and Status-Register Effects tables above */ /* enumerate every side effect a faithful translation must emit. */ ``` ## Implementation References **`vnor`** - xenia-canary XML: [`tools/ppc-instructions.xml` — search for `mnem="vnor"`](../../xenia-canary/tools/ppc-instructions.xml) - xenia-canary emit: [`src/xenia/cpu/ppc/ppc_emit_altivec.cc:1168`](../../xenia-canary/src/xenia/cpu/ppc/ppc_emit_altivec.cc#L1168) - xenia-rs opcode: [`crates/xenia-cpu/src/opcode.rs:110`](../../xenia-rs/crates/xenia-cpu/src/opcode.rs#L110) - xenia-rs decoder: [`crates/xenia-cpu/src/decoder.rs:534`](../../xenia-rs/crates/xenia-cpu/src/decoder.rs#L534) - xenia-rs interpreter: [`crates/xenia-cpu/src/interpreter.rs:2244-2252`](../../xenia-rs/crates/xenia-cpu/src/interpreter.rs#L2244-L2252)
xenia-rs interpreter body (frozen snapshot) ```rust PpcOpcode::vnor | PpcOpcode::vnor128 => { let (va, vb, vd) = vmx_reg_triple(instr); let a = ctx.vr[va].as_u32x4(); let b = ctx.vr[vb].as_u32x4(); let mut r = [0u32; 4]; for i in 0..4 { r[i] = !(a[i] | b[i]); } ctx.vr[vd] = xenia_types::Vec128::from_u32x4_array(r); ctx.pc += 4; } ```
**`vnor128`** - xenia-canary XML: [`tools/ppc-instructions.xml` — search for `mnem="vnor128"`](../../xenia-canary/tools/ppc-instructions.xml) - xenia-canary emit: [`src/xenia/cpu/ppc/ppc_emit_altivec.cc:1171`](../../xenia-canary/src/xenia/cpu/ppc/ppc_emit_altivec.cc#L1171) - xenia-rs opcode: [`crates/xenia-cpu/src/opcode.rs:110`](../../xenia-rs/crates/xenia-cpu/src/opcode.rs#L110) - xenia-rs decoder: [`crates/xenia-cpu/src/decoder.rs:623`](../../xenia-rs/crates/xenia-cpu/src/decoder.rs#L623) - xenia-rs interpreter: [`crates/xenia-cpu/src/interpreter.rs:2244-2252`](../../xenia-rs/crates/xenia-cpu/src/interpreter.rs#L2244-L2252)
xenia-rs interpreter body (frozen snapshot) ```rust PpcOpcode::vnor | PpcOpcode::vnor128 => { let (va, vb, vd) = vmx_reg_triple(instr); let a = ctx.vr[va].as_u32x4(); let b = ctx.vr[vb].as_u32x4(); let mut r = [0u32; 4]; for i in 0..4 { r[i] = !(a[i] | b[i]); } ctx.vr[vd] = xenia_types::Vec128::from_u32x4_array(r); ctx.pc += 4; } ```
## Special Cases & Edge Conditions - **Bitwise NOR across the full 128-bit register.** `VD = ~(VA | VB)`. The operation is lane-agnostic; PPC documents it per-bit, xenia implements it as four 32-bit lanes for convenience but the result is identical to 16-byte or 8-half-word decomposition. - **`vnor VD, VA, VA` is the idiomatic `vnot`** (bitwise complement of `VA`). No dedicated `vnot` exists in base Altivec. - **Aliasing is legal.** `vnor v3, v3, v4` or `vnor v3, v3, v3` are well-defined and common. - **No flags.** No CR, XER, VSCR side-effect. - **VMX128 sibling [`vnor128`](vnor128.md)** provides the same op with access to `v0..v127`; xenia shares the interpreter arm (`vmx_reg_triple` selects the right encoding helper). - **Useful for mask inversion.** When a compare result needs to be inverted — e.g. "where not equal" — `vnor` of the compare result with itself is cheaper than a dedicated inversion. ## Related Instructions - [`vand`](vand.md) — bitwise AND. - [`vandc`](vandc.md) — `VA & ~VB` (useful as a fused inversion on the B side). - [`vor`](vor.md), [`vxor`](vxor.md) — complete the boolean-primitive set. - [`vsel`](vsel.md) — three-input bit-select; often fed by the inverse of a compare mask. - [`vcmpequb`](vcmpequb.md) and related compares — produce the masks `vnor` is typically applied to. ## IBM Reference - [AIX 7.3 — `vnor` (Vector Logical NOR)](https://www.ibm.com/docs/en/aix/7.3.0?topic=set-vnor-vector-logical-nor-instruction) - [IBM AltiVec Technology Programmer's Interface Manual, Chapter 3 — Logical Operations](https://www.nxp.com/docs/en/reference-manual/ALTIVECPIM.pdf)