Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.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_Assembly - Fatal编程技术网

C到汇编的转换问题

C到汇编的转换问题,c,assembly,C,Assembly,我试图在不使用gcc-S函数的情况下将我的C代码转换成汇编,因为我想自己练习汇编。由于某些原因,我无法使我的汇编文件与我的c代码匹配,我也不知道为什么。这是我写的,C代码是正确的,但是汇编代码不编译。这是sparc组件顺便说一句 #include <stdio.h> int charCompare( const void *ptr1, const void *ptr2 ) { char i = *((char *)ptr1); char j = *((char *)

我试图在不使用gcc-S函数的情况下将我的C代码转换成汇编,因为我想自己练习汇编。由于某些原因,我无法使我的汇编文件与我的c代码匹配,我也不知道为什么。这是我写的,C代码是正确的,但是汇编代码不编译。这是sparc组件顺便说一句

#include <stdio.h>

int charCompare( const void *ptr1, const void *ptr2 )
{
    char i = *((char *)ptr1);
    char j = *((char *)ptr2);

    if (i > j)
        return (1);
    if (i < j)
        return (-1);
    return (0);
}

尝试使用以下命令:

gcc -S -O0 myfile.c

这个额外的gcc选项将关闭所有优化(比如可以重新排列代码的优化)。

我正在为此运行一个makefile以及其他文件,出于某种原因,c文件是编译的,但s会出错。nvm,我把我的makefile搞砸了,我想现在我已经修复了它。从程序集,看起来没有进行任何优化。您是否阅读了原始问题中特别提到的未使用gcc-S的部分?我假设他使用gcc检查其汇编代码(因此是“假定正确”的部分)。我现在明白你的意思了。我忘了把汇编文件实现到makefile中,我想现在可以了。如果你找不到任何问题,我想我找到了
gcc -S -O0 myfile.c