Dynasm-rs: dump assembly instructions instead of machine code?

dynasm-rs: GitHub - CensoredUsername/dynasm-rs: A dynasm-like tool for rust.

Is there a way to get dynasm to dump assembly instructions instead of machine code ? This sounds silly: an assembler that dumps asm instead of machine code is kind of pointless. The context / use case is this: I'm playing with a toy JIT. I want to dump the asm that the JIT produces. The way dynasm works is that it it is a rust procedural macro that is called in many different places.

After the dynasm! macro is called in lots of different places (possibly inside loops / nested function calls), I want a way to get the equivalent asm (instead of machine code)

(Looking at the src of the default assemblers, it seems them only keep track of a Vec<u8>, i.e. the machine code, but not the intermediate instructions.)

As workaround you can use a disassembler like capstone which has rust bindings:

https://docs.rs/capstone/0.9.0/capstone/

2 Likes