Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从C到汇编_C_Eclipse_Assembly - Fatal编程技术网

从C到汇编

从C到汇编,c,eclipse,assembly,C,Eclipse,Assembly,如何从我使用的C程序中获取汇编代码 我在Eclipse中使用了类似这样的东西-c-fmessage length=0-O2-S,但我遇到了一个错误,提前感谢您的帮助 现在我有了这个错误 atam.c:11: error: conflicting types for 'select' /usr/include/sys/select.h:112: error: previous declaration of 'select' was here atam.c:11: error: conflic

如何从我使用的C程序中获取汇编代码 我在Eclipse中使用了类似这样的东西
-c-fmessage length=0-O2-S
,但我遇到了一个错误,提前感谢您的帮助

现在我有了这个错误

   atam.c:11: error: conflicting types for 'select'
/usr/include/sys/select.h:112: error: previous declaration of 'select' was here
atam.c:11: error: conflicting types for 'select'
/usr/include/sys/select.h:112: error: previous declaration of 'select' was here
这是我的职责

int select(int board[],int length,int search){
    int left=0, right=length-1;

    while(1){
        int pivot_index=(right+left)/2;
        int ordered_pivot=partition(board,left,right,pivot_index);

        if(ordered_pivot==search){
            return board[ordered_pivot];
        }
        else if(search<ordered_pivot){
            right=ordered_pivot-1;
        }
        else{
            left=ordered_pivot+1;
        }
    }
}
int-select(int-board[],int-length,int-search){
int left=0,right=length-1;
而(1){
int pivot_index=(右+左)/2;
int ordered_pivot=分区(板、左、右、pivot_索引);
if(有序_pivot==搜索){
返回板[ordered_pivot];
}

else if(searchEclipse仍将输出视为对象文件

gcc -O0 -g3 -Wall -c -fmessage-length=0 -O2 -S -oatam.o ..\atam.c
正在生成您想要的程序集,但由于传递给GCC的
-oatam.o
(通常您会将程序集存储在
atam.s
中),因此将其存储在
atam.o
中会产生混淆。下一个命令:

gcc -oatam.exe atam.o

尝试链接
atam.o
并生成可执行文件,但
atam.o
是程序集源,而不是对象文件,因此链接器失败。您需要告诉eclipse不要运行第二个命令(并且您可能希望更改第一个命令的输出文件名)

-S
指示编译器不要执行实际的编译和链接步骤,并在发出程序集后停止。另一方面,您也告诉编译器在同一行编译文件(以及其他冲突设置)

试试这个:

gcc -O0 -S ../atam.c

优化将使生成的程序集文件远离源代码,因此我指示gcc关闭优化。也不要运行链接器。

发生错误,因为select是Unix系统调用,并且您的定义与相关系统标头中的声明冲突。您需要重命名您的函数。

Eclipse不是C编译器,但我猜您使用的是GCC作为后端,因此,
-S
应该足够了,但我到底输入了什么?@lego
GCC-S..\atam.C
是您严格需要的全部;这将生成名为
atam.S
的程序集文件“它不工作”没有任何帮助。从命令行运行时会出现什么错误?在查看修订历史记录之前,我完全搞不懂你在说什么;他显然编辑了问题,说了一些与原始问题完全不同的内容,然后在你回答后再次编辑,删除了大部分信息信息,包括对
select()
的所有引用。我将其回滚,因为这似乎是他正在寻找的答案