Intel 80286, 80287 manual 0o,3

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 477
Image 477

NUMERIC PROGRAMMING EXAMPLES

i AP X:286 MACRO ASSEMBLER

LOC 08,)

007F

007F D9F2

OOBI

0081 F6C742

0094 ?BIA

0096 D9Cl

OOBS EllA

OOSA

DOBA DDDS

OOSC 7404

OOBE 7002

0090 D9FB

0092

0092

0092 C3

0o,3

0093 D9ES

009'EBEA

0097

0097 OED.

0099 2ED9060AOO

009E 99

009F C3

OOAO

OOAO D9CO

00A2 D9CA

00A4

00A4 Dcea

OOA6 D9C9 00A8 DCCB OOAA DEC!

OOAC D9FA

OOAE 80E701

0001 80E402-

0094 DAFe

0006 7A02

OODB 09EO

OOBA

OOBA DEF'

DOBC C3

B0287 T1'ignometl'ic Functioni;

10: 13: 51 09/25/83 PAGE

LINE SOURCE

207

20B , Assert:: 0 ( steOl <- PII4

20.

210dD_sine_fphn:

212

flpten

 

,

TAN 9nO) • STeu/snol ... V/X

213

IIfte" _sine_flpten:

 

 

.14

 

 

210

te . t

bh.highCmilsk

c:and3 + m.sk cond!).

L.ao. at octant angle fell into

21.

.17.

JPo

X_numeT'atoT'

I

C.lcul.te cosine 'aT' Dctenh

21B

 

 

I 1,2.9.6

 

 

 

 

220Calculate the sine of the aT'~ument.

221sinCA) ... tanCA)/sq,T't<1+tanCA)**2)if tenCA) ... V/X then

2 ••sinCA) ... V/sqrt(X_X + V-V)

22'

224

 

'Id

stCl)

I

Cop V V value

22'

 

Jmp

shoT't finhh_sine

I

Put V value in numeT'atoT'

22.

,

The top 0' the stack is eUheT'

NAN. infinitv. OT' emptv .

• 27

22B

 

 

 

 

229

funnv"paT'ameteT':

 

 

 

230

 

fstp

steO)

,

Remove PII4

231

 

=

 

J'

retuT'n_empt"

I

Return empt\l if no paT'm

233

 

JPO

T'.tuT'n..NAN

 

Jump if st(OI is NAN

.34

 

I

235

 

st(O)

is infinit". R.tuT'n· an

indefinite

value.

23.

 

237

 

'pT'em

 

 

STell can be ·.n\lthing

2.B

 

 

I

23.

 

 

 

 

 

240T'etuT'n..NAN:

.41

T'etuT'n_emp tV:

 

 

.42

 

 

 

 

 

Ok to hillve fpT'em T'unning

243

 

•• t

I

244

 

Simuleh 'ptan lIIith ~tCO)

... 0

 

245

I

 

2 ••

,

 

 

 

 

 

.47

Il.ne_aT'gument_zeT'o:

 

 

.4B

 

 

 

 

 

Simulate tanCO)

•••2.0

 

 

 

 

I

 

 

 

 

I

RetuT'n the zeT'O value

201

 

The anllh ilia. tao laT'lIe.

Remove the modulull and divl.dend fT'om the

2.2

 

253stack and retuT'n an indefinite T'e~ult.

2••

••5

2••

257

 

fcompp

 

 

 

I

Pop tlllO valulls for'om the stack

25B

 

Hd

indefinite

 

 

I

RetuT'n indefinite

•••2.0

 

rot

 

 

 

 

Wait foT' load to finish

 

 

flllOl1t

 

 

 

I

•• 1

 

Calculate the cosine of the aT'gument.

 

 

 

2 ••

 

 

 

 

2.3

 

cosCA)

- 1/sqrtC1+tanCA)**2)

if

tenIA)

III V/X

then

2.'

,

cas (A)

= X/sq,rtex*x +

V*V)

 

 

 

 

 

••5

 

 

 

 

 

 

 

 

 

2 ••

X_numeT'atoT':

 

 

 

,

 

 

 

2.7

 

 

 

st(O)

 

 

COP\!

X value

2.B

 

fld

 

 

2 ••

 

fxch

~t(2)

 

 

 

Put X in

numeT'atoT'

270

finish _sine:

 

 

 

 

 

 

 

271

 

 

 

,

 

 

 

272

 

fmul

st. st(O)

 

 

FOT'm

x*x

+ V.V

27.

 

 

 

274

 

Fxch

st,st(O)

 

 

 

 

 

 

27S

 

fmul

 

 

 

 

=

 

.7.

 

hdd

 

 

 

 

st<O)

X'X + V*V

277

 

hq,rt

 

 

 

 

steOI

. sqrteX*X + V*V)

278

 

 

 

 

 

 

 

 

 

 

27.

 

FOT'm

the sign of the T'esult.

The

hID conditions

are the Cl flag 'T'tlm

2BO

 

2Bl

 

FXAM in bh and the CO flag fT'om IpT'em in ah.

 

 

28.

 

 

 

bh, high (mask

condO)

 

 

Look at the fprem CO flag

28.

 

and

 

 

2B4

 

.nd

ah, highemask

condl)

 

 

Look at the ham Cl flag

B5

 

D.

bh, ah

 

 

 

Even numbeT' of flags cancel

.8.

 

JPe

positive_sine

 

 

 

TIllO negatives m.ake a positive

2B7

 

fchs

 

 

 

 

FOT'ce

T'esult negative

.88

 

 

 

 

 

2B.

 

 

 

 

 

 

 

 

 

 

2'0

 

 

 

 

 

 

 

 

 

 

2.1

 

fdiv

 

 

 

 

Form

final result

2.2

 

 

 

 

 

2.3

 

rot

 

 

 

 

Ok to leave fdiv running

2.4

 

 

 

 

 

 

 

 

 

 

2.'

casine endp

 

 

 

 

 

 

 

296 +1

'eJect

 

 

 

 

 

 

 

 

 

2.7

 

This function !IIill calculate the tangent of an angle.

2.B

 

2.'

 

The angle, in T'adians is pa.sed in ST(O), the tangent is T'eturned

300in ST(OL The tangent is calculated to OIn aCCUT'aCU of 4 units in the

Figure 4-7. Calculating Trigonometric Functions (Cont'd.)

4-21

Page 477
Image 477
Intel 80286, 80287 manual 0o,3