将代码从c转换为assemly

将代码从c转换为assemly,c,assembly,C,Assembly,我不能正确地将c代码转换成汇编代码 代码是 #include <stdio.h> /* Standard Library of Input and Output */ #include <complex.h> /* Standard Library of Complex Numbers */ double complex power(double complex value, int power){ double comple

我不能正确地将c代码转换成汇编代码

代码是

    #include <stdio.h>      /* Standard Library of Input and Output */
   #include <complex.h>    /* Standard Library of Complex Numbers */


 double complex power(double complex value, int power){
     double complex result=1;
    for (int i=0;i<power;i++){
        result  = result * value;
    }
    return result;
 }

  double complex function(double order,double complex * array,double complex value) // a function that calculates f(x)
  {
    double complex result=0;
     for (int i = order ; i >= 0 ; i--){
      result = result + array[i]*(power(value,i));
  }
   //printf("the value of f(x) is:  = %.10f %+.10fi\n",creal(result), cimag(result));
  return result;
 } 
double complex derivefunction(double order,double complex * array,double complex value,double complex * darray){
  for (int i = order-1 ; i >= 0 ; i--){
       darray[i] = array[i+1]*(i+1);
}
return function(order-1,darray,value);

  }
   double abs(double m){//absolute
    if (m<0) 
        return -m;
    return m;
  }

  int main(void) {


   double tol,order;
   double arrayr[100];//assuming the maximum order is 0
   double arrayi[100];
   double complex array[100];

    printf("Enter the tolarence:\n");
    scanf("%lf", &tol);
    printf("the toleracnce is: %.10f\n",tol);


printf("Enter the order\n");
scanf("%lf", &order);
printf("the order is: %lf\n",order);


for (int i = order ; i >= 0 ; i--){
    printf("Enter the %d coeficience\n",i);
    scanf("%lf", &(arrayr[i]));//taking the real number
    scanf("%lf", &(arrayi[i]));// taking the imaginary number
    array[i] = arrayr[i] + arrayi[i] * I;//summing the complex number
    printf("The %d coeficience is  = %.2f %+.2fi\n",i ,creal(array[i]), cimag(array[i]));
}


double initialr, initiali;
double complex initial;
printf("Enter the initial value of z(the guss) \n");
scanf("%lf", &initialr);//taking the real number
scanf("%lf", &initiali);// taking the imaginary number
initial = initialr + initiali*I;

printf("The initial is  = %.2f %+.2fi\n", creal(initial), cimag(initial));
double complex result1 = function(order,array,initial);



     if (order > 0) {

    double complex darray[sizeof(array)];
    double complex result2 = derivefunction(order,array,initial,darray);



    //now the newton-rashford method
      double complex m = result1/result2;//the initial
    while (abs((double)(m)) >= tol)//if it is in the range
  {

        m = function(order,array,initial) / derivefunction(order,array,initial,darray);//f(x)/f'(x)
        initial = initial - m;
        //printf("The initial is  = %.10f %+.10fi\n", creal(initial), cimag(initial));
  }
  printf("The root is  = %.10f %+.10fi\n", creal(initial), cimag(initial));
 }

return 0;

  }

等等。。我认为这与我使用复数有关,但我不确定如何解决这个问题。

AFAIK gcc默认使用AT&T语法,而nasm使用Intel。我不明白为什么要显示原始C代码,而不是为其发出错误的生成的汇编程序。gcc生成的汇编代码是打算用gas而不是nasm来汇编的?看看这个:@Clifford推荐的。@MustacheMoses:别把话塞进我的嘴里。我没有推荐任何东西。问题是关于组装生成的汇编程序,您给出的链接是关于如何在第一个实例中生成汇编代码-我假设他已经完成了这一点,尽管没有提供证据。我唯一的建议是将汇编代码发布到C上,而不是发布到C上。但答案是我非常肯定使用gas而不是nasm。您的问题是gcc不会输出打算由nasm组装的代码。它希望你用汽油,但有一些不同。我想你可以试试,但你可能还需要做一些调整。
    nasm -g -f elf64 -w+all -o main.o main.s
    main.s:1: error: attempt to define a local label before any non-local labels
    main.s:1: error: parser: instruction expected
    main.s:2: error: attempt to define a local label before any non-local labels