Skip to main content
skill CX Codex

abi-and-calling-conventions — Claude Code skill: ABI and calling

A skill that teaches your coding agent the ABI rules: which registers carry arguments, how the stack aligns, what breaks across FFI.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mohitmishra786/low-level-dev-skills --skill abi-and-calling-conventions -a claude-code
Open on GitHub

What abi-and-calling-conventions does

The skill documents calling conventions for three architectures: System V AMD64, ARM AAPCS and RISC-V psABI. Inside are register tables for integer and float arguments, return values, callee-saved sets and stack alignment. Separate sections cover stack frame layout, variadic functions, and checking compiler output with gcc -O2 -S and objdump -d -M intel.

Reach for it when writing assembly thunks or inline asm clobbers, debugging a corrupted stack in mixed C/asm code, reading disassembly, or wiring Rust, C and Zig together through FFI. It points at neighbouring material: skills/rust/rust-ffi, skills/zig/zig-cinterop, skills/debuggers/gdb, skills/low-level-programming/assembly-x86.

A troubleshooting table maps symptoms to causes and fixes: a crash on call from a misaligned rsp, a wrong float argument when XMM and GPR get mixed up, garbage in FFI when Windows x64 and System V meet. Windows x64 follows different rules, and the skill sends you to skills/compilers/msvc-cl for those — worth checking which platform you actually build for.

What it helps with

  • work out which registers take arguments 5–8
  • fix a crash on call caused by a misaligned stack
  • find a missing clobber in inline asm
  • bridge Rust and C over FFI without garbled arguments
  • read .cfi_* directives in compiler output

Example prompts for the agent

  • /abi-and-calling-conventions which registers hold args 5–8 in AArch64 for my C function?
  • /abi-and-calling-conventions why does the call crash after my assembly thunk?
  • /abi-and-calling-conventions check the clobber list in this inline asm

How to install abi-and-calling-conventions

1Skills CLI (Vercel)

npx skills add mohitmishra786/low-level-dev-skills --skill abi-and-calling-conventions -a claude-code

2Manually: put the files in place

~/.claude/skills/abi-and-calling-conventions/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/abi-and-calling-conventions/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about abi-and-calling-conventions

How do I install abi-and-calling-conventions in Claude?

Run npx skills add mohitmishra786/low-level-dev-skills --skill abi-and-calling-conventions -a claude-code. The skill lands in ~/.claude/skills/abi-and-calling-conventions/SKILL.md.

What does abi-and-calling-conventions do?

It lays out ABI rules for System V AMD64, ARM AAPCS and RISC-V psABI: register roles, stack alignment, argument passing, return values and variadic calls.

How is Windows x64 different from System V?

The skill states plainly that Windows x64 differs and points to skills/compilers/msvc-cl for the details. Mix the two ABIs in one build and FFI hands back garbage.

Source text

SKILL.md · MIT
---
name: abi-and-calling-conventions
description: ABI and calling conventions skill for cross-language boundaries. Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Activates on queries about calling convention, ABI, System V AMD64, AAPCS, stack frame, variadic function, or FFI registers.
---

# ABI and Calling Conventions

## Purpose

Document application binary interface (ABI) rules: register roles, stack alignment, argument passing, return values, and variadic conventions across System V AMD64, ARM AAPCS, and RISC-V — essential for assembly, FFI, and debugging.

## When to Use

- Writing assembly thunks or inline asm clobbers
- Debugging corrupted stack in mixed C/asm
- FFI between Rust/C/Zig (`skills/rust/rust-ffi`, `skills/zig/zig-cinterop`)
- Reading disassembly from `skills/debuggers/gdb`

## Workflow

### 1. System V AMD64 (Linux/macOS)

| Item | Rule |
|------|------|
| Integer args | `rdi, rsi, rdx, rcx, r8, r9` |
| XMM args | `xmm0`–`xmm7` (float) |
| Return int/ptr | `rax` (+ `rdx` for 128-bit) |
| Stack alignment | 16-byte before `call` |
| Red zone | 128 bytes below `rsp` (Linux) |
| Callee-saved | `rbx, rbp, r12–r15` |

```c
/* void foo(int a, int b, int c, int d, int e, int f, int g); */
/* a–f in regs, g on stack */
```

Windows x64 differs — see `skills/compilers/msvc-cl`.

### 2. ARM AAPCS (AArch32/AArch64)

**AArch64:**

| Item | Rule |
|------|------|
| Integer args | `x0`–`x7` |
| Float args | `v0`–`v7` |
| Return | `x0`/`x1` or `v0` |
| Stack align | 16-byte |
| Callee-saved | `x19`–`x28`, `fp` (`x29`), `lr` (`x30`) |

Thumb interworking: LSB of function pointer set for Thumb code.

See `skills/low-level-programming/assembly-arm`.

### 3. RISC-V psABI (RV64)

| Item | Rule |
|------|------|
| Integer args | `a0`–`a7` |
| Callee-saved | `s0`–`s11`, `sp` |
| Return | `a0`, `a1` |
| Stack align | 16-byte |

See `skills/low-level-programming/assembly-riscv`.

### 4. Stack frame layout (conceptual)

```
high addresses
├── return address
├── saved frame pointer
├── local variables
├── spill slots / alignment padding
└── outgoing args (if any)
low addresses (rsp)
```

### 5. Variadic functions

System V: `al` holds number of vector args used; `register_save_area` on stack for `va_start`. Prefer typed wrappers over raw `va_arg` in portable FFI.

### 6. Verify in compiler output

```bash
gcc -O2 -S -o - foo.c   # study .cfi_* and mov args
objdump -d -M intel ./a.out
```

### 7. Agent usage

```
/abi-and-calling-conventions Which registers hold args 5–8 in AArch64 for my C function?
```

## Common Problems

| Symptom | Cause | Fix |
|---------|-------|-----|
| Crash on `call` | Stack misaligned | Align `rsp` mod 16 |
| Wrong float arg | XMM vs GPR mismatch | Match prototype |
| Corrupt callee-saved | Asm clobber missing | List in clobber or save |
| FFI garbage | Windows vs SysV mix | Match toolchain ABI |
| Variadic UB | Wrong type to `va_arg` | Cast to promoted type |

## Related Skills

- `skills/low-level-programming/assembly-x86` — x86-64 asm
- `skills/low-level-programming/assembly-arm` — AAPCS examples
- `skills/low-level-programming/assembly-riscv` — RISC-V asm
- `skills/rust/rust-ffi` — `extern "C"` guarantees
- `skills/binaries/elf-inspection` — symbol and relocation views

© mohitmishra786 · MIT · mohitmishra786/low-level-dev-skills

Similar skills

All skills for Programming languages →

From the same set62

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor