User's Manual

iAPX286
MACRO
ASSEMBLER
LaC
OBJ
002F
ODDS
0031
09E8
0033
C3
0034
0034
09E5
0036
'rOOFED
0039
2E082EOOOO
003E
9E
003F
7249
0041
D9C9
0043
13100
0045
7Ee7
0047
0047
D9FB
0049
93
004A
9BDFEO
0040
93
004E
F6C704
0051
7544
0053
09El
0055
OAe9
0057
740F
0059
eOE4FD
Dose
BOeFBQ
005F
80C74Q
0062
BODO
0064
Dono
0066
32F8
0068
0068
F6C102
006B
7404
0060
DEE9
OOoF EBCE
0071
0071
09E4
0073
91
0074
9BDFEO
0077
91
0078 0009
007A
F6C540
0070
7514
NUMERIC PROGRAMMING EXAMPLES
80287
T'I'ignometric
Functions
10: 13:
51
09/25/83
PAGE
LINE
113
11'
115
116
117
118
".
120
121
122
123
12.
125
126
127
128
12.
130
131
132
133
13.
135
136
137
138
13.
140
141
142
"3
144
145
146
147
148
14.
150
151
152
153
154
155
156
157
158
15.
160
161
162
163
164
165
166
167
168
16.
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
18.
,.0
",
,.2
,.3
I.'
,.5
,.6
,.7
,.8
'"
200
201
202
203
204
205
206
SOURCE
sine:
fstp
fld
1
rot
stCO)
Remove
a
Return
1
All
",ork
is
done
as
a
sine
function.
By
adding
PI/2
to
the
angle
a
cosine
is
converted
to
a
sine.
Of
c:ourse
the
angle
addition
is
not
done
to
the
argument
but
rather
to
the
program
logic
control
",alues.
fXam
fstsw
ax
f!ld
pi_quarter
sahf
J'
funnlJ-parameter
Angle
is
unnormal.
normal.
fxch
mov
Jpo
cl,O
5 i
ne_z
ero_unnorma
1
I
Entry
point
for
sine
function
Look
at
the
parameter
Look
at
f!~am
status
Get
PI/4
",alue
CF
==
CO.
PF
::
C2.
ZF
==
C3
,Jump
if
emptlJ'
NAN.
or
infinity
denormal.
I
ST(1)
II:
PI/4,
steO)
angle
;
Signal
sine
; ,Jump
if
%ero
or
unnormal
ST(O)
is
either
a
normal
or
denormal
",alue.
Both
will
work.
Use
the
fprem
instruction
to
accuratellJ
reduce
the
range
of
the
gi",en
angle
to
within
0
and
PI/4
in
magnitude.
If
fprem
cannot
reduce
the
angle
in
one
shot,
the
angle
is
too
big
to
be
meaningful,
>
2*".62
radians.
Any
roundoff
error
in
the
calculation
of
the
angle
given
could
completellJ
change
the
result
of
this
function.
It
is
safE'st
to
call
this
verlJ
rare
c:ase
an
E'rror.
enter
_sine:
fprem
I
Reduce
angle
xchg
ax.
b x
fstsw
ax
xchg
ax.
b x
test
bh,
high(mask
cond2l
Jnz
angle_too_big
Note
that
fprem
will
force
a
I
denormal
to
a
verlJ
small
unnormal
Fptan
of
a
very
small
unnormal
will
be
the
same
very
small
unnormal.
which
is
correct.
Save
old
status
in
EX
Check
if
reduction
was
complete
I
Quotient
in
CO.
C3.
Cl
Put
new
status
in
bx
sin(2*N*PI+~)
=
sin(x)
Set
sign
flags
and
test
for
whic:h
eighth
of
the
revolution
the
angle
fell
into
Assert·
-PI/4
<
st(O)
<
PI/4
fabs
Dr
J'
cLcl
sine_select
Force
the
al'gument
positive
cond1
bit
in
bx
holds
the
sign
Test
for
sine
Ol'
cosine
function
,Jump
if
sine
function
This
is
a
cosine
function.
Ignol'e
the
origlnal
sign
of
the
angle
and add
a
G.uarter
revolution
to
the
octant
id
from
the
fpl'em
instruction.
cos
(A)
::::
sin(A+PI/2)
and
c:os(
:A:)
::::
cosCA)
and
add
mov
rol
ah,not
high(mask
condll
bh,
SOH
bh,
high
(mask
con(3)
a},
0
al,l
bh,
al
Turn
Off
sign
of
argument
Prepare
to
add
010
to
CO,
C3,
Cl
status
value
in
ax
Set
busy
bit
so
carry
out
from
C3
will
go
into
the
carry
flag
Extract
carrlJ
flag
Put
carrlJ
flag
in
low
bit
Add
carry
to
CO
not
changing
Cl
flag
See
if
the
argument
should
be
revel'sed,
depending
on
the
octant
in
which
the
argument
fell
during
fprem.
test
bh,
high(mask
condU
Angle
was
in
oct
...
nt~
1.3.5,7.
fsub
Jmp
Angle
was
in
octants
0,2,4,6.
J
Reverse
angle
if'
Cl
Invert
sense
of
rotation
o <
arg
<=
PI/4
Test
for
a
zero
aT'gument
since
fptan
will
not
WOT'k
if
st(O)
::::
0
ftst
Test
for
zero
angle
xchg
ax,
cx
fstsw
ax
c,c'ind3 = 1
if'
st(Q)
= 0
xchg
ax,
c x
fstp
st(
1)
Remove
PI/4
te~t
ch,high(mask
cond3)
I
If
C3==1.
argument
is
zero
Jnz
sine_argument_zero
Figure
4-7.
Calculating
Trigonometric
Functions
(Cont'd.)
4-20