al_homework repository.
You may NOT use/access:
Failure to abide by these guidelines will result in a zero for the assignment and the incident will be reported to the university provost as a violation of the university academic integrity policy. A second incident of academic dishonesty (whether from this course or another computer science course) will result in an F in the course.
The approximation of gets closer and closer to the actual value as you
continue the pattern. For our purposes we'll parameterize the series with an
integer value
.
When we get
(which with a bit of algebra yields
).
When we get
(yielding
).
When we get
(yielding
).
Your x86 program will implement a function called estimate_pi that will accept
an integer value of as a parameter and will return a double-precision estimate of
. Your function will use register-based calling conventions.
Then, in a loop, you will call your function with increasing values of
to produce output similar to this:
Estimation for pi: 2.000000 Estimation for pi: 2.666667 Estimation for pi: 2.933333 Estimation for pi: 3.047619 Estimation for pi: 3.098413 Estimation for pi: 3.121501 Estimation for pi: 3.132157 . . . . . . . . . . . . . . .
Your program will end when your estimate gets within 0.0000001 of 3.14159265358979323846. NOTE: The I/O macros only show about 6 decimal places so you won't be able to see the exact results. To determine whether you are within a fraction of the goal you will need to do this calculation: error= abs(estimate - goal). There are several ways to calculate the absolute value in x86 assembly. We'll do it by calling the C-language fabs function provided by the math library as practiced in the lab exercises.
ADVICE: Code your solution in a high level language (including a separate
function for estimate_pi). Once it is working properly then start
encoding it in assembly. Write and test the function first. Once it is working
then complete the main program.
| Correctness/Completeness | 16 | pts |
| Documentation | 2 | pts |
| x86 Conventions | 2 | pts |
| Total | 20 | pts |
See Homework #6 for instructions on proper documentation and on x86 assembly language conventions.