Solved

# Converting C to Assembly Language

Posted on 2007-11-14

Is it possible to convert a program written in c to assembly language that will solve quadratic equation? Below is a sample program.

// Program to calculate roots of a quadratic equation ie ax2+bx+c=0 //

# include <stdio.h>

# include <conio.h>

#include <math.h>

void main()

{

float a, b, c, d, x1,x2;

clrscr();

printf("Enter coefficients of quadratic equation ie a, b and c: ");

scanf("%f%f%f", &a, &b, &c);

d=b*b-4*a*c;

if (d>0)

{

x1= (-b+(sqrt(d)))/(2*a);

x2= (-b-(sqrt(d)))/(2*a);

printf("Roots x1= %f and x2= %f are real and unequal", x1, x2);

}

else if (d==0)

{

x1= (-b/2*a);

x2= x1;

printf("Roots x1= %f and x2= %f are real and equal", x1, x2);

}

else

{

x1= (-b/2*a);

x2= sqrt(abs(d))/(2*a);

printf("Real part= %f and imaginary part= %f are complex conjugates", x1,x2);

}

printf(\n\n\t\t Press any key to continue&);

getch();

}