Function burst::x86::format_instruction_string
[−]
[src]
pub fn format_instruction_string(
stream: &mut Write,
fmt: &str,
opcode: Option<&[u8]>,
addr: usize,
instr: &X86Instruction
) -> Result
Write an Instruction
to a stream.
The fmt
string can contain these specifiers:
%a
: Shows the address of the instruction as passed in theaddr
parameter.%b
: Shows the bytes of the instruction. Theopcode
parameter must contain the same contents as the call to to the disassemble function that produced the instruction. If%b
is not used, then theopcode
parameter may beNone
.%i
: Shows the operation mnemonic.%o
: Shows the operands.
In the future, this may be replaced by something that is more
like the std::fmt
features of the Rust standard library.
This currently doesn't support any configurable syntax support for AT&T style syntax.
use burst::x86::*; let data = [0u8, 0u8]; if let Ok(instr) = disassemble_64(&data, 0, data.len()) { let mut out = String::new(); format_instruction_string(&mut out, "%a %b %i %o", Some(&data), 0, &instr); assert_eq!("0000000000000000 0000 add byte [rax], al", out); }