Nvis 5586A
Nvis Technologies Pvt. Ltd.
157
Program 39:
Write a program to calculate Sin (Z) where Z - is defined in degrees
.
Solution:
Sin (Z) is calculated using tangent function of 8087.
tan (Z/2)
=
Y/X
then Sin (Z)
=
Y
X
2XY
The FPTAN instruction has to be given data in radians. The value of degrees is to be
converted in radian. On execution of FPTAN the result is return in Y/X format where X is
written on top of stack and Y is the next to top of stack. Further the argument must satisfy
0< argument < P1/4. This is the reason we restrict Z to satisfy 0< Z < 90.
This restriction can be eliminated, by more computation. If Z is unrestricted, then the use of
FPREM function of 8087 to reduce the argument to the required range and use the relation
Sin (P1 + Z) = -Sin Z
The above problem is solved by calculating Z/2, then converting the degrees into radians and
then calculating the tangents. The resulting values of X and Y are used for calculating Sin
(Z).
The following steps are required to implement this program.
1.
Calculating the Z/2
2.
Calculate the angle in radians.
3.
Calculate tan (Z/2) = X/Y format.
4.
Calculate Sin Z = 2XY/(X
2
+Y
2
)
5.
Get the integer value argument - 4.
Address
Opcode
Mnemonic
Comment
Step-1
0200
B4 00
MOV
AH, 00
CLEAR AH
0202
D1 E8
SHR
AX, 01
Z = Z/2.
0204
A3 00 03
MOV
WARGI,
AX
LOAD AX IN ARG.1
0207
DF 06 00 03
FILD
ARGI
LOADING Z/2 ON TOS
Step-2
020B
C7 06 02 03
MOV
WARG
ARG 2 I IS LOADED WITH
B4 I.E. 180° VALUE IN HEX.
020F
B4 00
MOV
AH, 00
0211
9B DF 06 02 03 FILD
ARG 2
INSERT
F
WAIT
AND
LOAD AR G2.
0216
9B DE F9
FDIVRP
WAIT AND DIVIDE ST (O) =
Z/180.
0219
9B D9 EB
FILDP
ST (O) = PI
021C
9B DE C9
FMULRP
ST (O) = PI X Z/180
Total Angle in Radians
Step-3
Summary of Contents for 5586A
Page 2: ...Nvis 5586A Nvis Technologies Pvt Ltd 2...
Page 23: ...Nvis 5586A Nvis Technologies Pvt Ltd 23 Memory Read Timing in Maximum Mode...
Page 30: ...Nvis 5586A Nvis Technologies Pvt Ltd 30...
Page 48: ...Nvis 5586A Nvis Technologies Pvt Ltd 48 Diagram of module RESET power Instruction Set Note...