Convert assembly instructions to bytes in gdb

Is there any way I can convert an assembly instruction such as

cmp %rdx,%rbp

to bytes, but from text, not memory (so not by going to an address, printing it as an instruction and then printing it as bytes). Alternatively using some other tool than gdb.

>Solution :

There is a tool called compiler explorer:
https://godbolt.org/

Using it you can choose the input and output of your code.
For example, for this case, you can insert the input as "Assembly" and in the output choose the flag of "compile to binary" to see for any instruction what is the relevant bytes for it.

Leave a Reply