Skip to content

How do you get the opcodes for an instruction using the API? #1613

Answered by psifertex
psifertex asked this question in General
Discussion options

You must be logged in to vote

There's two main ways you could do this. First if you just want opcodes for a generic instruction you can use the built-in assembler, like:

>>> bv.arch.assemble("mov eax, eax")
b'\x89\xc0'

Or if you don't have an open binary view, something like:

>>> list(Architecture)
[<arch: aarch64>, <arch: armv7>, <arch: thumb2>, <arch: armv7eb>, <arch: thumb2eb>, <arch: mipsel32>, <arch: mips32>, <arch: ppc>, <arch: ppc64>, <arch: ppc_le>, <arch: ppc64_le>, <arch: x86_16>, <arch: x86>, <arch: x86_64>, <arch: msp430>, <arch: m16c>, <arch: M68000>, <arch: M68008>, <arch: M68010>, <arch: M68020>, <arch: M68030>, <arch: M68040>, <arch: M68LC040>, <arch: M68EC040>, <arch: M68330>, <arch: M68340>]
>>> Arch…

Replies: 1 comment 1 reply

Comment options

psifertex
Apr 26, 2020
Maintainer Author

You must be logged in to vote
1 reply
@ghost
Comment options

Answer selected by psifertex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant