我想知道如何使用Unix从C程序生成汇编代码.我试过gcc:gcc -c file.c
我也先使用cpp然后尝试as但是我遇到了错误.
我正在尝试从3个不同的程序构建汇编程序
prog1.c prog2.c prog.h
这样做是否正确gcc -S prog1.c prog2.c prog.h?似乎不正确.我不知道是否必须从每个汇编程序生成汇编程序然后将它们链接起来
谢谢
根据手册:
`-S'
Stop after the stage of compilation proper; do not assemble. The
output is in the form of an assembler code file for each
non-assembler input file specified.
By default, the assembler file name for a source file is made by
replacing the suffix `.c', `.i', etc., with `.s'.
Input files that don't require compilation are ignored.
Run Code Online (Sandbox Code Playgroud)
所以试试吧gcc -S file.c.
来自man gcc:
-S Stop after the stage of compilation proper; do not
assemble. The output is an assembler code file for
each non-assembler input file specified.
By default, GCC makes the assembler file name for a
source file by replacing the suffix `.c', `.i',
etc., with `.s'. Use -o to select another name.
GCC ignores any input files that don't require com-
pilation.
Run Code Online (Sandbox Code Playgroud)
如果你正在使用gcc(看起来像)它是gcc -S.
如果需要,请不要忘记使用-I指定包含路径.
gcc -I ../my_includes -S my_file.c
Run Code Online (Sandbox Code Playgroud)
并且您将使用Assembler指令获取my_file.s.