[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AKAXADZT8P1NJR1173AQKV":3,"skill-same:01M7AKAXADZT8P1NJR1173AQKV":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7AKAXADZT8P1NJR1173AQKV","assembly-fundamentals-and-isas",null,"Use when deciding whether to write assembly at all, learning or comparing instruction sets, or reasoning about what the machine actually does beneath the ISA. Covers the machine model (registers, addressing modes, flags, endianness, alignment, memory ordering), x86-64 (register file, the instruction set honestly, compiler idioms, the x86 tax), AArch64\u002FARM64, RISC-V (design philosophy, profiles and fragmentation), and other ISAs worth knowing. Includes the router for the whole assembly-programming reference.","the-vibey-project\u002Fvibey","the-vibey-project","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F329298758?v=4","01M7AJHGZ9722CTJ4JNQZVRH0Q","the vibey project","01M7AJHGZVMG2K7TGXQ6XFHVG3",5,"MIT","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fassembly-programming\u002Fskills\u002Fassembly-fundamentals-and-isas\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: assembly-fundamentals-and-isas\ndescription: \"Use when deciding whether to write assembly at all, learning or comparing instruction sets, or reasoning about what the machine actually does beneath the ISA. Covers the machine model (registers, addressing modes, flags, endianness, alignment, memory ordering), x86-64 (register file, the instruction set honestly, compiler idioms, the x86 tax), AArch64\u002FARM64, RISC-V (design philosophy, profiles and fragmentation), and other ISAs worth knowing. Includes the router for the whole assembly-programming reference.\"\n---\n\n# Assembly Programming: Fundamentals and ISAs\n\n> **Part 1 of 4** of the *Assembly Programming* reference (plugin `assembly-programming`), covering §0–§5. Sibling skills: `assembly-toolchain-performance-and-simd` (§6–§10), `assembly-systems-crypto-and-inline` (§11–§14), `assembly-reference` (§15–§20). Section numbers are shared across the set; a reference written as §N → `skill` points into that sibling skill.\n>\n> **Currency:** Verified August 2026. See §17 → `assembly-reference` for the currency snapshot and what goes stale first.\n\n> **How to read this.** Reference, not tutorial. Sections are independent. Three markers:\n> - **[DURABLE]** — machine organization, algorithms, or a lesson that has held since the\n>   1970s. Does not expire.\n> - **[ISA]** — specific to x86-64, AArch64, RISC-V, or a particular microarchitecture.\n>   Verify against the vendor's current manual.\n> - **[CONTESTED]** — practitioners genuinely disagree, usually about how much hand-written\n>   assembly is justified.\n>\n> **⚠️ GOTCHA** boxes mark the mistakes that produce silent corruption, ABI violations,\n> or code that is slower than the C you replaced.\n>\n> **The three framings that organize everything below:**\n> 1. **The instruction set is an interface, not the machine.** The CPU you're actually\n>    programming is out-of-order, superscalar, speculative, and cached. Your instructions\n>    are decoded into µops, reordered, and executed in parallel. Reasoning about assembly\n>    as \"the CPU does this, then this\" is wrong in ways that make your optimizations wrong.\n> 2. **Reading assembly is a hundred times more common than writing it, and more\n>    valuable.** Most of the return here comes from understanding compiler output,\n>    debugging an optimized crash, or reverse-engineering a binary.\n> 3. **When you write assembly, you are taking on the compiler's job permanently.** No\n>    retargeting, no auto-vectorization, no new-CPU tuning, and no help from the next\n>    twenty years of compiler improvements. That's the real cost, and it's paid in\n>    maintenance rather than in the initial write.\n\n---\n\n## §0. Routing\n\n### 0.1 Should you write assembly at all?\n\n**[DURABLE] For almost all code, no.** Modern compilers beat hand-written assembly on\nanything but small, carefully-chosen kernels — and they retarget for free. The legitimate\nreasons, in rough order of how often they're actually valid:\n\n| Reason | Notes |\n|---|---|\n| **Reading compiler output** | The dominant use. Not writing at all |\n| **Debugging optimized code \u002F crash dumps** | You have no choice; the source is a fiction at `-O2` |\n| **Reverse engineering, malware analysis, security research** | Reading, again |\n| **Instructions the compiler won't emit** | Crypto (AES-NI, SHA, carry-less multiply), CRC, special atomics, cache control, hardware-specific instructions |\n| **Constant-time cryptography** | §12 → `assembly-systems-crypto-and-inline` — the compiler is actively hostile to your requirements here |\n| **Boot code, context switches, interrupt vectors, syscall stubs** | §11 → `assembly-systems-crypto-and-inline` — there is no C for \"set up the stack before there is a stack\" |\n| **Hot kernels after profiling and after intrinsics** | Codecs, BLAS, hashing, parsers. And use **intrinsics first** |\n| **Extremely constrained targets** | Tiny MCUs, boot ROMs, size-limited firmware |\n| **Compiler bugs \u002F missing optimizations** | Real, but verify before assuming |\n| **Learning how machines work** | The best reason of all, and it doesn't need to ship |\n\n**[DURABLE] The ladder, and take it in order:**\n```\n1. Better algorithm                      ← usually the whole answer\n2. Better data layout \u002F memory access    ← usually the rest of it\n3. Compiler flags, PGO, LTO\n4. Restructure C\u002FC++\u002FRust so the compiler can vectorize\n5. Compiler INTRINSICS                   ← 95% of the benefit, register allocation for free\n6. Inline assembly for a specific instruction\n7. Hand-written assembly functions\n8. Hand-written assembly with microarchitectural scheduling\n```\n**Steps 5 and 7 are separated by a large maintenance cliff.** Intrinsics keep the\ncompiler's register allocation, scheduling, and inlining; hand-written assembly does not.\n\n### 0.2 The question router\n\n| Asked about... | Go to |\n|---|---|\n| Machine model: registers, memory, flags, endianness | §1 |\n| x86-64 specifically | §2 |\n| AArch64 \u002F ARM64 specifically | §3 |\n| RISC-V specifically | §4 |\n| Other ISAs (embedded, GPU, historical) | §5 |\n| Calling conventions and ABIs | §6 → `assembly-toolchain-performance-and-simd` |\n| Assemblers, syntax, toolchain, linking | §7 → `assembly-toolchain-performance-and-simd` |\n| Reading disassembly and compiler output | §8 → `assembly-toolchain-performance-and-simd` |\n| Performance: pipelines, latency, caches, branches | §9 → `assembly-toolchain-performance-and-simd` |\n| SIMD and vector programming | §10 → `assembly-toolchain-performance-and-simd` |\n| Systems assembly: interrupts, context switch, boot | §11 → `assembly-systems-crypto-and-inline` |\n| Cryptographic and constant-time assembly | §12 → `assembly-systems-crypto-and-inline` |\n| Inline assembly and intrinsics | §13 → `assembly-systems-crypto-and-inline` |\n| Debugging, testing, verification | §14 → `assembly-systems-crypto-and-inline` |\n| \"Don't do this\" | §15 → `assembly-reference` |\n| \"Which approach is better?\" | §16 → `assembly-reference` (contested) |\n| \"Is this still current?\" | §17 → `assembly-reference` |\n| Books, manuals, people | §18 → `assembly-reference` |\n\n---\n\n## §1. The Machine Model\n\n### 1.1 What's actually there\n\n```\n┌──────────────────────────────────────────────────────────────┐\n│ ARCHITECTURAL STATE (what the ISA promises)                  │\n│   general-purpose registers · SIMD\u002Fvector registers          │\n│   program counter · flags\u002Fcondition codes · stack pointer    │\n│   control\u002Fsystem registers · memory (virtual address space)  │\n└──────────────────────────────────────────────────────────────┘\n                    ↕  (the ISA is a CONTRACT, not a description)\n┌──────────────────────────────────────────────────────────────┐\n│ MICROARCHITECTURE (what actually happens)                    │\n│   fetch → decode → µop cache → RENAME (physical regs ≫ arch) │\n│   → scheduler\u002Freservation stations → OUT-OF-ORDER EXECUTION  │\n│   across multiple ports → load\u002Fstore buffers → RETIRE in     │\n│   order · branch predictors · L1\u002FL2\u002FL3 caches · TLBs ·       │\n│   prefetchers · store-to-load forwarding · speculation       │\n└──────────────────────────────────────────────────────────────┘\n```\n\n**[DURABLE] Register renaming is why most naive assembly intuitions fail.** The CPU has\nfar more physical registers than architectural ones and renames on the fly, so\n**write-after-write and write-after-read \"dependencies\" are free** — only true\nread-after-write data dependencies cost you. This is why `xor eax, eax` is faster than\n`mov eax, 0` (it's recognized as a zeroing idiom and breaks the dependency chain), and why\n\"reusing a register to save registers\" can be actively harmful.\n\n**[DURABLE] The three things that actually determine speed** (§9 → `assembly-toolchain-performance-and-simd`): the **critical path\nthrough the dependency graph**, **memory access patterns**, and **branch predictability**.\nInstruction *count* is a distant fourth and is the thing beginners optimize.\n\n### 1.2 Registers\n\n| Class | Purpose |\n|---|---|\n| General-purpose | Integers, addresses. x86-64: 16 (32 with APX); AArch64: 31 + zero register; RISC-V: 32 (x0 hardwired to zero) |\n| SIMD\u002Fvector | Packed data. §10 → `assembly-toolchain-performance-and-simd` |\n| Floating-point | Separate on some ISAs, shared with SIMD on others |\n| Flags\u002Fcondition | x86 EFLAGS, ARM NZCV. **RISC-V has none** — a deliberate design choice |\n| Special | PC\u002FIP, SP, link register, TLS base, system\u002Fcontrol registers |\n\n**[DURABLE] A zero register is a surprisingly large ISA win.** AArch64's `xzr`\u002F`wzr` and\nRISC-V's `x0` let one instruction encoding serve many purposes: `add rd, rs, x0` is a move,\n`beq rs, x0, label` is branch-if-zero, storing `xzr` is a memset. x86 has no zero register\nand needs distinct encodings for all of it.\n\n### 1.3 Addressing modes\n\n```\nx86-64:   [base + index*scale + disp]        scale ∈ {1,2,4,8}   — very expressive\n          mov rax, [rbx + rcx*8 + 16]\nAArch64:  [base], [base, #imm], [base, Xn{, LSL #s}], pre\u002Fpost-index\n          ldr x0, [x1, #16]!        pre-index:  x1 += 16, then load\n          ldr x0, [x1], #16         post-index: load, then x1 += 16\nRISC-V:   [base + imm12]  ONLY                                   — deliberately minimal\n          ld  a0, 16(a1)\n```\n**[DURABLE] This is the clearest illustration of the CISC\u002FRISC trade-off that survives\ninto 2026.** x86's addressing modes fold address arithmetic into the load for free —\nbut they're one reason x86 decoding is hard. RISC-V's single mode means indexed access\ncosts an extra `add`, which the designers judged a fair price for decode simplicity.\nNeither is wrong; they optimize different things.\n\n### 1.4 Endianness, alignment, and memory ordering\n\n- **Endianness**: x86-64, AArch64 (in practice), and RISC-V are all **little-endian**\n  today. Big-endian survives in network byte order, some MIPS\u002FPowerPC\u002FSPARC deployments,\n  and file formats. **Byte-swap instructions exist**: `bswap`\u002F`movbe` (x86), `rev` (ARM),\n  `rev8` (RISC-V Zbb).\n- **Alignment**: x86-64 tolerates unaligned scalar access with a small penalty (and\n  *requires* alignment for some SIMD instructions and all atomics that must not split a\n  cache line). ARM and RISC-V vary — unaligned may fault, may trap-and-emulate slowly, or\n  may work fine. **⚠️ A split-cache-line access is dramatically slower everywhere, and a\n  split-page access worse still.**\n- **Memory ordering [DURABLE, and the most dangerous area in multicore assembly]:**\n\n| ISA | Model |\n|---|---|\n| **x86-64** | **TSO** (total store order) — strong. Only store→load can reorder. `mfence`\u002F`lock`-prefixed ops for the rest |\n| **AArch64** | **Weak**, with acquire\u002Frelease built into instructions: `ldar`\u002F`stlr`, plus `dmb`\u002F`dsb`\u002F`isb` barriers |\n| **RISC-V** | **Weak** (RVWMO), with `fence` and `.aq`\u002F`.rl` suffixes on atomics |\n| **POWER** | Weak, notoriously so |\n\n> **⚠️ GOTCHA — x86's strong ordering hides bugs that ARM and RISC-V expose.** Concurrent\n> code developed and tested only on x86 routinely breaks on AArch64, because the missing\n> barrier never mattered before. This is one of the most common real-world porting\n> failures, and it produces rare, load-dependent corruption rather than a clean crash.\n\n---\n\n## §2. x86-64\n\n### 2.1 The register file\n\n```\n64-bit   32-bit  16-bit  8-bit    Conventional role (System V AMD64)\nrax      eax     ax      al\u002Fah    return value; implicit in mul\u002Fdiv\nrbx      ebx     bx      bl       callee-saved\nrcx      ecx     cx      cl       4th arg; implicit shift count\nrdx      edx     dx      dl       3rd arg; high half of mul\u002Fdiv\nrsi      esi     si      sil      2nd arg; string source\nrdi      edi     di      dil      1st arg; string destination\nrbp      ebp     bp      bpl      frame pointer (callee-saved)\nrsp      esp     sp      spl      STACK POINTER — never clobber\nr8–r15                            r8\u002Fr9 = 5th\u002F6th args; r12–r15 callee-saved\nxmm0–15 \u002F ymm0–15 \u002F zmm0–31       SIMD (§10)\nrip                               instruction pointer (RIP-relative addressing)\n```\n\n> **⚠️ GOTCHA — the 32-bit zero-extension rule.** Writing to a 32-bit register\n> **zero-extends into the full 64-bit register**; writing to a 16- or 8-bit register does\n> **not** (it merges, creating a **partial-register dependency stall**). So `mov eax, 1`\n> clears the upper 32 bits of `rax` — deliberately, and usefully, because it's a shorter\n> encoding — while `mov ax, 1` leaves the top 48 bits and creates a false dependency.\n> **Prefer 32-bit operations when the value fits**: shorter encoding, and free zeroing.\n\n### 2.2 The instruction set, honestly\n\nx86-64 is **variable-length** (1–15 bytes), **two-operand destructive** (`add rax, rbx`\nmeans `rax += rbx` — APX changes this, §17 → `assembly-reference`), and enormous. Practical groupings:\n\n- **Data movement**: `mov`, `movzx`\u002F`movsx` (zero\u002Fsign extend), `lea`, `push`\u002F`pop`,\n  `xchg`, `cmov`.\n- **`lea` is the workhorse.** It computes an address without accessing memory, so it's a\n  free three-operand add-and-shift: `lea rax, [rbx + rcx*4 + 8]`. Compilers use it\n  constantly for arithmetic that has nothing to do with addresses.\n- **Arithmetic\u002Flogic**: `add`\u002F`adc`, `sub`\u002F`sbb`, `imul`\u002F`mul`, `idiv`\u002F`div`\n  (**very slow — 20–100 cycles; strength-reduce it**), `and`\u002F`or`\u002F`xor`\u002F`not`, shifts,\n  `bt`\u002F`bts`\u002F`btr`.\n- **BMI1\u002FBMI2**: `andn`, `bextr`, `blsi`, `tzcnt`, `lzcnt`, `popcnt`, `pdep`\u002F`pext`\n  (**note: `pdep`\u002F`pext` are microcoded and glacial on pre-Zen 3 AMD** — a classic\n  portability-of-performance trap).\n- **Control**: `jmp`, `jcc`, `call`\u002F`ret`, `loop` (**don't** — slower than the equivalent\n  `dec`\u002F`jnz` on modern parts).\n- **`cmov`** — conditional move, no branch. Essential for §12 → `assembly-systems-crypto-and-inline`, and a good idea whenever a\n  branch is unpredictable.\n- **Atomics**: `lock`-prefixed RMW, `cmpxchg`, `cmpxchg16b`, `xadd`.\n- **Crypto**: AES-NI (`aesenc`…), SHA extensions, `pclmulqdq` (carry-less multiply — the\n  basis of fast GCM and CRC).\n\n### 2.3 Idioms you'll see in every compiler's output\n\n```asm\nxor  eax, eax        ; rax = 0. Shorter than mov, and BREAKS the dependency chain\ntest rax, rax        ; set flags from rax without a compare-with-zero\nlea  rax, [rbx+rbx*2]; rax = rbx*3, no multiplier, no flags touched\nsete al              ; materialize a condition as 0\u002F1 without branching\ncdq \u002F cqo            ; sign-extend eax→edx:eax before idiv  (forgetting this is a classic bug)\nendbr64              ; CET indirect-branch landing pad — required at indirect targets\n```\n\n### 2.4 The x86 tax\n\n**[DURABLE]** Variable-length decoding is genuinely expensive, which is why modern x86\ncores have **µop caches** to bypass the decoder on hot loops. Practical consequences:\n- **Code density matters more than instruction count** on x86 — fitting a loop in the µop\n  cache or in fewer 32-byte fetch windows is a real optimization.\n- **Alignment of branch targets** to 16 or 32 bytes can matter.\n- The **legacy modes** (real, protected, long) and the accumulated 40 years of encodings\n  are the reason a full x86 assembler is a large program.\n\n---\n\n## §3. AArch64 (ARM64)\n\n### 3.1 The register file\n\n```\nx0–x30    64-bit GPRs;  w0–w30 are the 32-bit views (writing wN zero-extends to xN)\n  x0–x7   arguments and return values\n  x8      indirect result location \u002F Linux syscall number\n  x9–x15  caller-saved (temporary)\n  x16,x17 IP0\u002FIP1 — intra-procedure-call scratch, may be clobbered by the LINKER's veneers\n  x18     PLATFORM REGISTER — reserved on some OSes (⚠️ Darwin, Windows). Don't touch\n  x19–x28 callee-saved\n  x29     FP (frame pointer)\n  x30     LR (link register — the return address)\nsp        stack pointer  (⚠️ MUST be 16-byte aligned at any public interface)\nxzr\u002Fwzr   the ZERO REGISTER (reads 0, writes discarded) — encoding 31, context-dependent with sp\npc        not directly writable\nv0–v31    128-bit SIMD (NEON), also used as scalar FP (s\u002Fd\u002Fh views)\nz0–z31    SVE scalable vectors; p0–p15 predicates (§10)\n```\n\n### 3.2 The character of the ISA\n\n**Fixed 32-bit instructions**, load\u002Fstore architecture (**arithmetic never touches memory**),\nmostly three-operand and non-destructive, and a genuinely clean encoding.\n\n```asm\n; the canonical prologue\u002Fepilogue\nstp  x29, x30, [sp, #-16]!   ; push FP and LR, pre-decrement sp\nmov  x29, sp\n; ...\nldp  x29, x30, [sp], #16     ; pop, post-increment\nret                          ; branch to x30\n\n; conditional execution without branches\ncmp   x0, x1\ncsel  x2, x3, x4, lt         ; x2 = (x0 \u003C x1) ? x3 : x4    ← constant-time friendly\ncinc  x2, x2, ne             ; conditional increment\ncbz   x0, label              ; compare-and-branch-if-zero: one instruction, no flags\ntbz   x0, #3, label          ; test-bit-and-branch\n\n; loading a 64-bit constant takes up to four instructions\nmovz x0, #0x1234, lsl #48\nmovk x0, #0x5678, lsl #32    ; movk = move-keep (doesn't clear other bits)\n; ...or, far more often:\nadrp x0, symbol              ; PC-relative page address (±4 GB)\nadd  x0, x0, :lo12:symbol    ; plus the low 12 bits\n```\n\n**[DURABLE] The `adrp`\u002F`add` pair is the single most characteristic AArch64 idiom** and\nthe thing that confuses people coming from x86's RIP-relative addressing. AArch64 can't\nencode a 64-bit address in a 32-bit instruction, so PC-relative addressing is split into\na 4 KB-page-granular part and a 12-bit offset.\n\n**Pointer authentication (PAC) and BTI** — Armv8.3+\u002F8.5+ security features you'll see in\nmodern compiler output: `paciasp`\u002F`autiasp` sign and authenticate the return address in\nthe prologue\u002Fepilogue (defeating ROP), and `bti c` marks legal indirect-branch targets.\n**Don't strip these**; on Apple platforms they're mandatory.\n\n**Atomics**: the classic **LL\u002FSC** pair `ldxr`\u002F`stxr` (load-exclusive \u002F store-exclusive,\nwith a retry loop), plus the much better **LSE** atomics from Armv8.1 (`ldadd`, `swp`,\n`cas`) which are single instructions and scale far better under contention.\n\n---\n\n## §4. RISC-V\n\n### 4.1 The design philosophy, and why it matters to you\n\n**[DURABLE] RISC-V is a small base plus modular extensions**, which makes it the easiest\nmajor ISA to learn and the most annoying to target portably.\n\n```\nRV32I \u002F RV64I   base integer (I = 32 registers; E = 16, for embedded)\nM  multiply\u002Fdivide      A  atomics          F\u002FD\u002FQ  float (single\u002Fdouble\u002Fquad)\nC  compressed (16-bit)  V  vector (§10)     B  bit manipulation (Zba\u002FZbb\u002FZbs)\nZicsr control regs      Zifencei            Zk*  scalar crypto     Zvk*  vector crypto\n```\nThe shorthand: **RV64GC** = IMAFD + Zicsr + Zifencei + C, the general-purpose target.\n\n```\nx0\u002Fzero  hardwired zero     x1\u002Fra  return address     x2\u002Fsp  stack pointer\nx3\u002Fgp    global pointer     x4\u002Ftp  thread pointer     x5–7\u002Ft0–2  temporaries\nx8\u002Fs0\u002Ffp saved \u002F frame ptr  x9\u002Fs1  saved\nx10–17\u002Fa0–a7  arguments and return values      x18–27\u002Fs2–11  saved\nx28–31\u002Ft3–6   temporaries\n```\n\n**Notably absent: condition flags.** Comparison and branch are fused into one instruction\n(`beq`, `bne`, `blt`, `bge`, `bltu`, `bgeu`), and `slt`\u002F`sltu` materialize a comparison as\n0\u002F1. This removes a serialization point and a rename hazard that x86 and ARM both carry.\n\n```asm\naddi sp, sp, -16\nsd   ra, 8(sp)\nsd   s0, 0(sp)\n# ...\nld   ra, 8(sp)\nld   s0, 0(sp)\naddi sp, sp, 16\nret                  # pseudo-instruction for: jalr x0, 0(ra)\n```\n\n**⚠️ Pseudo-instructions are pervasive and you must know they're not real**: `li`, `la`,\n`mv`, `nop`, `ret`, `call`, `j`, `beqz`, `not`, `neg`. The assembler expands each into one\nor more real instructions, and `li` with a large constant becomes `lui`+`addi`.\n\n### 4.2 Profiles — the fragmentation fix\n\n**[VERSIONED]** The extension modularity created a real portability problem, and\n**profiles** are the answer: a named set of mandatory and optional extensions that\nsoftware can target.\n\n**RVA23 was ratified 21 October 2024** and is the current 64-bit application-processor\nprofile. What matters for assembly programmers:\n- **The V (vector) extension is now MANDATORY** — it was optional in RVA22. Vectors are no\n  longer an optional accelerator; they're a baseline capability software can assume.\n- **RVA23 is the baseline requirement for the Android RISC-V ABI.**\n- Also newly mandatory in RVA23U64: **Zvfhmin** (vector half-precision), **Zvbb** (vector\n  bit manipulation), **Zvkt** (vector data-independent execution latency — see §12 → `assembly-systems-crypto-and-inline`),\n  **Zihintntl**, **Zicond** (integer conditional ops), **Zimop**\u002F**Zcmop**, **Zcb**,\n  **Zfa**, and **Supm** (pointer masking).\n- **The scalar crypto extensions Zkn and Zks are no longer options** — the stated goal is\n  for hardware and software vendors to **move to vector crypto**, since vectors are now\n  mandatory and vector crypto is substantially faster.\n- The hypervisor extension is in the S-mode profile.\n- Ratified specs are **frozen**: \"No changes are allowed… Ratified extensions are never\n  revised.\" Changes go into new extensions.\n\n---\n\n## §5. Other ISAs Worth Knowing\n\n| ISA | Where you'll meet it |\n|---|---|\n| **ARM32 \u002F Thumb-2** | Older embedded, Cortex-M. Thumb-2's mixed 16\u002F32-bit encoding is excellent for code density; **Cortex-M is Thumb-only** |\n| **AVR** | Arduino, 8-bit MCUs. Harvard architecture — separate code and data address spaces, which surprises everyone |\n| **MSP430, PIC, 8051** | Deeply embedded, still shipping in volume |\n| **POWER \u002F PowerPC** | IBM servers, older consoles. Weak memory model, big-endian heritage |\n| **MIPS** | Networking silicon, older Roku\u002Fembedded, and **every undergraduate architecture course** |\n| **SPARC** | Register windows — a genuinely different idea worth understanding |\n| **s390x** | IBM mainframe. Big-endian, and still absolutely everywhere in banking |\n| **WebAssembly** | A stack machine and a compile target, not hardware. Structured control flow, no registers |\n| **x86 16\u002F32-bit** | Boot code, BIOS\u002FUEFI, DOS-era reverse engineering, retro |\n| **GPU ISAs** (PTX\u002FSASS, RDNA, SPIR-V) | Mostly generated; PTX is a virtual ISA, SASS is the real one |\n| **6502, Z80, 68000** | Retro computing and demoscene, and the best teaching ISAs ever made |\n","# Assembly Programming: Fundamentals and ISAs\n\n> **Part 1 of 4** of the *Assembly Programming* reference (plugin `assembly-programming`), covering §0–§5. Sibling skills: `assembly-toolchain-performance-and-simd` (§6–§10), `assembly-systems-crypto-and-inline` (§11–§14), `assembly-reference` (§15–§20). Section numbers are shared across the set; a reference written as §N → `skill` points into that sibling skill.\n>\n> **Currency:** Verified August 2026. See §17 → `assembly-reference` for the currency snapshot and what goes stale first.\n\n> **How to read this.** Reference, not tutorial. Sections are independent. Three markers:\n> - **[DURABLE]** — machine organization, algorithms, or a lesson that has held since the\n>   1970s. Does not expire.\n> - **[ISA]** — specific to x86-64, AArch64, RISC-V, or a particular microarchitecture.\n>   Verify against the vendor's current manual.\n> - **[CONTESTED]** — practitioners genuinely disagree, usually about how much hand-written\n>   assembly is justified.\n>\n> **⚠️ GOTCHA** boxes mark the mistakes that produce silent corruption, ABI violations,\n> or code that is slower than the C you replaced.\n>\n> **The three framings that organize everything below:**\n> 1. **The instruction set is an interface, not the machine.** The CPU you're actually\n>    programming is out-of-order, superscalar, speculative, and cached. Your instructions\n>    are decoded into µops, reordered, and executed in parallel. Reasoning about assembly\n>    as \"the CPU does this, then this\" is wrong in ways that make your optimizations wrong.\n> 2. **Reading assembly is a hundred times more common than writing it, and more\n>    valuable.** Most of the return here comes from understanding compiler output,\n>    debugging an optimized crash, or reverse-engineering a binary.\n> 3. **When you write assembly, you are taking on the compiler's job permanently.** No\n>    retargeting, no auto-vectorization, no new-CPU tuning, and no help from the next\n>    twenty years of compiler improvements. That's the real cost, and it's paid in\n>    maintenance rather than in the initial write.\n\n---\n\n## §0. Routing\n\n### 0.1 Should you write assembly at all?\n\n**[DURABLE] For almost all code, no.** Modern compilers beat hand-written assembly on\nanything but small, carefully-chosen kernels — and they retarget for free. The legitimate\nreasons, in rough order of how often they're actually valid:\n\n| Reason | Notes |\n|---|---|\n| **Reading compiler output** | The dominant use. Not writing at all |\n| **Debugging optimized code \u002F crash dumps** | You have no choice; the source is a fiction at `-O2` |\n| **Reverse engineering, malware analysis, security research** | Reading, again |\n| **Instructions the compiler won't emit** | Crypto (AES-NI, SHA, carry-less multiply), CRC, special atomics, cache control, hardware-specific instructions |\n| **Constant-time cryptography** | §12 → `assembly-systems-crypto-and-inline` — the compiler is actively hostile to your requirements here |\n| **Boot code, context switches, interrupt vectors, syscall stubs** | §11 → `assembly-systems-crypto-and-inline` — there is no C for \"set up the stack before there is a stack\" |\n| **Hot kernels after profiling and after intrinsics** | Codecs, BLAS, hashing, parsers. And use **intrinsics first** |\n| **Extremely constrained targets** | Tiny MCUs, boot ROMs, size-limited firmware |\n| **Compiler bugs \u002F missing optimizations** | Real, but verify before assuming |\n| **Learning how machines work** | The best reason of all, and it doesn't need to ship |\n\n**[DURABLE] The ladder, and take it in order:**\n```\n1. Better algorithm                      ← usually the whole answer\n2. Better data layout \u002F memory access    ← usually the rest of it\n3. Compiler flags, PGO, LTO\n4. Restructure C\u002FC++\u002FRust so the compiler can vectorize\n5. Compiler INTRINSICS                   ← 95% of the benefit, register allocation for free\n6. Inline assembly for a specific instruction\n7. Hand-written assembly functions\n8. Hand-written assembly with microarchitectural scheduling\n```\n**Steps 5 and 7 are separated by a large maintenance cliff.** Intrinsics keep the\ncompiler's register allocation, scheduling, and inlining; hand-written assembly does not.\n\n### 0.2 The question router\n\n| Asked about... | Go to |\n|---|---|\n| Machine model: registers, memory, flags, endianness | §1 |\n| x86-64 specifically | §2 |\n| AArch64 \u002F ARM64 specifically | §3 |\n| RISC-V specifically | §4 |\n| Other ISAs (embedded, GPU, historical) | §5 |\n| Calling conventions and ABIs | §6 → `assembly-toolchain-performance-and-simd` |\n| Assemblers, syntax, toolchain, linking | §7 → `assembly-toolchain-performance-and-simd` |\n| Reading disassembly and compiler output | §8 → `assembly-toolchain-performance-and-simd` |\n| Performance: pipelines, latency, caches, branches | §9 → `assembly-toolchain-performance-and-simd` |\n| SIMD and vector programming | §10 → `assembly-toolchain-performance-and-simd` |\n| Systems assembly: interrupts, context switch, boot | §11 → `assembly-systems-crypto-and-inline` |\n| Cryptographic and constant-time assembly | §12 → `assembly-systems-crypto-and-inline` |\n| Inline assembly and intrinsics | §13 → `assembly-systems-crypto-and-inline` |\n| Debugging, testing, verification | §14 → `assembly-systems-crypto-and-inline` |\n| \"Don't do this\" | §15 → `assembly-reference` |\n| \"Which approach is better?\" | §16 → `assembly-reference` (contested) |\n| \"Is this still current?\" | §17 → `assembly-reference` |\n| Books, manuals, people | §18 → `assembly-reference` |\n\n---\n\n## §1. The Machine Model\n\n### 1.1 What's actually there\n\n```\n┌──────────────────────────────────────────────────────────────┐\n│ ARCHITECTURAL STATE (what the ISA promises)                  │\n│   general-purpose registers · SIMD\u002Fvector registers          │\n│   program counter · flags\u002Fcondition codes · stack pointer    │\n│   control\u002Fsystem registers · memory (virtual address space)  │\n└──────────────────────────────────────────────────────────────┘\n                    ↕  (the ISA is a CONTRACT, not a description)\n┌──────────────────────────────────────────────────────────────┐\n│ MICROARCHITECTURE (what actually happens)                    │\n│   fetch → decode → µop cache → RENAME (physical regs ≫ arch) │\n│   → scheduler\u002Freservation stations → OUT-OF-ORDER EXECUTION  │\n│   across multiple ports → load\u002Fstore buffers → RETIRE in     │\n│   order · branch predictors · L1\u002FL2\u002FL3 caches · TLBs ·       │\n│   prefetchers · store-to-load forwarding · speculation       │\n└──────────────────────────────────────────────────────────────┘\n```\n\n**[DURABLE] Register renaming is why most naive assembly intuitions fail.** The CPU has\nfar more physical registers than architectural ones and renames on the fly, so\n**write-after-write and write-after-read \"dependencies\" are free** — only true\nread-after-write data dependencies cost you. This is why `xor eax, eax` is faster than\n`mov eax, 0` (it's recognized as a zeroing idiom and breaks the dependency chain), and why\n\"reusing a register to save registers\" can be actively harmful.\n\n**[DURABLE] The three things that actually determine speed** (§9 → `assembly-toolchain-performance-and-simd`): the **critical path\nthrough the dependency graph**, **memory access patterns**, and **branch predictability**.\nInstruction *count* is a distant fourth and is the thing beginners optimize.\n\n### 1.2 Registers\n\n| Class | Purpose |\n|---|---|\n| General-purpose | Integers, addresses. x86-64: 16 (32 with APX); AArch64: 31 + zero register; RISC-V: 32 (x0 hardwired to zero) |\n| SIMD\u002Fvector | Packed data. §10 → `assembly-toolchain-performance-and-simd` |\n| Floating-point | Separate on some ISAs, shared with SIMD on others |\n| Flags\u002Fcondition | x86 EFLAGS, ARM NZCV. **RISC-V has none** — a deliberate design choice |\n| Special | PC\u002FIP, SP, link register, TLS base, system\u002Fcontrol registers |\n\n**[DURABLE] A zero register is a surprisingly large ISA win.** AArch64's `xzr`\u002F`wzr` and\nRISC-V's `x0` let one instruction encoding serve many purposes: `add rd, rs, x0` is a move,\n`beq rs, x0, label` is branch-if-zero, storing `xzr` is a memset. x86 has no zero register\nand needs distinct encodings for all of it.\n\n### 1.3 Addressing modes\n\n```\nx86-64:   [base + index*scale + disp]        scale ∈ {1,2,4,8}   — very expressive\n          mov rax, [rbx + rcx*8 + 16]\nAArch64:  [base], [base, #imm], [base, Xn{, LSL #s}], pre\u002Fpost-index\n          ldr x0, [x1, #16]!        pre-index:  x1 += 16, then load\n          ldr x0, [x1], #16         post-index: load, then x1 += 16\nRISC-V:   [base + imm12]  ONLY                                   — deliberately minimal\n          ld  a0, 16(a1)\n```\n**[DURABLE] This is the clearest illustration of the CISC\u002FRISC trade-off that survives\ninto 2026.** x86's addressing modes fold address arithmetic into the load for free —\nbut they're one reason x86 decoding is hard. RISC-V's single mode means indexed access\ncosts an extra `add`, which the designers judged a fair price for decode simplicity.\nNeither is wrong; they optimize different things.\n\n### 1.4 Endianness, alignment, and memory ordering\n\n- **Endianness**: x86-64, AArch64 (in practice), and RISC-V are all **little-endian**\n  today. Big-endian survives in network byte order, some MIPS\u002FPowerPC\u002FSPARC deployments,\n  and file formats. **Byte-swap instructions exist**: `bswap`\u002F`movbe` (x86), `rev` (ARM),\n  `rev8` (RISC-V Zbb).\n- **Alignment**: x86-64 tolerates unaligned scalar access with a small penalty (and\n  *requires* alignment for some SIMD instructions and all atomics that must not split a\n  cache line). ARM and RISC-V vary — unaligned may fault, may trap-and-emulate slowly, or\n  may work fine. **⚠️ A split-cache-line access is dramatically slower everywhere, and a\n  split-page access worse still.**\n- **Memory ordering [DURABLE, and the most dangerous area in multicore assembly]:**\n\n| ISA | Model |\n|---|---|\n| **x86-64** | **TSO** (total store order) — strong. Only store→load can reorder. `mfence`\u002F`lock`-prefixed ops for the rest |\n| **AArch64** | **Weak**, with acquire\u002Frelease built into instructions: `ldar`\u002F`stlr`, plus `dmb`\u002F`dsb`\u002F`isb` barriers |\n| **RISC-V** | **Weak** (RVWMO), with `fence` and `.aq`\u002F`.rl` suffixes on atomics |\n| **POWER** | Weak, notoriously so |\n\n> **⚠️ GOTCHA — x86's strong ordering hides bugs that ARM and RISC-V expose.** Concurrent\n> code developed and tested only on x86 routinely breaks on AArch64, because the missing\n> barrier never mattered before. This is one of the most common real-world porting\n> failures, and it produces rare, load-dependent corruption rather than a clean crash.\n\n---\n\n## §2. x86-64\n\n### 2.1 The register file\n\n```\n64-bit   32-bit  16-bit  8-bit    Conventional role (System V AMD64)\nrax      eax     ax      al\u002Fah    return value; implicit in mul\u002Fdiv\nrbx      ebx     bx      bl       callee-saved\nrcx      ecx     cx      cl       4th arg; implicit shift count\nrdx      edx     dx      dl       3rd arg; high half of mul\u002Fdiv\nrsi      esi     si      sil      2nd arg; string source\nrdi      edi     di      dil      1st arg; string destination\nrbp      ebp     bp      bpl      frame pointer (callee-saved)\nrsp      esp     sp      spl      STACK POINTER — never clobber\nr8–r15                            r8\u002Fr9 = 5th\u002F6th args; r12–r15 callee-saved\nxmm0–15 \u002F ymm0–15 \u002F zmm0–31       SIMD (§10)\nrip                               instruction pointer (RIP-relative addressing)\n```\n\n> **⚠️ GOTCHA — the 32-bit zero-extension rule.** Writing to a 32-bit register\n> **zero-extends into the full 64-bit register**; writing to a 16- or 8-bit register does\n> **not** (it merges, creating a **partial-register dependency stall**). So `mov eax, 1`\n> clears the upper 32 bits of `rax` — deliberately, and usefully, because it's a shorter\n> encoding — while `mov ax, 1` leaves the top 48 bits and creates a false dependency.\n> **Prefer 32-bit operations when the value fits**: shorter encoding, and free zeroing.\n\n### 2.2 The instruction set, honestly\n\nx86-64 is **variable-length** (1–15 bytes), **two-operand destructive** (`add rax, rbx`\nmeans `rax += rbx` — APX changes this, §17 → `assembly-reference`), and enormous. Practical groupings:\n\n- **Data movement**: `mov`, `movzx`\u002F`movsx` (zero\u002Fsign extend), `lea`, `push`\u002F`pop`,\n  `xchg`, `cmov`.\n- **`lea` is the workhorse.** It computes an address without accessing memory, so it's a\n  free three-operand add-and-shift: `lea rax, [rbx + rcx*4 + 8]`. Compilers use it\n  constantly for arithmetic that has nothing to do with addresses.\n- **Arithmetic\u002Flogic**: `add`\u002F`adc`, `sub`\u002F`sbb`, `imul`\u002F`mul`, `idiv`\u002F`div`\n  (**very slow — 20–100 cycles; strength-reduce it**), `and`\u002F`or`\u002F`xor`\u002F`not`, shifts,\n  `bt`\u002F`bts`\u002F`btr`.\n- **BMI1\u002FBMI2**: `andn`, `bextr`, `blsi`, `tzcnt`, `lzcnt`, `popcnt`, `pdep`\u002F`pext`\n  (**note: `pdep`\u002F`pext` are microcoded and glacial on pre-Zen 3 AMD** — a classic\n  portability-of-performance trap).\n- **Control**: `jmp`, `jcc`, `call`\u002F`ret`, `loop` (**don't** — slower than the equivalent\n  `dec`\u002F`jnz` on modern parts).\n- **`cmov`** — conditional move, no branch. Essential for §12 → `assembly-systems-crypto-and-inline`, and a good idea whenever a\n  branch is unpredictable.\n- **Atomics**: `lock`-prefixed RMW, `cmpxchg`, `cmpxchg16b`, `xadd`.\n- **Crypto**: AES-NI (`aesenc`…), SHA extensions, `pclmulqdq` (carry-less multiply — the\n  basis of fast GCM and CRC).\n\n### 2.3 Idioms you'll see in every compiler's output\n\n```asm\nxor  eax, eax        ; rax = 0. Shorter than mov, and BREAKS the dependency chain\ntest rax, rax        ; set flags from rax without a compare-with-zero\nlea  rax, [rbx+rbx*2]; rax = rbx*3, no multiplier, no flags touched\nsete al              ; materialize a condition as 0\u002F1 without branching\ncdq \u002F cqo            ; sign-extend eax→edx:eax before idiv  (forgetting this is a classic bug)\nendbr64              ; CET indirect-branch landing pad — required at indirect targets\n```\n\n### 2.4 The x86 tax\n\n**[DURABLE]** Variable-length decoding is genuinely expensive, which is why modern x86\ncores have **µop caches** to bypass the decoder on hot loops. Practical consequences:\n- **Code density matters more than instruction count** on x86 — fitting a loop in the µop\n  cache or in fewer 32-byte fetch windows is a real optimization.\n- **Alignment of branch targets** to 16 or 32 bytes can matter.\n- The **legacy modes** (real, protected, long) and the accumulated 40 years of encodings\n  are the reason a full x86 assembler is a large program.\n\n---\n\n## §3. AArch64 (ARM64)\n\n### 3.1 The register file\n\n```\nx0–x30    64-bit GPRs;  w0–w30 are the 32-bit views (writing wN zero-extends to xN)\n  x0–x7   arguments and return values\n  x8      indirect result location \u002F Linux syscall number\n  x9–x15  caller-saved (temporary)\n  x16,x17 IP0\u002FIP1 — intra-procedure-call scratch, may be clobbered by the LINKER's veneers\n  x18     PLATFORM REGISTER — reserved on some OSes (⚠️ Darwin, Windows). Don't touch\n  x19–x28 callee-saved\n  x29     FP (frame pointer)\n  x30     LR (link register — the return address)\nsp        stack pointer  (⚠️ MUST be 16-byte aligned at any public interface)\nxzr\u002Fwzr   the ZERO REGISTER (reads 0, writes discarded) — encoding 31, context-dependent with sp\npc        not directly writable\nv0–v31    128-bit SIMD (NEON), also used as scalar FP (s\u002Fd\u002Fh views)\nz0–z31    SVE scalable vectors; p0–p15 predicates (§10)\n```\n\n### 3.2 The character of the ISA\n\n**Fixed 32-bit instructions**, load\u002Fstore architecture (**arithmetic never touches memory**),\nmostly three-operand and non-destructive, and a genuinely clean encoding.\n\n```asm\n; the canonical prologue\u002Fepilogue\nstp  x29, x30, [sp, #-16]!   ; push FP and LR, pre-decrement sp\nmov  x29, sp\n; ...\nldp  x29, x30, [sp], #16     ; pop, post-increment\nret                          ; branch to x30\n\n; conditional execution without branches\ncmp   x0, x1\ncsel  x2, x3, x4, lt         ; x2 = (x0 \u003C x1) ? x3 : x4    ← constant-time friendly\ncinc  x2, x2, ne             ; conditional increment\ncbz   x0, label              ; compare-and-branch-if-zero: one instruction, no flags\ntbz   x0, #3, label          ; test-bit-and-branch\n\n; loading a 64-bit constant takes up to four instructions\nmovz x0, #0x1234, lsl #48\nmovk x0, #0x5678, lsl #32    ; movk = move-keep (doesn't clear other bits)\n; ...or, far more often:\nadrp x0, symbol              ; PC-relative page address (±4 GB)\nadd  x0, x0, :lo12:symbol    ; plus the low 12 bits\n```\n\n**[DURABLE] The `adrp`\u002F`add` pair is the single most characteristic AArch64 idiom** and\nthe thing that confuses people coming from x86's RIP-relative addressing. AArch64 can't\nencode a 64-bit address in a 32-bit instruction, so PC-relative addressing is split into\na 4 KB-page-granular part and a 12-bit offset.\n\n**Pointer authentication (PAC) and BTI** — Armv8.3+\u002F8.5+ security features you'll see in\nmodern compiler output: `paciasp`\u002F`autiasp` sign and authenticate the return address in\nthe prologue\u002Fepilogue (defeating ROP), and `bti c` marks legal indirect-branch targets.\n**Don't strip these**; on Apple platforms they're mandatory.\n\n**Atomics**: the classic **LL\u002FSC** pair `ldxr`\u002F`stxr` (load-exclusive \u002F store-exclusive,\nwith a retry loop), plus the much better **LSE** atomics from Armv8.1 (`ldadd`, `swp`,\n`cas`) which are single instructions and scale far better under contention.\n\n---\n\n## §4. RISC-V\n\n### 4.1 The design philosophy, and why it matters to you\n\n**[DURABLE] RISC-V is a small base plus modular extensions**, which makes it the easiest\nmajor ISA to learn and the most annoying to target portably.\n\n```\nRV32I \u002F RV64I   base integer (I = 32 registers; E = 16, for embedded)\nM  multiply\u002Fdivide      A  atomics          F\u002FD\u002FQ  float (single\u002Fdouble\u002Fquad)\nC  compressed (16-bit)  V  vector (§10)     B  bit manipulation (Zba\u002FZbb\u002FZbs)\nZicsr control regs      Zifencei            Zk*  scalar crypto     Zvk*  vector crypto\n```\nThe shorthand: **RV64GC** = IMAFD + Zicsr + Zifencei + C, the general-purpose target.\n\n```\nx0\u002Fzero  hardwired zero     x1\u002Fra  return address     x2\u002Fsp  stack pointer\nx3\u002Fgp    global pointer     x4\u002Ftp  thread pointer     x5–7\u002Ft0–2  temporaries\nx8\u002Fs0\u002Ffp saved \u002F frame ptr  x9\u002Fs1  saved\nx10–17\u002Fa0–a7  arguments and return values      x18–27\u002Fs2–11  saved\nx28–31\u002Ft3–6   temporaries\n```\n\n**Notably absent: condition flags.** Comparison and branch are fused into one instruction\n(`beq`, `bne`, `blt`, `bge`, `bltu`, `bgeu`), and `slt`\u002F`sltu` materialize a comparison as\n0\u002F1. This removes a serialization point and a rename hazard that x86 and ARM both carry.\n\n```asm\naddi sp, sp, -16\nsd   ra, 8(sp)\nsd   s0, 0(sp)\n# ...\nld   ra, 8(sp)\nld   s0, 0(sp)\naddi sp, sp, 16\nret                  # pseudo-instruction for: jalr x0, 0(ra)\n```\n\n**⚠️ Pseudo-instructions are pervasive and you must know they're not real**: `li`, `la`,\n`mv`, `nop`, `ret`, `call`, `j`, `beqz`, `not`, `neg`. The assembler expands each into one\nor more real instructions, and `li` with a large constant becomes `lui`+`addi`.\n\n### 4.2 Profiles — the fragmentation fix\n\n**[VERSIONED]** The extension modularity created a real portability problem, and\n**profiles** are the answer: a named set of mandatory and optional extensions that\nsoftware can target.\n\n**RVA23 was ratified 21 October 2024** and is the current 64-bit application-processor\nprofile. What matters for assembly programmers:\n- **The V (vector) extension is now MANDATORY** — it was optional in RVA22. Vectors are no\n  longer an optional accelerator; they're a baseline capability software can assume.\n- **RVA23 is the baseline requirement for the Android RISC-V ABI.**\n- Also newly mandatory in RVA23U64: **Zvfhmin** (vector half-precision), **Zvbb** (vector\n  bit manipulation), **Zvkt** (vector data-independent execution latency — see §12 → `assembly-systems-crypto-and-inline`),\n  **Zihintntl**, **Zicond** (integer conditional ops), **Zimop**\u002F**Zcmop**, **Zcb**,\n  **Zfa**, and **Supm** (pointer masking).\n- **The scalar crypto extensions Zkn and Zks are no longer options** — the stated goal is\n  for hardware and software vendors to **move to vector crypto**, since vectors are now\n  mandatory and vector crypto is substantially faster.\n- The hypervisor extension is in the S-mode profile.\n- Ratified specs are **frozen**: \"No changes are allowed… Ratified extensions are never\n  revised.\" Changes go into new extensions.\n\n---\n\n## §5. Other ISAs Worth Knowing\n\n| ISA | Where you'll meet it |\n|---|---|\n| **ARM32 \u002F Thumb-2** | Older embedded, Cortex-M. Thumb-2's mixed 16\u002F32-bit encoding is excellent for code density; **Cortex-M is Thumb-only** |\n| **AVR** | Arduino, 8-bit MCUs. Harvard architecture — separate code and data address spaces, which surprises everyone |\n| **MSP430, PIC, 8051** | Deeply embedded, still shipping in volume |\n| **POWER \u002F PowerPC** | IBM servers, older consoles. Weak memory model, big-endian heritage |\n| **MIPS** | Networking silicon, older Roku\u002Fembedded, and **every undergraduate architecture course** |\n| **SPARC** | Register windows — a genuinely different idea worth understanding |\n| **s390x** | IBM mainframe. Big-endian, and still absolutely everywhere in banking |\n| **WebAssembly** | A stack machine and a compile target, not hardware. Structured control flow, no registers |\n| **x86 16\u002F32-bit** | Boot code, BIOS\u002FUEFI, DOS-era reverse engineering, retro |\n| **GPU ISAs** (PTX\u002FSASS, RDNA, SPIR-V) | Mostly generated; PTX is a virtual ISA, SASS is the real one |\n| **6502, Z80, 68000** | Retro computing and demoscene, and the best teaching ISAs ever made |\n",{"name":5,"description":7},"develop","ae32736a1aabddabca5d2c96d665aa0ebc7d8700","src\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fassembly-programming\u002Fskills\u002Fassembly-fundamentals-and-isas",3,"https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey","https:\u002F\u002Fthe-vibey-project.github.io\u002Fvibey\u002F","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project","https:\u002F\u002Fvibewithadam.matthewsteinberger.com","freedom for software engineers","2026-11-15 05:47:42",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add the-vibey-project\u002Fvibey --skill assembly-fundamentals-and-isas",{"tool":40,"command":41},"bunx","bunx skills add the-vibey-project\u002Fvibey --skill assembly-fundamentals-and-isas",{"tool":43,"command":44},"pnpm","pnpm dlx skills add the-vibey-project\u002Fvibey --skill assembly-fundamentals-and-isas","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fassembly-programming\u002Fskills\u002Fassembly-fundamentals-and-isas\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7AT1FQJAE1FQYAMDTF490Y4","white-paper-writing","Use when writing white papers, technical reports, policy documents, thought leadership pieces, or any long-form authoritative document. Triggers on requests to write, structure, outline, or review white papers, technical reports, position papers, policy briefs, or evidence-driven arguments. Also use for B2B content marketing strategy, technical documentation requiring authority, academic-style reports, or any document that must educate while persuading. Use when someone asks \"how should I structure this\" for a long-form document.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fwhite-paper-writing\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7AT16BJRJJKK2MASXRZS76G","prose-technical-mechanics","Use when editing or writing prose at a technical\u002Fmechanical level: choosing between Anglo-Saxon and Latinate diction, placing information in topic vs stress positions, writing periodic vs cumulative sentences, handling sentence rhythm, punctuation as logic, transitions, paragraph structure, or phonesthetics. Use when someone wants to understand WHY prose works or doesn't, not just surface-level style advice. Triggers on word choice, sentence structure, emphasis, rhythm, diction, or any deep writing mechanics question.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fprose-technical-mechanics\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7AT0W9HT0ZZ9Y287NW99MR3","prose-mechanics","Use when writing, editing, or analyzing prose style; when trying to avoid generic AI-sounding writing; when applying specific prose styles such as journalistic, academic, narrative, KJV biblical, Hemingway plain, Latinate\u002FJamesian, Orwellian, Augustan, Victorian, Early Modern (Bacon, Browne, Milton), or free indirect discourse; or when coaching someone on writing voice and mechanics. Triggers on any request to improve, analyze, or write in a specific prose style, to fix \"AI-sounding\" writing, to make prose more vivid or concrete, to vary sentence rhythm, or to understand how a particular writer achieves their effects.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fprose-mechanics\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7AT0KR635JX66X2X6F3E2CP","narrative-structure","Use when structuring stories, pitches, presentations, white papers, or any persuasive narrative; analyzing the hero's journey in fiction or non-fiction; applying StoryBrand for business communication; designing narrative arcs for thought leadership; or understanding Vogler, Snyder, Propp, or Campbell frameworks. Triggers on any narrative structure, storytelling, pitch structure, StoryBrand, hero's journey, three-act structure, Freytag, Save the Cat, narrative arc, or \"how should I structure this story\u002Fpitch\u002Fpresentation\" request.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fnarrative-structure\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7AT0AKGW09NKKZDYBT8VRDE","legal-brief-writing","Use when writing legal briefs, motions, or any court filing; when analyzing judicial cognition and persuasion; when applying elite brief-writing techniques from Roberts, Clement, Kagan, Garner; or when structuring legal arguments for maximum persuasion. Also use for autistic\u002Fneurodivergent advocates who need to understand how their natural communication style maps to elite legal advocacy. Triggers on any legal writing, brief drafting, motion preparation, or legal argument structuring request.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Flegal-brief-writing\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7AT00VWPS4Q8B5VEMXX9NQT","journal-publishability-criteria","Use whenever a research paper, article or preprint is being written, revised, reviewed or published, and specifically before every publication of docs\u002Fpaper.md. Covers what legitimate journals actually gate on, in order of gating — the editor's desk screen (scope, novelty, package problems), what reviewers judge (methodological soundness, claims the evidence can carry, statistical and qualitative reporting), EQUATOR reporting guidelines, the ICMJE authorship criteria, COPE's view of text recycling, the near-universal generative-AI policy (no AI author, disclosure, author responsibility), TOP 2025 transparency standards, how to verify a journal is legitimate, submitting without an institution, and a pre-submission checklist. Triggers on requests to evaluate, review, prepare or submit a paper, to judge publishability, to write a declarations or data-availability section, to disclose AI use, or to check a journal.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fjournal-publishability-criteria\u002FSKILL.md",[],[]]