Skip to content

Read in Russian

RASM

License Rust version Crates.io CI GitHub Release

x86_64 assembler with Intel syntax

Documentation | Architecture | Contributing | Changelog | Security | CoC | To-Do List | NOTICE | Third-Party Licenses | License | The Book | Site

RASM (Red Assembler) — x86_64 assembler with Intel syntax.

Features and Benefits

  • Cross-platform: ELF64 for Linux, Mach-O for macOS, and PE32+ & COFF64 for Windows.

  • Native emitter: RASM does not require an external linker to create executable files.

    Most popular assemblers generate object files and require a separate linking step:

    • NASM → ld / lld / link.exe
    • GAS → ld / lld / link.exe
    • MASM → link.exe
    • YASM → ld / lld / link.exe

    RASM performs the entire process on its own.

  • JIT compilation: RASM has JIT compilation, which means that you can run your code without compiling it into an executable file.

  • Library: You can connect librasm to your Cargo.toml, and use RASM through simple function calls!
  • Minimum dependencies: The entire workspace uses only 3 external dependencies.
  • Errors and Diagnostics: Errors look in rustc/clang style.


Sample program

Let's write a simple program that outputs "Hello, world!" to the terminal.

On Windows

Save this code to main.s:

.import kernel32.dll GetStdHandle
.import kernel32.dll WriteFile

.data
msg:
    .ascii "Hello, world!\r\n"
written:
    dd 0

.text
_start:
    sub rsp, 40

    mov rcx, -11
    call GetStdHandle

    mov rcx, rax
    lea rdx, [rip + msg]
    mov r8, 15
    lea r9, [rip + written]
    mov qword [rsp + 32], 0
    call WriteFile

    add rsp, 40
    mov rax, 0
    ret

Next, run the program:

# Using the JIT compiler:
rasm run main.s

# Using the AOT compiler:
rasm build main.s

# Then run the compiled file:
./main.exe

On Linux

Save the code below to a file named main.s:

_start:
    jmp print

msg:
    .ascii "Hello, world!\n"

print:
    mov rax, 1
    mov rdi, 1
    lea rsi, [rip + msg]
    mov rdx, 14
    syscall

    mov rax, 60
    xor rdi, rdi
    syscall

Next, run the program:

# Using the JIT compiler:
rasm run main.s

# Using the AOT compiler:
rasm build main.s

# Then run the compiled file:
./main

Supported output formats

Supported formats for executable files.

Format Platform
ELF64 Linux
Mach-O macOS
PE32+ Windows

Comparison

Opportunity RASM NASM FASM MASM
Intel syntax
Direct generation of ELF64 executable files
Direct generation of PE32+ executable files
Built-in emitter
JIT execution
The official library API

The main difference between RASM and NASM, FASM and MASM is built-in emitter, JIT execution and the ability to use as libraries.


Project status

The development of RASM is actively continuing.

Quick start

Download Options RASM:


1. Via Github Releases (recommended)

Download the latest RASM version for your OS from Github Releases.

If you have Linux/macOS, make the file executable:

chmod +x rasm
./rasm -v

2. Build from the source code (need rustc & cargo 1.96.0)

  1. Clone the repository (you need git) and go to the working directory

    git clone https://github.com/dev-er1/rasm.git
    cd rasm
  2. Compile the workspace and remove the RASM from the target

    cargo build --release
    
    # Here you need to get the binary to your current directory so that the following command will work for you.
    ./rasm -v
  3. Add to the PATH (optional)

    So that you can run RASM from any folder by simply writing rasm, add the binary file to the environment variables of your OS:

    • If you have Linux/macOS:

      Add a line to your configuration file (for example, ~/.bashrc or ~/.zshrc):

      export PATH="$PATH:/path/to/folder/with/rasm"
    • For Windows:

      Run the command in PowerShell as an Administrator:

      [Environment]::SetEnvironmentVariable("Path", $env:Path + ";С:\path\to\rаѕm ", "User")

      (After that, restart the terminal)


Documentation and other documents

About

RASM (Red Assembler) is an x86-64 assembler with Intel syntax.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages