AsmArm64 2.0.0

dotnet add package AsmArm64 --version 2.0.0
                    
NuGet\Install-Package AsmArm64 -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AsmArm64" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AsmArm64" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AsmArm64" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AsmArm64 --version 2.0.0
                    
#r "nuget: AsmArm64, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AsmArm64@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AsmArm64&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AsmArm64&version=2.0.0
                    
Install as a Cake Tool

AsmArm64 ci NuGet

<img align="right" width="160px" height="160px" src="https://raw.githubusercontent.com/xoofx/AsmArm64/main/img/AsmArm64.png">

AsmArm64 is a powerful ARM64 Assembler and Disassembler .NET library.

✨ Features

  • Full support of 2448+ ARM64 v8.x/v9.x instructions
    • Automatically generated from ARM XML specification files from latest update 2024-12.
    • Note that SVE/SVE2/SME are not yet supported.
  • Unique strongly typed assembler API
  • Easily disassemble instructions and operands, including the knowledge of which operands and status flags are being read/write.
  • High performance / zero allocation library for disassembling / assembling instructions.
  • 15,000+ unit tests battle testing this library
  • Compatible with net8.0+ and NativeAOT.

💻 Example

Strongly Typed Assembler API

using var asm = new Arm64Assembler(0x1_0000);

// // Main entry point
// _start:
asm.Label("_start", out var labelStart);
//     mov     x0, #5         // Call sum_loop(5)
//     bl      sum_loop       // Call the function, result in x0
//     ret                    // Return from _start (normally would return to a caller)
var labelSumLoop = asm.CreateLabel("sum_loop");
asm.MOVZ(X0, 5)
   .BL(labelSumLoop)
   .RET();
// 
// 
// // Function: sum_loop(x0)
// // - Takes x0 as the loop limit
// // - Returns the sum in x0
// sum_loop:
asm.Label(labelSumLoop);
//     mov     x1, #0         // Accumulator (sum)
//     mov     x2, #0         // Counter
asm.MOVZ(X1, 0)
   .MOVZ(X2, 0);
// 
// loop_start:
asm.Label("loop_start", out var labelLoopStart);
//     add     x1, x1, x2     // Add counter (x2) to sum (x1)
//     add     x2, x2, #1     // Increment counter
//     cmp     x2, x0         // Compare counter with limit
//     blt     loop_start     // If counter < limit, continue loop
//     mov     x0, x1         // Store result in x0 (return value)
//     ret                    // Return to caller
asm.ADD(X1, X1, X2)
   .ADD(X2, X2, 1)
   .CMP(X2, X0)
   .B(LT, labelLoopStart)
   .MOV(X0, X1)
   .RET()
   .End();
// Bytes available in asm.Buffer or asm.ToArray()

Generated instruction methods return the assembler, so calls can be chained. Statement-style calls still work when the returned assembler is ignored.

Labels can be used in simple address expressions for label operands, e.g. asm.B(loop + 4) or asm.ADR(X0, dataLabel + 16). Arm64Address.Page/label.Page() and PageOffset() help with ADRP + page-offset address materialization. Subtracting labels (labelB - labelA) evaluates to a signed expression once both labels are bound.

When generated overloads can do so without creating ambiguous optional-operand signatures, they also record caller file/line information in asm.DebugMap. BeginFunction, EndFunction, BeginCodeSection, EndCodeSection, BeginDataSection, and EndDataSection add named markers to the same map for tooling and annotated disassembly. Finalization failures such as unbound labels or out-of-range labels throw Arm64AssemblerException with structured Arm64AssemblerDiagnostic entries; TryEnd(out var diagnostics) is available for non-throwing tooling workflows.

For larger layouts, Arm64Block/ArrangeBlocks can place fixed and aligned floating blocks, Literal/FlushLiteralPool emits explicit literal pools for LDR literal, and ExternalLabel records unresolved symbol relocations in asm.Relocations.

Disassembler API

ReadOnlySpan<byte> instructionBuffer = asm.Buffer;
var disassembler = new Arm64Disassembler();
var textWriter = new StringWriter();
disassembler.Disassemble(instructionBuffer, textWriter);
Console.WriteLine(textWriter);

// For quick roundtrips, use:
string text = asm.Disassemble();
// or:
string text2 = Arm64Disassembler.DisassembleToString(instructionBuffer, asm.BaseAddress);

will print:

LL_01:
    mov x0, #5
    bl LL_02

    ret

LL_02:
    mov x1, #0
    mov x2, #0

LL_03:
    add x1, x1, x2
    add x2, x2, #1
    cmp x2, x0
    b.lt LL_03

    mov x0, x1
    ret

Arm64DisassemblerOptions.TryFormatLabel can be used to resolve absolute addresses to label or symbol names, for example from PDB data. Arm64DisassemblerOptions.AutoLabelKinds controls which PC-relative operands get generated local labels (branches, calls, ADR/ADRP, or literal loads). Formatting options include style presets, comment prefix, address prefix, generated local-label format, and hex casing. Arm64DisassemblerOptions.InvalidDataMode controls trailing bytes that are not a complete 4-byte instruction: throw, emit a .byte directive, or ignore them.

📖 User Guide

For more details on how to use AsmArm64, please visit the user guide.

🪪 License

This software is released under the BSD-2-Clause license.

🤗 Author

Alexandre Mutel aka xoofx.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 305 5/16/2026
1.0.4 184 2/25/2026
1.0.3 109 2/25/2026
1.0.2 111 2/22/2026
1.0.1 118 2/5/2026
1.0.0 611 2/17/2025