An assembler library for the LC2 ISA 🏗️
-
Add the library to you project:
cargo add assemblers --git https://git.nicolabelluti.me/little-emulator/little-assembler.git
-
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!(); }
| 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 |