/assembly-programming:assembly-systems-crypto-and-inlinefrom assembly-programming
Provides guidance on writing systems-level assembly (interrupt handlers, context switches, boot code), cryptographic constant-time assembly, inline assembly with GCC/Clang extended asm constraints, and debugging hand-written assembly with GDB and sanitizers.
Ships in assembly-programming. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Part 3 of 4 of the Assembly Programming reference (plugin
assembly-programming), covering §11–§14. Sibling skills:assembly-fundamentals-and-isas(§0–§5),assembly-toolchain-performance-and-simd(§6–§10),assembly-reference(§15–§20). Section numbers are shared across the set; a reference written as §N →skillpoints into that sibling skill.Currency: Verified August 2026. See §17 →
assembly-referencefor the currency snapshot and what goes stale first.
How to read this. Reference, not tutorial. Sections are independent. Three markers:
- [DURABLE] — machine organization, algorithms, or a lesson that has held since the 1970s. Does not expire.
- [ISA] — specific to x86-64, AArch64, RISC-V, or a particular microarchitecture. Verify against the vendor's current manual.
- [CONTESTED] — practitioners genuinely disagree, usually about how much hand-written assembly is justified.
⚠️ GOTCHA boxes mark the mistakes that produce silent corruption, ABI violations, or code that is slower than the C you replaced.
The three framings that organize everything below:
- The instruction set is an interface, not the machine. The CPU you're actually programming is out-of-order, superscalar, speculative, and cached. Your instructions are decoded into µops, reordered, and executed in parallel. Reasoning about assembly as "the CPU does this, then this" is wrong in ways that make your optimizations wrong.
- Reading assembly is a hundred times more common than writing it, and more valuable. Most of the return here comes from understanding compiler output, debugging an optimized crash, or reverse-engineering a binary.
- When you write assembly, you are taking on the compiler's job permanently. No retargeting, no auto-vectorization, no new-CPU tuning, and no help from the next twenty years of compiler improvements. That's the real cost, and it's paid in maintenance rather than in the initial write.
[DURABLE] Some things simply cannot be written in a high-level language, and this is where assembly is unavoidable rather than merely faster:
iret, eret, mret).setjmp/longjmp, coroutines, stack switching, unwinding.clflush, wbinvd, dc civac, tlbi, sfence.vma) and
memory barriers.; Linux x86-64 syscall (write(1, msg, len))
mov rax, 1 ; syscall number
mov rdi, 1 ; fd
mov rsi, msg
mov rdx, len
syscall ; ⚠️ CLOBBERS rcx and r11 — the ABI differs from a function call
⚠️ GOTCHA — the syscall ABI is not the function-call ABI. On x86-64 Linux, the 4th argument is
r10, notrcx(becausesyscalldestroysrcx), andrcxandr11are clobbered. On AArch64 the number goes inx8and the instruction issvc #0. Getting this wrong produces bafflingly wrong syscall behaviour.
JIT-specific concerns: W^X (never map memory writable and executable
simultaneously — use dual mapping or mprotect transitions; macOS on Apple Silicon
requires pthread_jit_write_protect_np), and instruction-cache invalidation — on
ARM and RISC-V, writing bytes is not enough; you must flush D-cache to the point of unity
and invalidate I-cache (dc cvau / ic ivau / isb, or fence.i). x86 has coherent
I-cache and doesn't need this, which is exactly why JIT code that works on x86 breaks
mysteriously when ported.
[DURABLE] This is the strongest remaining justification for hand-written assembly, and the reason is that the compiler is actively working against you. An optimizing compiler is free to turn your carefully branchless code back into a branch, and there is no standard way in C to say "don't."
Tools: cmov/csel (§2.3 → assembly-fundamentals-and-isas, §3.2 → assembly-fundamentals-and-isas), masking (mask = -(cond & 1) then
r = (a & mask) | (b & ~mask)), and constant-time comparison that accumulates differences
with OR rather than returning early.
[VERSIONED, and this is genuinely important and under-known.] For decades rule 3 rested on documentation and microbenchmarks with no guarantee for future microarchitectures. That changed with explicit vendor contracts:
PSTATE.DIT, since Armv8.4) — when set, the architecture requires that the
timing of instructions in the DIT subset is insensitive to the data values in their
registers, and that load/store timing is insensitive to the data being loaded or stored.IA32_UARCH_MISC_CTL bit 0, "data operand independent timing") — the
same idea for a documented instruction subset. Intel explicitly does not recommend
enabling it globally because of the performance cost; it's meant to be enabled only for
code already written to be constant-time.Zkt (scalar) and Zvkt (vector) attest
that their instruction subsets have data-independent execution latency — and Zvkt is
mandatory in RVA23.The part that catches people out: on Intel, the guarantees held by default only for
microarchitectures earlier than Ice Lake (Core) and Gracemont (Atom). On Ice Lake,
Gracemont, and later, they are not provided by default and must be explicitly enabled
via DOIT. Meanwhile the DOIT bit is an MSR — kernel-only, whereas Arm's DIT is a cheap
unprivileged msr a user-space program can set itself. Linux enabled DIT for arm64 in
v6.2 but only in the kernel, leaving user space to opt in.
⚠️ GOTCHA — read Arm's DIT guarantee precisely. It requires timing to be independent of the registers the instruction explicitly uses. Researchers have pointed out it does not obviously cover values in registers the instruction doesn't reference, and it makes no statement about data memory-dependent prefetchers (DMPs) — the mechanism behind attacks like GoFetch. Intel's DOIT, by contrast, explicitly does cover data-dependent prefetchers. These are not equivalent guarantees, and the difference matters for real attacks.
The state of the art is moving toward verified rather than merely careful:
Jasmin (a language and verification framework for high-assurance crypto, extended to
prove that only DOIT-subset instructions touch secret data — including under speculative
execution), Serberus, Vale, and formally-verified libraries like
HACL* and fiat-crypto. [VERSIONED] LLVM is also gaining constant-time
intrinsics (lowering to CSEL on AArch64, masked arithmetic where no constant-time
instruction exists), which maintainers of Rust Crypto, BearSSL, and PuTTY have expressed
interest in adopting to replace their current inline-assembly workarounds — which, if
it lands broadly, removes one of assembly's last unavoidable use cases.
Also use the hardware crypto instructions: AES-NI, ARMv8 Crypto Extensions, RISC-V Zvk*. They are faster and constant-time by construction, which is the rare case where the fast path and the safe path coincide.
[DURABLE] Intrinsics give you the specific instruction while keeping register allocation, scheduling, inlining, and constant propagation. Inline assembly gives up all of that and requires you to describe your effects to the compiler correctly — which is where the bugs are.
__asm__ volatile (
"addq %[b], %[a]" // template
: [a] "+r" (x) // outputs: "+" = read-write
: [b] "r" (y) // inputs
: "cc", "memory" // CLOBBERS — the part people get wrong
);
The constraint letters that matter: r (any GPR), m (memory), i (immediate),
= (write-only output), + (read-write), & (early-clobber — written before all
inputs are consumed).
⚠️ GOTCHA — the four inline-asm failure modes, in order of how much time they waste:
- Missing
"memory"clobber when the asm reads or writes memory the compiler thinks it knows about → the compiler caches a stale value in a register, and the bug appears only at-O2.- Missing
"cc"clobber when you modify flags → the compiler reuses flags it thought were still valid.- Missing
&early-clobber → the compiler assigns an output and an input to the same register, and your asm overwrites the input before reading it.- Missing
volatileon asm with side effects but no used output → the compiler deletes it, or hoists it out of a loop.All four produce code that works at
-O0and fails at-O2, which is the worst possible debugging experience.
MSVC has no inline assembly for x64 — you use intrinsics or a separate .asm file
assembled by MASM. This is a real portability constraint on cross-platform projects.
Naked functions / separate .s files are cleaner than large inline blocks: you get
full control, real assembler syntax, proper CFI, and the code is testable and profilable.
Debugging: gdb/lldb with layout asm / si / info registers / x/i $pc;
disassemble /s to interleave source; hardware watchpoints; rr for reverse debugging
(x86 Linux — transformative for "how did this register get that value"); Intel PT / Arm
CoreSight for execution traces; and single-stepping is the ultimate ground truth.
Testing hand-written assembly:
assembly-fundamentals-and-isas).Formal verification is real in this niche: Alive2 for peephole correctness, Vale and Jasmin for verified crypto assembly, HACL* and fiat-crypto for verified implementations that generate the assembly. If you're writing crypto assembly by hand in 2026 without a verification story, consider whether you should be.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub the-vibey-project/vibey --plugin assembly-programming4 skills in this plugin
/assembly-fundamentals-and-isasUse 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/ARM64, RISC-V (design philosophy, profiles and fragmentation), and other ISAs worth knowing. Includes the router for the whole assembly-programming reference./assembly-referenceUse when reviewing assembly for known anti-patterns, weighing contested questions (hand-written asm vs compilers, CISC vs RISC, fixed-width SIMD vs scalable vectors, AVX-512's design, whether and which ISA to learn first), checking whether an ISA or microarchitecture claim is still current (snapshot verified August 2026), finding the authoritative vendor manuals, performance references, books, and people, or needing the quick-reference numbers, first moves, and hand-written-assembly review checklist. Companion to the other assembly-programming skills./assembly-toolchain-performance-and-simdUse when wiring assembly to C (calling conventions and ABIs: System V, Windows x64, AAPCS64, RISC-V), choosing or fighting an assembler (GAS vs NASM, AT&T vs Intel syntax, linkers, objdump), reading disassembly and recognizing compiler patterns, or optimizing at the instruction level. Covers the out-of-order/superscalar mental model, latency vs throughput, caches and memory, branch prediction, alignment, and SIMD/vector programming — SSE/AVX/AVX-512/AVX10, NEON/SVE2/SME, RISC-V RVV — and how to write SIMD well.