The purpose of this lab is to use write and test a procedure that uses floating point instructions to compute an approximation to ?.
Pi can be computed using the infinite series ? = 4 * (1 – 1/3 + 1/5 – 1/7 + 1/9 – 1/11 + …) or approximated by adding a finite number of the terms in the parentheses.
Let nbrTerms be the number of terms for a partial sum: 1 for 1, 2 for 1 – 1/3, 3 for 1 – 1/3 + 1/5, etc.
Write an assembly language procedure piApprox that returns a specified approximation.
A C prototype could look like float piApprox(int nbrTerms); /* returns 4 * (1 – 1/3 + 1/5 – 1/7 + 1/9 – 1/11 + …) */ /* where nbrTerms are added/subtracted in the parentheses*/
You will also write a test driver to input the number of terms, call piApprox and output the result. Here are additional specifications:
• Develop your program using Visual Studio 2015 (not an earlier or later version) • Use separate files for your test driver and procedure piApprox
• This will be a complete program that prompts for the number of terms and displays the approximation with an appropriate label. You may do this in either of two ways:
1. Write an assembly language test driver in a win32 project that uses procedure ftoaproc (section 9.3) to convert the result to ASCII for output. Note this will involve a third file and use of an appropriate EXTERN directive.
2. Write a C or C++ test driver to input the number of terms and display the result. See the instructions for creating a mixed-language VS 2015 project and the examples in the last section of the book. Note that if you choose this option, your assembly language procedure must be named _piApprox.
• As you accumulate the sum, keep the denominator (1, 3, 5, etc.) as an integer, not a floating point number. The sum and the terms you add/subtract must be floating point, of course.