Intel 80286, 80287 manual ii.t

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 467
Image 467

NUMERIC PROGRAMMING EXAMPLES

iAPX286 MACRO ASSEMBLER

LOC OBJ

0007 98

aooa 8S46FA

0000 2DCl

0000 7722

OODF DF46FC 00E2 SaFe!

00E4 BOEAFE aOE7 DB6EFO

OOEA D9FD

aOEe 0001 OOEe D9FC

OOFO 0809

OOFe! 9BDD7EFE 00F6 F146FE0040

00F9 7550

OOFO 0008

DOFF BnOb

0101

80287

Floating-Point to is-Digit ASCII

Conversion

10: 12: 38 0'1'/25/83 PAGE

LINE

SOURCE

 

 

 

32.

i'Li/ait

 

 

Wait for power_ten to be valid

323

mov

,ax,poLlla,,_ten

I

Get powe" of tan of value

3.4

sub

ax, ex

I

Form scaling factor nacaIl5.,,1,1 in ax

32S

J,a

adJust_"luult

 

Jump if number will not fit

326

 

 

 

 

327The number is betwaen 1 ,and 10**<field_lIirel.

328Test if it is an intega".

3 ••

HId

pOLlIa" _ two

 

 

 

 

 

 

330

I Ra .. to"e original number

 

331

mov

II i. d x

 

S.va "eturn valua

 

 

332

.ub

dl. NORMAL-EXACT

I

Conv."t to exact ".tu"n v .. lue

333

fl'

fraction

I

Form

full

value.

this 1s

safe here

334

fscal a

 

33'

'"f"ndint

,t (1)

 

Copy

value

fo" comparl!

 

336

 

J

Tast if its an intege"

 

337

fcomp

 

I

Compa"a values

 

 

338

fstsw

status

J

Save

status

 

 

33'

test

status.4000H

 

C3a 1

implil!S it was an integl!"

340

J"'

c onvl!rt_i ntagar

 

 

 

 

 

 

341

 

 

 

 

 

 

 

 

342

htp

st(Ol

J Remove non integer value

 

343

 

d x. IIi

I

Restore original

return

value

344

 

 

 

 

 

 

 

 

345Sc,ala the number to Ll/ithin the range allowed by the BCD form,at.

346The scaling operation 5hould produce ,a numb.r within one decimal order

347of magnitUde of the largut decim.!ll number repra .. ntabla within the

348given string width.

34.

,

nl! seal ing power of ten value is in u .

350

351

 

352adJu .. t_ruult:

0101 8907

0103 F708

0105 EBOOOO

0108 OD6EFO 010/3 DEC9

0100 813FI

0101=' 01E6 0111 01E6

011:3 0lE6

0115 OF46FC

0118 DEC2

OIIA D9FD

011C 0009

354

moy

33.

no,

306

 

357

call

358

fl'

339

360

fmul

361moY

362'h 1

363'h 1

364.h 1

365Hid

366faddp

367flcale

368htp

word ptr Cbx~ ••u

I

s . t

initial powe" of ten return value

 

 

j Subtract one 'or each order 0'

 

 

J magnitude the vo!!Ilue i!li scaled by

 

 

 

Scaling flactor is returned as uponent

Practlen

 

and

fraction

 

Q"t

.p"action

sit ex

 

Combine

fractions

I

Form pOlller of ten of! the maximum

si.1

j

BCD value to fit in the string

\ii.t

)

Indu

in

s1

si. 1

 

 

 

 

 

power _two

j

Combine

powlfrs of two

st(2). lit

 

Form full value. exponent wall saile

 

 

 

 

 

J

Remove

exponent

011E

011E 2EDC940eoo

0123 9BDFEO

0126 A90041

0129 750C

0129 2EOE360000

0130 BaE2FD 01:33 FF07

0135 E814

0137

0137 2EOC940000

013C 9DDFEO

013F A90001

0142 7401

0144 :2EOEOeOOOO

0149 FFOF

0149

0149 D9FC

0140

0140 OF76FO

0150 13E0800

370Tl!st the adJu.t.d value against a tablli! of t'~act powers of tt!n.

371Til. combined er"or' of thE!' magnitude IIstimatl! and power function ca.,

372ret.ult in a value one ordl'r of! magnitude too small 01" too large to fit

373corrl!ctly in ,the BCD Held. To handle thi!l pT'obhm. pretest the

37.

,

adJUsted valull> if it is too small 01' large. than adJust it by ten and

375

adJust th. powe" of ten value

376

 

377testJower:

37.f!com power_tableCsiJ+type power_table) Compare against exact power

380

 

.,

 

J

entry.

U!ie thf! ne~t entry since cx

381

 

 

J

has been decremented by one

382

fstsw

 

)

No

lIIait

is necessart,!

383

test

ax. 4100H

 

)

If

C3

-

CO .. 0 than too big

38.

J"'

test_fo" _sm,all

 

 

 

 

 

 

38.

 

 

 

 

 

 

 

 

 

386

f:Ldiv

const10

 

 

Elu

adJust

value

387

an'

d 1. not EXACT

 

Rli!mova

axact

fllag

388

in'

word ptr

tb xJ

I

AdJust power of tan value

39.

Jmp

.ho"t; in_ranga

J

Convart the value to a BCD int.g.r

3.,

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

39.

 

 

 

 

 

 

 

 

 

3.3

 

pOWIi!1"_hbhCsiJ

j

Test

relative size

394

 

..

 

 

No

wait

is naca.sart,!

39.

 

1U.IOOH

 

 

If! CO - 0 than st(O) >- low.,. bound

396

 

1n_range

 

I

Conv.rt tha valua to a BCD intager

397

 

 

 

"

 

 

 

 

 

399

Umul

constiO

 

AdJust valu. into range

 

 

39'

dac

LIIo"d pt,.

Cbx~

 

AdJu.t powar of t.n valua

400

 

 

 

 

 

 

 

 

 

401

40.

403flrndint

40SA.... rt: 0 <- TOS <- 999.999.999.999.999.999

406

J

The TOS number will ba ... c:tll,l repraunhble in 19 digit BCD format.

407

,

 

408convart_i nteg.,.:

410

 

411

 

41.

Whih the .to,..e BCD "uns ... etup ragi . tns for the conversion to

413ASCII.

415

 

I Initial BCD index valua

Figure 4-6. Floating-Point to ASCII Conversion Routine (Cont'd.)

4-11

Page 467
Image 467
Intel 80286, 80287 manual ii.t