Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly program in MASM Template to use the floating point unit to com

ID: 3861932 • Letter: W

Question

Write an assembly program in MASM Template to use the floating point unit to compute pi. Let the user input the number of terms used for computing pi. For example, the number of terms is 4 in the above formula. You may assume that the number of terms is not larger than 100,000.

pi () can be approximated as:

pi/ 4 = 1 – 1/3 + 1/5 – 1/7 + …

Steps:

1. ask the user to input n which is the number of terms.

2. if n == 0, exit the program.

3. If n > 100, 000, set it to 100, 000.

4. estimate pi using n terms.

5. show the estimated pi value.

6. go back to step 1.

Explanation / Answer

Assembly program to use the floating point unit to compute pi

.model small
.stack 100h
.data
import random
import math
Prompt db 13,10, ‘First number: ‘,’$’
Result db 13,10, ‘Result’,’$’
Num1 db ?
pi = math.pi
for i in range(0,100000):
result = pi * num1
print "result is ", result

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote