Question
Convert the C program below into an equivalent 64-bit x86-64 assembly language program. #include #include int main(void) { double a, b, c, disc; int status;
Convert the C program below into an equivalent 64-bit x86-64 assembly language program.
#include
#include
int main(void) {
double a, b, c, disc;
int status;
printf("Enter the constants a, b, and c for the quadratic equation: ");
status = scanf("%lf%lf%lf", &a, &b, &c);
if (status != 3)
printf("Error: Invalid input");
else if (a == 0 && b == 0)
printf("The quadratic equation has no solution ");
else if (a == 0)
printf("The quadratic equation has the single root %f ", -c / b);
else {
disc = b * b - 4 * a * c;
if (disc
printf("The quadratic equation has no real roots ");
else if (disc == 0)
printf("The quadratic equation has two equal real roots:%f ", -b / (2 * a));
else {
double sqrtDisc = sqrt(disc);
double root1 = (-b + sqrtDisc) / (2 * a);
double root2 = (-b - sqrtDisc) / (2 * a);
printf("The real roots of the quadratic equation are %f and %f ", root1, root2);
}
}
return 0;
}
Sample program runs: Enter the constants a, b, and c for the quadratic equation: 6.e x 7.0 Error: Invalid input Enter the constants a, b, and c for the quadratic equation: 2.e 5.e 3.e The real roots of the quadratic equation are -1.e0eee0 and -1.500000 Enter the constants a, b, and c for the quadratic equation: 1 4.e 10.0 The quadratic equation has no real roots Enter the constants a, b, and c for the quadratic equation: 1.e 8.0 16. The quadratic equation has two equal real roots:4.80008 Enter the constants a, b, and c for the quadratic equation : e. .e 6.5 The quadratic equation has no solution Sample program runs: Enter the constants a, b, and c for the quadratic equation: 6.e x 7.0 Error: Invalid input Enter the constants a, b, and c for the quadratic equation: 2.e 5.e 3.e The real roots of the quadratic equation are -1.e0eee0 and -1.500000 Enter the constants a, b, and c for the quadratic equation: 1 4.e 10.0 The quadratic equation has no real roots Enter the constants a, b, and c for the quadratic equation: 1.e 8.0 16. The quadratic equation has two equal real roots:4.80008 Enter the constants a, b, and c for the quadratic equation : e. .e 6.5 The quadratic equation has no solutionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started