pub fn assemble<C: ContextObject>(
    src: &str,
    loader: Arc<BuiltinProgram<C>>
) -> Result<Executable<C>, String>
Expand description

Parse assembly source and translate to binary.

Examples

use solana_rbpf::{assembler::assemble, program::BuiltinProgram, vm::{Config, TestContextObject}};
let executable = assemble::<TestContextObject>(
   "add64 r1, 0x605
    mov64 r2, 0x32
    mov64 r1, r0
    be16 r0
    neg64 r2
    exit",
    std::sync::Arc::new(BuiltinProgram::new_mock()),
).unwrap();
let program = executable.get_text_bytes().1;
println!("{:?}", program);

This will produce the following output:

[0x07, 0x01, 0x00, 0x00, 0x05, 0x06, 0x00, 0x00,
 0xb7, 0x02, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00,
 0xbf, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
 0x87, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]