customasm 0.13.10

An assembler for custom, user-defined instruction sets!
Documentation
pub mod asm;
pub mod diagn;
pub mod expr;
pub mod syntax;
pub mod util;

#[cfg(test)]
pub mod test;

#[cfg(any(test, target_arch="wasm32"))]
pub mod driver;

#[cfg(target_arch="wasm32")]
pub mod webasm;


/// Convenience function to assemble a given string.
/// 
/// The code cannot access external files through
/// `#include` or `incbin()`.
/// 
/// Returns the generated bytes of the assembled binary
/// if successful, together with the report containing
/// any errors or warnings that were encountered.
pub fn assemble_str_to_binary(
	src: &str)
	-> (Option<Vec<u8>>, diagn::Report)
{
	let virtual_filename = "str";

	let mut report = diagn::Report::new();
	let mut fileserver = util::FileServerMock::new();
	fileserver.add(virtual_filename, src);

	let opts = asm::AssemblyOptions::new();

	let assembly = asm::assemble(
		&mut report,
		&opts,
		&mut fileserver,
		&[virtual_filename]);
	
	(assembly.output.map(|o| o.format_binary()), report)
}