Assembly
Introduction to Assembly

Introduction to Assembly

Tooling

Writing and building sBPF Assembly programs traditionally required the full Solana toolchain, which can be complex to set up and platform-dependent. For this exact reason, Dean, with contribution from Claire, created sBPF: a complete toolkit for creating and building sBPF Assembly programs.

Installation

We start by installing the package by doing:

cargo install --git https://github.com/blueshift-gg/sbpf.git

After that we'll be able to do all the following commands:

  • init: Create a new project scaffold.
  • build: Compile into a Solana program executable.
  • deploy: Build and deploy the program.
  • test: Test the deployed program.
  • e2e: Build, deploy, and test a program.
  • clean: Clean up build and deploy artifacts.
  • help: Print this message or the help of the given subcommand(s).
Usage: sbpf <COMMAND>
 
Commands:
  init    Create a new project scaffold
  build   Compile into a Solana program executable
  deploy  Build and deploy the program
  test    Test deployed program
  e2e     Build, deploy and test a program
  clean   Clean up build and deploy artifacts
  help    Print this message or the help of the given subcommand(s)
 
Options:
  -h, --help     Print help
  -V, --version  Print version

Initialize a new project

To create a new project, use the sbpf init command. By default, it initializes a project with Rust tests using Mollusk. You can also initialize a project with TypeScript tests using the --ts-tests option.

sbpf init --help
Create a new project scaffold
 
Usage: sbpf init [OPTIONS] [NAME]
 
Arguments:
  [NAME]  The name of the project to create
 
Options:
  -t, --ts-tests  Initialize with TypeScript tests instead of Mollusk Rust tests
  -h, --help      Print help information
  -V, --version   Print version information

After initializing the project, you can navigate into the project directory and use other commands to build, deploy, and test your program.

Building Programs

sBPF provides two build options depending on your setup and needs:

sBPF Build

The build command uses a standalone assembler that requires no additional dependencies. It's perfect for learning and experimentation since it "just works" on any platform.

sbpf build

Advanced Usage

You can override the default linker with a custom linker file by including it in the src directory with the same name as your program. For example:

src/example/example.s
src/example/example.ld

Development Environment

For the best development experience, consider installing the VS Code sBPF Assembly extension which provides:

  • Syntax highlighting for sBPF assembly
  • Code completion for instructions and registers
  • Error detection and warnings
Contents
View Source
Blueshift © 2025Commit: e508535