Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

little-emulator/little-assembler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Little Assembler

Rust Brain made GNU AGPLv3.0 License Buymeacoffee
CI Badge GitHub Stars


An assembler library for the LC2 ISA 🏗️

Library Usage

  1. Add the library to you project:

    cargo add assemblers --git https://git.nicolabelluti.me/little-emulator/little-assembler.git
  2. Use the assembler in you project:

    use assemblers::{lc2::Lc2AssemblerBuilder, Assembler};
    
    fn main() {
        // Create a new assembler
        let assembler = Lc2AssemblerBuilder::new().build();
    
        // Assemble
        let (binary, symbol_table) = assembler.assemble(r#"
            .orig 0x3000
            
            LEA R0, string
            PUTS
            HALT
    
            string: .stringz "Hello, World!"
            
            .end
        "#).unwrap();
    
        // Print the binary
        for byte in binary {
            print!("{:02x}", byte);
        }
        println!();
    }

Builder setters

Param Default Description
.optional_starting_orig(...) false Allow the assembly to start witout a .orig directive. The start address will be set at 0
.multiple_origs(...) false Allow the assembly to have more than one .orig directive. They must be declared in order
.optional_end(...) false Allow the assembly to end without a .end directive
.nothing_after_end(...) true Return an error if the assembly has some instructions after the .end directive
.enable_stringzp(...) false Enable the .STRINGZP pseudo-operation to create null-terminated packed strings
.prepend_start_address(...) true Add the starting address to the start of the binary

About

A mirror repo for `little-assembler`, an assembler for the LC2 ISA

Topics

Resources

License

Stars

Watchers

Forks

Languages