librasm 0.0.0

Library for using RASM.
docs.rs failed to build librasm-0.0.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

LibRASM

License Rust version

RASM — assembly language compiler. LibRASM — library for using RASM.

How to use it

  1. Add librasm to your Cargo.toml

    cargo add librasm
    
    

    or

    librasm = "0.0.0" # Or latest version
    
    
  2. You can use it! Example:

    use librasm::{RASM, SourceASM};
    
    fn main() {
        // Простой код:
        // ```x86asm
        // _start:
        //     mov rax, 0
        //     ret
        // ```
        let code = SourceASM::Slice("_start:
    mov rax, 0
    ret");
    
        let mut rasm = RASM::new(code);
    
        // tokens will appear in the `rasm` structure themselves.
        let _tokens = rasm.tokenize().unwrap();
    
        let _ast = rasm.parse().unwrap();
    
        let machine_code = rasm.compile().unwrap();
    
        // This:
        // ```x86asm
        // _start:
        //     mov rax, 0
        //     ret
        // ```
        // Equal to:
        //
        //      0x48, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3
        assert_eq!(machine_code.code, vec![0x48, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3]);
    }