Intel 80286, 80287 manual 4676

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 479
Image 479

NUMERIC PROGRAMMING EXAMPLES

iAPX286 MACRO ASSEMBLER

80287

rrignometric Functions

10: 13: 51 09/25/83 PAGE

lOC ODJ

LINE

SOURCE

 

00E9 E83300

OOEe EDEO

OOEE

OOEE C3

COEF

DOEF D9E4 OOF! 91

OOF2 '9BDFEO

OOF5 91

OOF6 DDD9

OOFS F6C'40 OOFS 7515

caFD

OOFD D9F2

DOFF

39.

3.7

3.8

3••

403

404

40S

40.

407

408

410

412

413

414

415

417

"B

41.

420

.21

call Jmp

rot

Angle

flht

xchg

fstsw

xchg

htp test

J"'

fptan

aft . r _tangent:

normalize_valu. tan_normal

fell in octants 0.2.4.6. Test for 5t(O) - 0, flpti!ln won't work.

 

 

Test for

zero engle

u:.cx

 

C3 = 1

 

 

.,

I

H

st(O) .. 0

ex, Cl

I

Removtt

PI/4

ste 1)

ch, high(mask

cond3)

 

 

 

tan_zero

 

 

 

 

 

J

ttm sno)

.. ST(!)/ST(O)

OOFF BAC?

0101 254002

0104 F6C742

0107 7BOD

.22

• 23

42'

.OS

42.

.27 42B 42. 430

.31 432 '33

43'

.35

Decide on the o"der of the op.rands and their sign for the divide operation while the fptan instruction is working .

mov

d . btl

+ high(mask

I

Qet a cop", of 'prem C3 P1oI9

and

a •• mask cond1

cond3),

Elamine

fprem C3 flag

and

 

 

condl + mask

j

FXAH CI

flag

 

test

bh. high(mask

cond3)l

Use rttverse divide if in

 

 

 

,

octants

1.2, S. D

 

Jpo

reverse_divid..

 

Nate! parit", wo"ks

low

 

 

 

 

B bits

onllJ!

 

Angle was in octant. 0.3.4.7.

Test fo" the sign of the r.sult. Tlilo negatives cancel.

0109 OAC4

0108 7A02

0100 D9EO

OIOF

OIOF DEF9

0111 C3

0112

0112 D9EB

0114 EBE9

43.

.37

.3B 43. 440 441 442 443 44'

44'

446

447

44B

•••

4.0

451

452

453

or al,ah

Jpe positive_divide

IIdiv

rot

IIdl

Jmp aftttr _tangent

Angle lIIas in octant. 1.2.5.0.

,Set the correct sign of the result.

JForm r . sult

I Ok to leave fdiv running

J Force 1/0 - tanCP1I2)

0116

0116 OAC4

011B 7A02

011A D9EO

oue

OllC DEF1 ailE C3

454 ••5 456 457 45B 4 •• 460 '61

462

463

464

465

4.6

.4676.

46B

470

reverse_divide:

or

ai, ah

Jpe

positive_r_divide

fdivr

J Form reciprocal oil result

ret

Ok to leave fdiv running

tangent endp

 

This function 111111 normalize the vilh.l. in steOL

,The" PII4 i . placed into . telL

a11F

011F D9El

0121 D9F4

0123 D9EB

0125 DeCl

0127 DEE9

0129 D9FD

0128 DDD9

0120 2EDB2£0000

0132 09C9

0134 C3

471

472

.73 474 475

476-

.4777.

47B

.BO

4Bl

482

4B3

4B4

4B5

normal i ze_value:

fabs fxtract fldl

f.dd ste!), st flub

fscale

flstp stCI)

fld pi_lI.uart." fxch

ret

code .endn. .

IForce value positive

o <- steO) < I

Iget normalize bit

INormali Ztt fraction

Restor. original value

IForm ori91nal normali zed value I Remove scala .pactor

Get PII4

ASSEMBLY COMPLETE.

NO W"'RNINQS.

NO ERRORS

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

4-23

Page 479
Image 479
Intel 80286, 80287 manual 4676