Assembly — 100 Operations for AI Agents

This page is the canonical reference an AI coding agent uses to refactor, query, and analyze Assembly code through the act MCP server. 100 operations available: 26 refactor, 18 query, 42 analysis, 14 verification. Each operation is callable from Claude Code, Cursor, Codex, OpenCode, or any MCP-compatible agent host. Click any operation for a stable anchor link suitable for citation.

18Query
26Refactor
42Analysis
14Verify

Worked Assembly examples

act101 edits raw x86/ARM assembly at the instruction level: it can wrap a range of instructions in a #ifdef/#endif preprocessor guard and inline a .equ constant back into every instruction that references it, removing the directive. The skeleton reads a file's labels as its entry points. Every operation here is anchored to a specific line and column inside the file, so a rename or removal changes only the instructions it names and leaves the surrounding routine untouched. Each example below is the verbatim output of the command shown, run against the file shown. Query outputs are pretty-printed with the timing block omitted.

Wrap an instruction in a preprocessor guard

setup issues a syscall that should only run on x86-64 targets.

$ act refactor-lang wrap_in_ifdef --file setup.asm --params '{"start_line":3,"end_line":3,"symbol":"X86_64"}'

Before

setup:
    mov rax, 0
    syscall
    ret

After

setup:
    mov rax, 0
#ifdef X86_64
    syscall
#endif
    ret

The syscall line is wrapped between #ifdef X86_64 and #endif; mov rax, 0 and ret stay outside the guard.

List a program's entry points

beep.asm is a NASM program for Linux x86-64: _start calls ring_bell, which issues a write syscall for one bell byte, then jumps to exit_ok, which issues exit.

$ act query skeleton beep.asm

Before

; Linux x86-64: write a bell character to stdout, then exit with status 0.
SYS_WRITE equ 1
SYS_EXIT  equ 60
STDOUT    equ 1

section .text
global _start

_start:
        call    ring_bell
        jmp     exit_ok

ring_bell:
        push    7
        mov     rax, SYS_WRITE
        mov     rdi, STDOUT
        mov     rsi, rsp
        mov     rdx, 1
        syscall
        pop     rax
        ret

exit_ok:
        mov     rax, SYS_EXIT
        xor     edi, edi
        syscall

Output

{
    "type": "Skeleton",
    "declarations": [
        {
            "kind": "function",
            "name": "_start",
            "range": {
                "start": {
                    "file": "beep.asm",
                    "line": 9,
                    "column": 1,
                    "byte_offset": 154
                },
                "end": {
                    "file": "beep.asm",
                    "line": 9,
                    "column": 8,
                    "byte_offset": 161
                }
            },
            "name_range": {
                "start": {
                    "file": "beep.asm",
                    "line": 9,
                    "column": 1,
                    "byte_offset": 154
                },
                "end": {
                    "file": "beep.asm",
                    "line": 9,
                    "column": 7,
                    "byte_offset": 160
                }
            }
        },
        {
            "kind": "function",
            "name": "ring_bell",
            "range": {
                "start": {
                    "file": "beep.asm",
                    "line": 13,
                    "column": 1,
                    "byte_offset": 213
                },
                "end": {
                    "file": "beep.asm",
                    "line": 13,
                    "column": 11,
                    "byte_offset": 223
                }
            },
            "name_range": {
                "start": {
                    "file": "beep.asm",
                    "line": 13,
                    "column": 1,
                    "byte_offset": 213
                },
                "end": {
                    "file": "beep.asm",
                    "line": 13,
                    "column": 10,
                    "byte_offset": 222
                }
            }
        },
        {
            "kind": "function",
            "name": "exit_ok",
            "range": {
                "start": {
                    "file": "beep.asm",
                    "line": 23,
                    "column": 1,
                    "byte_offset": 398
                },
                "end": {
                    "file": "beep.asm",
                    "line": 23,
                    "column": 9,
                    "byte_offset": 406
                }
            },
            "name_range": {
                "start": {
                    "file": "beep.asm",
                    "line": 23,
                    "column": 1,
                    "byte_offset": 398
                },
                "end": {
                    "file": "beep.asm",
                    "line": 23,
                    "column": 8,
                    "byte_offset": 405
                }
            }
        }
    ]
}

Each of the three labels is a function whose range is its label line; the equ constants, the section and the global directives are not reported.

Inline a constant back into its instructions

counter.asm defines LIMIT with a .equ directive and uses it in two instructions.

$ act refactor-lang inline_constant --file counter.asm --params '{"constant_name":"LIMIT"}'

Before

.equ LIMIT, 100
check:
    cmp eax, LIMIT
    jge done
    add eax, LIMIT
done:
    ret

After

check:
    cmp eax, 100
    jge done
    add eax, 100
done:
    ret

Both LIMIT operands become the literal 100, and the now-unreferenced .equ LIMIT, 100 directive is removed.

Query

18 query tools, the same on every supported language. Descriptions live in the shared reference: /docs/query-tools.

callers control_flow data_flow definition diagnostics effect_closure effect_summary fix_auto get_type graph import_organize interface mutations references repo_outline skeleton symbols symbols_batch

Refactor

Operation Description
add-comment Add a ; comment to an instruction or label line
add-label Insert a label before an instruction line
extract-address Extract an address or label reference to a named constant
extract-constant Extract an immediate value to a named .equ constant
extract_function Extract a code selection into a new function — automatically infers parameters, return types, and inserts the call site. Use instead of manually cutting/pasting code. Works without LSP; LSP improves type inference. Params: file (string), new_name (string), start_line (u32), start_column (u32), end_line (u32), end_column (u32) [, preview (bool), receipt (bool)]
extract_variable Extract an expression into a named variable — inserts the declaration and replaces the expression with the variable name. Works without LSP. Params: file (string), new_name (string), start_line (u32), start_column (u32), end_line (u32), end_column (u32) [, preview (bool)]
generate-function-epilogue Generate function epilogue (cleanup/return) for a target architecture
generate-function-prologue Generate function prologue (stack setup) for a target architecture
generate-function-stub Generate complete function skeleton with prologue and epilogue
generate-label Generate a new unique label definition
generate-macro Generate a .macro/.endm skeleton
inline Inline a variable, function, or method — replace every usage with its definition body, then remove the original. The inverse of extract. Works without LSP: it walks the workspace for references and refuses, naming the file, when it cannot read every candidate file; a language server makes the reference set exact. Params: file (string), symbol (string) [, line (u32), column (u32), preview (bool), receipt (bool)]. line alone resolves the symbol's one declaration on that line (refused when the line declares none or several of the name); line + column pinpoints its name
inline-constant Inline a .equ constant, replacing all references with its value
insert_body Replace a function's implementation body with new code. AST-validated — rejects if the result has parse errors, so you can't accidentally break syntax. Use instead of manual text editing for function rewrites. Params: file (string), symbol (string), code (string) [, commit (bool)]
move_symbol Move a function, class, or type to a different file and automatically update all imports across the codebase. Use instead of manually cut/paste + fixing imports. Works without LSP: it walks the workspace for references and refuses, naming the file, when it cannot read every candidate file; a language server makes the reference set exact. Params: file (string), symbol (string), destination (string) [, preview (bool), receipt (bool)]
recipe_run Run a codemod recipe: declarative match → transform → optional verify across modeled grammars. Preview lists matches; apply writes with optional E7 receipts and all-or-nothing rollback. Returns a per-site report.
remove-comment Remove the trailing comment from a line
remove-dead-code Remove unreachable instructions after an unconditional jump
remove-instruction Remove a single instruction line
remove-label Remove an unused label line
rename Rename a symbol and automatically update ALL references across the codebase. Safer and faster than find-and-replace — AST-aware, won't rename strings or comments. Works without LSP: it renames across the workspace and refuses, naming the file, when it cannot read every candidate file; a language server makes the reference set exact. Params: file (string), old_name (string), new_name (string) [, line (u32), column (u32), preview (bool), receipt (bool)]. line alone resolves the symbol's one declaration on that line (refused when the line declares none or several of the name); line + column pinpoints its name
rename Rename an assembly symbol and every reference that binds to it
rename-label Rename a label and all its jump/call references
rename-register Rename a register across all uses in scope
unwrap-ifdef Remove #ifdef/#endif wrapper, keeping the body
wrap-in-ifdef Wrap instructions in #ifdef/#endif conditional assembly

Analysis

42 analysis tools, the same on every supported language. Descriptions live in the shared reference: /docs/analysis-tools.

analyze_api_diff analyze_chokepoints analyze_clones analyze_clusters analyze_cohesion analyze_conformance analyze_coupling analyze_cycle_risk analyze_cycles analyze_dead_code analyze_depth analyze_entry_points analyze_export analyze_extraction analyze_fan_balance analyze_features analyze_hotspots analyze_impact analyze_inconsistencies analyze_inheritance analyze_interface_bloat analyze_interfaces analyze_layers analyze_orphan_types analyze_patterns analyze_platform_deps analyze_readiness analyze_roles analyze_seams analyze_stability analyze_surface analyze_test_gaps analyze_thickness analyze_type_completeness churn_hotspots co_change_clusters coverage_overlay ownership_map profile_overlay simulate split_module trace_overlay

Verify

14 verify tools, the same on every supported language. Descriptions live in the shared reference: /docs/verification.

bisect_regression gate generate_test_harness scan secret_surface summarize_pr taint_flow unsafe_surface verify_behavioral_equivalence verify_contract_preserved verify_diff_semantics verify_port_parity verify_side_effects verify_test_impact

← ArduinoAstro →