
Assembly X86
- 383 installs
- 155 repo stars
- Updated June 27, 2026
- mohitmishra786/low-level-dev-skills
assembly-x86 is a Claude Code agent skill that teaches x86-64 assembly reading, writing, and debugging with System V AMD64 ABI conventions for developers optimizing performance-critical C, C++, or Rust routines.
About
assembly-x86 is a low-level-dev-skills agent skill for x86-64 assembly from the mohitmishra786 toolchain suite. The skill documents System V AMD64 ABI register roles across rdi, rsi, rdx, rcx, r8, r9 argument slots, xmm0–xmm7 SIMD args, callee-saved rbx/rbp/r12–r15, and the 128-byte red zone. Developers reach for assembly-x86 when reading GCC -S output in AT&T or Intel syntax, writing inline asm in C/C++, debugging rsp/rbp stack frames in GDB, or applying SSE, AVX, and AVX-512 intrinsics in hot paths.
- Covers x86 instruction patterns and register usage
- Explains ABI, stacks, and calling conventions
- Supports debugging and optimizing tight native loops
- Bridges high-level code with machine-level behavior
Assembly X86 by the numbers
- 383 all-time installs (skills.sh)
- +26 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #115 of 782 Skill Development skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill assembly-x86Add your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 383 |
|---|---|
| repo stars | ★ 155 |
| Last updated | June 27, 2026 |
| Repository | mohitmishra786/low-level-dev-skills ↗ |
How do you read x86-64 GCC assembly output?
Write, read, and debug x86 assembly for performance-critical routines, ABI-compliant calls, and low-level systems work when higher-level languages are insufficient.
Who is it for?
Systems programmers debugging x86-64 disassembly, writing inline asm in C/C++/Rust, or optimizing hot paths with SIMD intrinsics on Linux or macOS.
Skip if: Developers building standard web frontends or managed-language services without compiler assembly output or register-level debugging needs.
When should I use this skill?
A user asks about x86-64 registers, System V AMD64 calling convention, AT&T vs Intel syntax, or reading disassembly from objdump or GDB.
What you get
Correct x86-64 assembly with System V AMD64 ABI register usage, inline asm constraints, and annotated objdump or GDB disassembly.
- ABI-compliant inline asm blocks
- Annotated AT&T or Intel disassembly
By the numbers
- Documents 6 integer argument registers plus r8 and r9 on System V AMD64
- Covers 128-byte red zone below rsp for leaf function optimization
Files
x86-64 Assembly
Purpose
Guide agents through x86-64 assembly: reading compiler output, understanding the ABI, writing inline asm, and common patterns.
Triggers
- "How do I read the assembly GCC generated?"
- "What are the x86-64 registers?"
- "What is the calling convention on Linux/macOS?"
- "How do I write inline assembly in C?"
- "How do I use SSE/AVX intrinsics?"
- "This assembly uses
%rsp/%rbp— what does it mean?"
Workflow
1. Generate and read assembly
# AT&T syntax (GCC default)
gcc -S -O2 -fverbose-asm foo.c -o foo.s
# Intel syntax
gcc -S -masm=intel -O2 foo.c -o foo.s
# From GDB
(gdb) disassemble /s main # with source
(gdb) x/20i $rip
# From objdump
objdump -d -M intel -S prog # Intel + source (needs -g)2. x86-64 registers
| 64-bit | 32-bit | 16-bit | 8-bit high | 8-bit low | Purpose |
|---|---|---|---|---|---|
%rax | %eax | %ax | %ah | %al | Return value / accumulator |
%rbx | %ebx | %bx | %bh | %bl | Callee-saved |
%rcx | %ecx | %cx | %ch | %cl | 4th arg / count |
%rdx | %edx | %dx | %dh | %dl | 3rd arg / 2nd return |
%rsi | %esi | %si | — | %sil | 2nd arg |
%rdi | %edi | %di | — | %dil | 1st arg |
%rbp | %ebp | %bp | — | %bpl | Frame pointer (callee-saved) |
%rsp | %esp | %sp | — | %spl | Stack pointer |
%r8–%r11 | %r8d–%r11d | %r8w–%r11w | — | %r8b–%r11b | 5th–8th args / caller-saved |
%r12–%r15 | %r12d–%r15d | %r12w–%r15w | — | %r12b–%r15b | Callee-saved |
%rip | Instruction pointer | ||||
%rflags | %eflags | Status flags | |||
%xmm0–%xmm7 | FP/SIMD args and return | ||||
%xmm8–%xmm15 | Caller-saved SIMD | ||||
%ymm0–%ymm15 | AVX 256-bit | ||||
%zmm0–%zmm31 | AVX-512 512-bit |
3. System V AMD64 ABI (Linux, macOS, FreeBSD)
Integer/pointer argument registers (in order): %rdi, %rsi, %rdx, %rcx, %r8, %r9
Floating-point argument registers: %xmm0–%xmm7
Return values:
- Integer:
%rax(low),%rdx(high if 128-bit) - Float:
%xmm0(low),%xmm1(high)
Caller-saved (scratch): %rax, %rcx, %rdx, %rsi, %rdi, %r8–%r11, %xmm0–%xmm15
Callee-saved (must preserve): %rbx, %rbp, %r12–%r15
Stack: 16-byte aligned before call; call pushes 8 bytes → 16-byte aligned at function entry after prologue.
Red zone: 128 bytes below %rsp may be used by leaf functions without adjusting %rsp. Not available in kernel/signal handlers.
4. Common instruction patterns
| Pattern | Meaning |
|---|---|
mov %rdi, %rax | Copy rdi to rax |
mov (%rdi), %rax | Load 8 bytes from address in rdi |
mov %rax, 8(%rdi) | Store rax to rdi+8 |
lea 8(%rdi), %rax | Load effective address rdi+8 into rax (no memory access) |
push %rbx | Push rbx; rsp -= 8 |
pop %rbx | Pop into rbx; rsp += 8 |
call foo | Push return addr; jmp foo |
ret | Pop return addr; jmp to it |
xor %eax, %eax | Zero rax (smaller encoding than mov $0, %rax) |
test %rax, %rax | Set ZF if rax == 0 (cheaper than cmp $0, %rax) |
cmp $5, %rdi | Set flags for rdi - 5 |
jl label | Jump if signed less than |
5. AT&T vs Intel syntax
| Feature | AT&T | Intel |
|---|---|---|
| Operand order | source, dest | dest, source |
| Register prefix | %rax | rax |
| Immediate prefix | $42 | 42 |
| Memory operand | 8(%rdi) | [rdi+8] |
| Size suffix | movl, movq | — (inferred) |
GCC emits AT&T by default. Use -masm=intel for Intel syntax.
6. Inline assembly (GCC extended asm)
// Basic: increment a register
int x = 5;
__asm__ volatile (
"incl %0"
: "=r"(x) // outputs: =r means write-only register
: "0"(x) // inputs: 0 means same as output 0
: // clobbers: none
);
// CPUID example
uint32_t eax, ebx, ecx, edx;
__asm__ volatile (
"cpuid"
: "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
: "a"(1) // input: leaf 1
);
// Atomic increment
static inline int atomic_inc(volatile int *p) {
int ret;
__asm__ volatile (
"lock; xaddl %0, %1"
: "=r"(ret), "+m"(*p)
: "0"(1)
: "memory"
);
return ret + 1;
}Constraint codes:
"r"— any general register"m"— memory operand"i"— immediate integer"a","b","c","d"— specific registers (%rax, %rbx, %rcx, %rdx)"="prefix — output (write-only)"+"prefix — read-write"memory"clobber — tells compiler memory may be modified (barrier)
7. SSE/AVX intrinsics (preferred over inline asm)
#include <immintrin.h> // includes all x86 SIMD headers
// Add 8 floats at once with AVX
__m256 a = _mm256_loadu_ps(arr_a); // load 8 floats (unaligned)
__m256 b = _mm256_loadu_ps(arr_b);
__m256 c = _mm256_add_ps(a, b);
_mm256_storeu_ps(result, c);Check CPU support at compile time: -mavx2 or -march=native. Check at runtime: __builtin_cpu_supports("avx2").
For a full register and instruction reference, see references/reference.md.
Related skills
- Use
skills/low-level-programming/assembly-armfor AArch64/ARM assembly - Use
skills/compilers/gccfor-S -masm=intelflag details - Use
skills/debuggers/gdbfor stepping through assembly (si,ni,x/i)
x86-64 Assembly Reference
Source: <https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html> Source: <https://gitlab.com/x86-psABIs/x86-64-ABI> (System V AMD64 ABI)
Table of Contents
1. Instruction set quick reference 2. RFLAGS bits 3. Conditional jump codes 4. SIMD header files 5. Prologue / epilogue patterns
---
Instruction set quick reference
Data movement
| Instruction | Effect |
|---|---|
mov src, dst | Copy |
movzx src, dst | Copy with zero-extend |
movsx src, dst | Copy with sign-extend |
movq xmm, r64 | Move 64-bit integer from XMM to GPR |
lea mem, dst | Load effective address (no memory access) |
push r64 | rsp -= 8; [rsp] = r64 |
pop r64 | r64 = [rsp]; rsp += 8 |
xchg src, dst | Swap (with implicit LOCK for mem operand) |
cmpxchg src, dst | Compare and swap (needs LOCK prefix) |
Arithmetic
| Instruction | Effect |
|---|---|
add src, dst | dst += src |
sub src, dst | dst -= src |
mul r/m | rdx:rax = rax * r/m (unsigned) |
imul r/m | rdx:rax = rax * r/m (signed) |
imul src, dst | dst *= src (2-operand) |
imul imm, src, dst | dst = src * imm (3-operand) |
div r/m | rax = rdx:rax / r/m; rdx = remainder |
inc dst | dst++ |
dec dst | dst-- |
neg dst | dst = -dst |
idiv r/m | Signed division |
Bit operations
| Instruction | Effect |
|---|---|
and src, dst | Bitwise AND |
or src, dst | Bitwise OR |
xor src, dst | Bitwise XOR |
not dst | Bitwise NOT |
shl/sal cnt, dst | Shift left |
shr cnt, dst | Shift right (logical) |
sar cnt, dst | Shift right (arithmetic, sign-extends) |
rol/ror cnt, dst | Rotate left/right |
bsf src, dst | Bit scan forward (index of lowest set bit) |
bsr src, dst | Bit scan reverse (index of highest set bit) |
tzcnt src, dst | Count trailing zeros |
lzcnt src, dst | Count leading zeros |
popcnt src, dst | Count set bits |
bt src, idx | Bit test |
bts/btr/btc | Bit test and set/reset/complement |
Comparison and branching
| Instruction | Effect |
|---|---|
cmp a, b | Set flags for b - a without storing result |
test a, b | Set flags for a & b without storing result |
jmp target | Unconditional jump |
jcc target | Conditional jump (see table below) |
cmovcc src, dst | Conditional move |
setcc dst | Set byte to 0 or 1 based on condition |
---
RFLAGS bits
| Flag | Name | Set when |
|---|---|---|
| CF | Carry | Unsigned overflow |
| ZF | Zero | Result is zero |
| SF | Sign | Result is negative |
| OF | Overflow | Signed overflow |
| PF | Parity | Low byte has even number of 1s |
| AF | Auxiliary carry | Carry from bit 3 to bit 4 |
| DF | Direction | Controls string instruction direction |
---
Conditional jump codes
| Instruction | Condition | Flags |
|---|---|---|
je / jz | Equal / Zero | ZF=1 |
jne / jnz | Not equal | ZF=0 |
jl / jnge | Signed less | SF≠OF |
jle / jng | Signed ≤ | ZF=1 or SF≠OF |
jg / jnle | Signed > | ZF=0 and SF=OF |
jge / jnl | Signed ≥ | SF=OF |
jb / jnae / jc | Unsigned < | CF=1 |
jbe / jna | Unsigned ≤ | CF=1 or ZF=1 |
ja / jnbe | Unsigned > | CF=0 and ZF=0 |
jae / jnb / jnc | Unsigned ≥ | CF=0 |
js | Negative | SF=1 |
jns | Non-negative | SF=0 |
jo | Overflow | OF=1 |
jno | No overflow | OF=0 |
---
SIMD header files
| Header | What it provides |
|---|---|
<xmmintrin.h> | SSE (__m128, float ops) |
<emmintrin.h> | SSE2 (int ops, double) |
<pmmintrin.h> | SSE3 |
<tmmintrin.h> | SSSE3 |
<smmintrin.h> | SSE4.1 |
<nmmintrin.h> | SSE4.2 |
<immintrin.h> | AVX, AVX2, FMA, AVX-512 (includes all above) |
<x86intrin.h> | All x86 intrinsics including BMI, ADX |
---
Prologue / epilogue patterns
With frame pointer (default at -O0, -Og)
push %rbp
mov %rsp, %rbp
sub $N, %rsp ; allocate N bytes for locals
; ... body ...
leave ; mov %rbp, %rsp; pop %rbp
retWithout frame pointer (-fomit-frame-pointer, default at -O1+)
sub $N, %rsp ; allocate locals + align stack
; ... body ...
add $N, %rsp
retSaving callee-saved registers
push %rbx
push %r12
push %r13
; ... body that uses rbx, r12, r13 ...
pop %r13
pop %r12
pop %rbx
retAlways restore in reverse push order.
Related skills
How it compares
Pick assembly-x86 over assembly-arm when debugging Linux or macOS x86-64 compiler output, SIMD intrinsics, or System V AMD64 ABI compliance.
FAQ
What calling convention does assembly-x86 document?
assembly-x86 documents the System V AMD64 ABI used on Linux, macOS, and FreeBSD. Integer arguments pass through rdi, rsi, rdx, rcx, r8, and r9, with floating-point args in xmm0–xmm7 and returns in rax or xmm0.
How does assembly-x86 switch between AT&T and Intel syntax?
assembly-x86 generates AT&T syntax with gcc -S -O2 by default and Intel syntax with gcc -S -masm=intel -O2. Disassembly uses objdump -d -M intel -S for Intel syntax with source interleaving.