跳到正文
cccskills
免费在 GitHub 公开

assembly-arm

Use when reading or writing AArch64 or AArch32 Thumb assembly, inline asm in C, AAPCS64 register roles, or NEON and SVE vector code. Not for ABI detail across ISAs: use abi-and-calling-conventions.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(3)

  • SKILL.md6.0 KB
  • agents/openai.yaml198 B
  • references/reference.md4.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

ARM and AArch64 assembly

AArch64 has 31 general 64-bit registers, a clean load-store instruction set, and per-core SIMD through NEON. This skill reads compiler output and writes correct inline asm for it.

Contract

FieldBound contract
TriggerThe task reads GCC or Clang AArch64 output, writes inline asm or standalone assembly, decodes AAPCS64 register roles, or writes NEON intrinsics or SVE kernels.
AuthorityRead-only. The skill explains, drafts, and annotates assembly; edits land in the user's source through the normal coding path. No remote mutation.
Side effectNone. Output is analysis and drafted code in chat.
DoneThe drafted assembly assembles for the named target, or the compiler output under discussion is explained register by register.

Inputs

  • The C or C++ source, compiler output, or assembly fragment: required.
  • The target: required. aarch64-linux-gnu for application cores, arm-none-eabi with -mthumb for 32-bit Cortex-M.
  • The purpose: required. Reading output, writing inline asm, or vectorizing.

Procedure

  1. Generate a baseline. Write the C version first and read its output before hand-writing anything. Done when: the compiler's own code for the same function is on screen.
aarch64-linux-gnu-gcc -O2 -S foo.c -o foo.s
aarch64-linux-gnu-objdump -d a.out
  1. Map registers by role. The table names are the ABI's, and assembly must respect them. Done when: every register in the fragment is classified.
RegisterAliasRole
x0 to x7w0 for 32-bit useArguments and return values, caller saved
x8Indirect result location, or syscall number on Linux
x9 to x15Temporaries, caller saved
x16, x17ip0, ip1Intra-procedure call scratch, do not keep values across calls
x18Platform register, reserved on some platforms, do not use
x19 to x28Callee saved
x29fpFrame pointer
x30lrLink register, return address
spStack pointer, must stay 16-byte aligned at public interfaces
v0 to v7q/d/s viewsFP and SIMD arguments and returns, caller saved
v8 to v15Callee saved, low 64 bits only
  1. Read the common instructions. Load and store are separate from arithmetic, which only runs on registers. Done when: each instruction in the fragment parses.
ldr  x0, [x1]          // load 64-bit
ldrb w0, [x1]          // load byte, zero-extended
strb w0, [x1]          // store byte
ldp  x0, x1, [sp]      // load pair
stp  x29, x30, [sp, #-16]!  // store pair with pre-index writeback
add  x0, x1, x2        // x0 = x1 + x2
mul  x0, x1, x2        // low 64 bits of the product
madd x0, x1, x2, x3    // x0 = x1*x2 + x3
sdiv x0, x1, x2        // signed divide
udiv x0, x1, x2        // unsigned divide
cmp  x0, x1            // set flags from x0 - x1
cbz  x0, label         // branch if zero, no flags needed
blr  x0                // branch to address in register, set x30
ret                    // return through x30
adrp x0, symbol        // page address of a symbol
add  x0, x0, :lo12:symbol
  1. Write the standard prologue and epilogue. Leaf functions that fit in a frame need none. Done when: any callee-saved register pushed is popped, and sp returns aligned.
my_func:               // non-leaf example
    stp  x29, x30, [sp, #-32]!
    mov  x29, sp
    stp  x19, x20, [sp, #16]
    // body
    ldp  x19, x20, [sp, #16]
    ldp  x29, x30, [sp], #32
    ret
  1. Write inline asm with the constraints the target needs. volatile stops reordering, memory declares side effects on memory, and hardware registers need explicit clobbers. Use the counter to read the timer. Done when: the fragment compiles and its inputs, outputs, and clobbers are each listed.
static inline uint64_t read_cntvct(void) {
    uint64_t val;
    __asm__ volatile("mrs %0, cntvct_el0" : "=r"(val));
    return val;
}
  1. Use NEON for 128-bit SIMD. Work through <arm_neon.h> intrinsics; they map one to one onto instructions. Done when: the loop processes one vector per iteration and the scalar tail stays correct.
#include <arm_neon.h>

void sum_f32(const float *a, const float *b, float *dst, int n) {
    for (int i = 0; i + 4 <= n; i += 4) {
        float32x4_t va = vld1q_f32(a + i);   // load 4 floats
        float32x4_t vb = vld1q_f32(b + i);
        float32x4_t vc = vaddq_f32(va, vb);
        vst1q_f32(dst + i, vc);              // store 4 floats
    }
}
  1. Apply the platform corrections. Apple silicon uses 16 KiB pages and a 128-byte cache line, so sysconf(_SC_PAGESIZE) replaces the 4096 assumption. AMX is internal to Apple libraries; write portable code with Accelerate or Metal instead. SVE exists only where the hardware has it; guard SVE code and keep a NEON fallback. Done when: the code states no portability assumption the target contradicts.

Failure and recovery

Failure classBehavior
sp misaligned crash in a calleeA path adjusted sp by a non-16-byte amount. Audit every sub sp and pre-index offset.
Value lost across a call in hand-written asmThe value sat in x0 to x17. Move it to a callee-saved register or spill it.
Inline asm result wrong at -O2Missing volatile or a missing "memory" clobber let the compiler delete or reorder the asm.
NEON code fails on Cortex-MCortex-M has no NEON and runs Thumb. Rewrite with scalar code or a DSP extension.
SVE build fails on a NEON-only coreSVE needs supporting hardware. Use the guarded fallback from step 7.

Output

Annotated assembly or inline asm, with the register roles named, the clobbers justified, and the target stated. The condition-code table, the wider instruction list, and the NEON category reference are in references/reference.md.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

Use when configuring ADC sampling time, DMA-driven ADC, calibration, or DAC channel setup on bare-metal MCUs. Not for the DMA stream itself: use dma-baremetal.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

af-xdp

免费

Use when creating AF_XDP sockets, configuring UMEM and XSK rings, writing an XDP redirect program, or choosing copy versus zero-copy mode. Not for full kernel bypass: use dpdk.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

Use when a completed session needs an agent-environment retrospective. Not for an engineering retrospective from telemetry: use engineering-retrospective.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

Use when a redacted, trimmed agent transcript must be appended to a GitHub PR or issue body, with human approval and preview. Not for automated or model-initiated insertion.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

agents-md

免费

Use when a repo needs agent setup, AGENTS.md added or made lean, CLAUDE.md audited, or agent instructions scored or pruned. Not for remote, credential, publish, deploy, or irreversible changes.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin372026年9月29日 更新

查看 OutlineDriven 的全部技能

报告此技能的问题