
use iced_x86::code_asm::asm_traits::CodeAsmJmp;
use iced_x86::{Instruction, code_asm::*};

pub fn assemble<F>(addr: u64, op: F) -> Result<Vec<u8>, Box<dyn std::error::Error>>
where
    F: Fn(&mut CodeAssembler) -> Result<(), Box<dyn std::error::Error>>,
{
    let mut asm = CodeAssembler::new(64)?;
    _ = op(&mut asm);
    Ok(asm.assemble(addr)?)
}