Easy way to convert c code to x86 assembly?

前端 未结 9 1746
礼貌的吻别
礼貌的吻别 2021-01-30 23:44

Is there an easy way (like a free program) that can covert c/c++ code to x86 assembly?

I know that any c compiler does something very similar and that I can just compile

相关标签:
9条回答
  • 2021-01-31 00:14

    Gcc can do it with the -S switch, but it will be disgustingly ugly at&t syntax.

    0 讨论(0)
  • 2021-01-31 00:14

    The lcc compiler is a multiplatform cross-compiler. You can get it to produce Intel syntax assembly code by

    lcc -S -Wf-target=x86/win32 foo.c
    

    I find assembly code from lcc significantly easier to read than what gcc spits out nowawadays.

    0 讨论(0)
  • 2021-01-31 00:17

    Your compiler is already doing that as you've stated, and most likely will have an option to stop before assembling.

    For GCC, add the -S flag.

    gcc -S x.c
    cat x.s
    

    Edit: If your program is pretty short, you could use the online service at https://gcc.godbolt.org/.

    0 讨论(0)
  • 2021-01-31 00:20

    GCC can output Intel syntax assembly using the following command line:

    gcc -S input.c -o output.asm -masm=intel
    
    0 讨论(0)
  • 2021-01-31 00:20

    gcc will generate assembly if you pass it the -S option on the command line.

    Microsoft Visual C++ will do the same with the /FAs option.

    0 讨论(0)
  • 2021-01-31 00:23

    notice every architecture has its own unique names and even build differently now when you know the stacks involved using asm volatile would b the perfect solution

    0 讨论(0)
提交回复
热议问题