I'm looking into a way to generate pseudo-code from snippet of assembly,

let's assume I have this ASM

    push    rbp
    mov     rbp, rsp
    mov     DWORD PTR [rbp-4], edi
    mov     DWORD PTR [rbp-8], esi
    mov     edx, DWORD PTR [rbp-4]
    mov     eax, DWORD PTR [rbp-8]
    add     eax, edx
    pop     rbp

is there is a way to turn it into pseudo-code using the available decompilers?

if there is any exported API?

2 Answers 2


You can take the instructions, assemble them into hex values, for example by using: Online disassembler.

Then you get the byte representation: \x55\x48\x89\xE5\x89\x7D\xFC\x89\x75\xF8\x8B\x55\xFC\x8B\x45\xF8\x01\xD0\x5D\xC3

With this, you can patch bytes in the binary, and then use the normal decompile functionality in Ghidra/Ida on the patched area.


You can actually compile this with NASM depends on your preferred architecture, example command is below (I used linux):

nasm -f elf64 -o ./sample.asm ./sample.o 
ld -o ./sample ./sample.o 

global _start

section .text


    push    rbp
    mov     rbp, rsp
    mov     DWORD [rbp-4], edi
    mov     DWORD [rbp-8], esi
    mov     edx, DWORD [rbp-4]
    mov     eax, DWORD [rbp-8]
    add     eax, edx
    pop     rbp

After compiling and linking, I used IDA with pseudo-code support as what @macro_controller mentioned above.

enter image description here

Here is the result.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.