Intel 80287, 80286 manual Coce

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 478
Image 478

NUMERIC PROGRAMMING EXAMPLES

iAPX2B6 MACRO ASSEMBLER

80287 Trignometric Functions

10: 13: 51 09/25/83 PI\QE

LOC DB'"

LINE

SOURCE

 

301least three signUieant bits of an extended T'eal format number, The

302PLM/S6 c.alling fOTmat is:

 

 

303

tangent:

proceduT'1!

Cangle)

1'8al

external;

 

 

 

 

 

 

 

 

304

 

 

 

 

 

 

 

 

30S

 

 

declare

angle

reall

 

 

 

 

 

 

 

 

 

 

 

306

 

 

end

tangentl

 

 

 

 

 

 

 

 

 

 

 

 

 

 

307

 

TIIIO

stack

registers

are

used.

The

re5ult of

the

tangent

function is

 

 

308

 

 

 

30.

defined for the follollling cases:

 

 

 

 

 

 

 

 

 

 

310

 

 

 

 

 

 

 

angle

 

 

 

 

 

 

Tll'sult

 

 

 

311

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

31'

 

 

 

 

 

 

 

 

< 2**62

 

 

 

 

 

correct

value

 

 

313

 

 

vali.d 01'

unnormal

in

magnitude

 

 

 

 

314

 

 

o

 

 

 

 

 

 

 

 

 

 

 

 

 

o

 

 

 

 

31S

 

 

denol'mal

 

 

 

> 2**b2

 

 

 

 

 

correct

denormal

 

 

316

 

 

valid Dr

unnormal

in

magnitude

 

 

indefinite

 

 

317

 

 

NAN

 

 

 

 

 

 

 

 

 

 

 

 

NAN

 

 

 

 

318

 

 

infinity

 

 

 

 

 

 

 

 

 

 

 

indefinite

 

 

31'

 

 

empty

 

 

 

 

 

 

 

 

 

 

 

Itmptl,!

 

 

 

320

 

The tangent in.tt'uction uses the

fptan

instruction.

Four

possible

 

 

321

 

 

 

32.

relations

are used:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

323

 

l..et

R a

langle

HOD PI/41

 

 

 

 

 

 

 

 

 

 

 

 

 

324

 

 

 

 

 

 

 

 

 

 

 

 

 

 

32.

 

 

B ...

- lor

1

depend ing

the

sign of the

angle

 

 

 

 

 

3.6

1 l teneR)

 

 

 

tan1PI/4-Rl

 

l/tanlR)

 

l/tanCPI/4-R)

 

 

327

 

 

2)

3)

4)

 

 

328

 

The fo1101111"g table is used to decide which relation to use depending

 

 

32.

 

 

 

330

on in IIIhich octant the angle fell.

 

 

 

 

 

 

 

 

 

 

331

octant

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

332

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

333

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

334

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

335

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

336

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

337

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

338

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

33.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

340

,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

341

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

34.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OOBD

 

343

tangent proc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

344

fxam

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OOBD

D9E5

34S

 

 

 

 

 

 

 

 

 

 

 

l.ook

at

tfie

parameter

 

DOOF

9BDFEO

346

fstslll

ax

 

 

 

 

 

 

 

 

 

 

get

ham

.tatus

 

 

OOC:;!:

2EDB2EOOOO

347

fld

pi_Cl.uilrte,.

 

 

 

 

 

 

I

get

PI/4

 

 

 

 

OOC7

9E

348

sahf

 

 

 

 

 

 

 

 

 

 

I

CF = co.

PF"'C2.

ZF"'C3

OOCS

72CO

34'

JC

funn\lJilrameter

 

 

 

 

 

 

 

 

 

 

 

 

 

350

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

351

 

 

 

 

 

 

 

 

 

 

 

or

denol'mal.

 

 

 

 

 

 

352

fxch

 

 

 

 

 

 

 

 

 

 

I

steO) ... angle. stll)

... PI/4

·OOCA D9CQ

353

 

 

 

 

 

 

 

 

 

 

coce

7i117

354

JPe

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

355

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

356Angle is either an normal 01' denormal.

357Reduce the angle to the range -PI/4 < result < PI/4.

358If fprem cannot perform this operation in one try. the magnitude of the

35.

angle must be ) 2**b2. Such an angle is so large that an\! rounding

360errors could make a verI,! large difference in the reduced angle.

361It ls safest to call tllis verl,l rare case an et'ror.

36.

aOCE

 

363

 

 

 

 

 

 

 

 

 

 

364

fprem

 

Quotient

in CO. C3. Cl

 

DOCE

D9FB

365

 

 

 

 

366

xchg

ax. bx

 

Convert

denormals

into unnormals

0000

93

367

 

Quotient

identifies

octant

0001

9BDFEO

368

fstsbl

 

I

 

 

36.

xchg

ax. bx

 

original

angle fell

into

OOD4

93

370

 

Test

for

complete

reduction

0005 F6C704

371

test

bh, highlmask

cond2)

OODS 7S0D

372

Jnz

angle_tao_big

I

Exit

if

angle bias

too big

373

374See if the angle must be reversed.

376Assert: -PI/4 < steO) < PI/4

OODA

D9El

378

 

fabs

 

 

I 0 <= stlO) < P1I4

 

 

37.

 

 

 

 

 

C3 In bl has the sign flag

CODe

F6C702

380

 

test

bh. highlmask condl)

I

must be revet-sed

OODF

740E

381

 

J'

no_tan_reverse

 

 

 

 

 

38.

 

Angle

fell

in octants 1.3.5.7.

Neverse

It, sUO'li'ratl; ii. i"um ~:;,;..;.

 

 

383

 

OOEI

DEE9

380

 

fsub

 

 

I

Reverse

angle

385

 

 

 

OOE3 EBIS

386

 

Jmp

short

do_tangent

 

 

 

 

 

387

,

Angle is either zero or an unnormal.

 

 

 

 

388

 

 

 

 

38.

 

 

 

 

 

 

ODES

 

3.0

tan_zero_unnormal:

 

 

 

 

ODE' DDD9

3"

 

 

stll)

 

;

Remove

PI/4

392

 

 

 

OOE7

7405

3.3

 

 

 

 

 

 

 

 

 

3"

 

Angle

is an

unnormal.

 

 

 

 

 

3.5

 

 

 

 

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

4-22

Page 478
Image 478
Intel 80287, 80286 manual Coce