Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im creating a solve quadratic formula HLA program but im having issues finding the error program solveQuadratic; #include ( stdlib.hhf ) ; static a:

Im creating a solve quadratic formula HLA program but im having issues finding the error
program solveQuadratic;
#include( "stdlib.hhf");
static
a: real32;
b: real32;
c: real32;
discriminant: real32;
root1: real32;
root2: real32;
begin solveQuadratic;
// Prompt and read values for a, b, and c
stdout.put("Gimme a value for a: ");
stdin.get(a);
stdout.put("Gimme a value for b: ");
stdin.get(b);
stdout.put("Gimme a value for c: ");
stdin.get(c);
// Calculate the discriminant
mov(b, eax);
fld(eax);
fmul(st0, st1); // b^2
fld(a);
fld(c);
fmul(st0, st1); // a * c
fadd(st0, st1); //2ac
fsub(); // b^2-4ac
fstp(discriminant);
// Compute the roots
fld(discriminant);
fsqrt();
fstp(root1); // store sqrt(discriminant) in root1
// Calculate the positive root
fld(b);
fchs(); //-b
fld(root1);
fadd(); //-b + sqrt(discriminant)
fld(a);
fadd(st0, st0); //2a
fdiv(); //(-b + sqrt(discriminant))/(2a)
fstp(root1);
// Calculate the negative root
fld(b);
fchs(); //-b
fld(root1);
fsub(); //-b - sqrt(discriminant)
fld(a);
fadd(st0, st0); //2a
fdiv(); //(-b - sqrt(discriminant))/(2a)
fstp(root2);
// Output the roots
stdout.put("x is ", root1:0:5," and x is also ", root2:0:5,"
");
end solveQuadratic;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

4. What are the current trends in computer software platforms?

Answered: 1 week ago