Intel 80287, 80286 manual 4BB

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 468
Image 468

NUMERIC PROGRAMMING EXAMPLES

iAPX286 MACRO ASSEMBLER

LOC ODJ

0153 B9040F

0156 BBOI00

0159 BD7EOC

DISC BCDS

015E eEeD

0160 Fe

0161 B02B

0163 F6(:201

0166 7402

0168 802D

016A

016A AA

0168 BOE2FE

016E 98

016F

016F BA62FO

0172 BAC4

0174 D2EB

0176 22C5

0178 7516

017A BAC4

al7e 22C5 017E 7518

0180 4E

0181 79EC

0183 0030

0185 AA

01B6 43

0187 EU6

0189

0189 BA62FO alBC 8AC4 018E 02E8

0190

0190 0430

0192 AA

0193 BAC4

0195 22C5

0197 43

80287

Floatlnll-Paint to IS-Digit ASCII Conve,.si!)"

 

 

10: 12: 38

09/25/83 PAQE

LINE

SOURCE

 

 

 

 

 

 

 

 

 

 

 

 

416

 

 

 

cx.Of04h

 

I

Set

shift count .nd mlillsk

 

417

 

 

 

bll,l

 

 

S. t initial sin of ASCII . hld for aign

418

 

 

 

di. ~trinIlJt,.

 

 

Get .. ddre .. of start of ASCII string

419

 

 

 

ax. ds

 

I

CoPu

ds

to es

 

 

 

4.0

 

mov

 

 

 

 

 

 

 

 

 

 

421

 

cld

.. I, '+'

 

 

Set .. utoinere.ent mode

 

4.2

 

mov

 

I C ....r sign fhld

 

 

423

 

tnt

dl.I1INUS

 

 

Look 'or ne.ative v .. lue

 

424

 

JI

positive_result

 

 

 

 

 

 

 

 

4••

 

 

 

 

 

 

 

 

 

 

 

 

 

426

 

 

 

al. ' - '

 

 

 

 

 

 

 

 

4.7

posi tive_resul t:

 

 

 

 

 

 

 

 

 

 

4.B

 

 

 

 

 

 

 

 

 

 

429

 

 

 

 

 

 

 

 

 

 

 

 

 

430

 

stosb

 

 

 

I

Bump

string pointer past

sign

431

 

.and

dl. not MINUS

 

I

Turn

off

sign

bit

 

 

43.

 

flilait

 

 

 

I

W,.it

for

fbstp

to

finish

 

433

 

 

 

 

 

 

 

 

 

 

 

 

 

434

 

 

 

 

 

 

 

 

 

 

 

 

 

4,.

 

 

 

 

 

ah:

BCD byte value in use

 

430

 

 

 

 

 

al:

ASCII

character

v.alue

 

437

 

 

 

 

 

dx:

Return

value

 

 

 

438

 

 

 

 

 

eh:

BCD mask. Ofh

 

 

 

439

 

 

 

 

 

c1:

BCD shift count . 4

 

 

440

 

 

 

 

 

bx:

ASCII

string field

width

 

441

 

 

 

 

 

si:

BCD field

index

 

 

 

44.

 

 

 

 

 

di:

ASCII

strihg field

pointer

 

443

 

 

 

 

 

ds •• s:

ASCII string segment ba.e

 

444

,

 

 

 

 

 

 

 

 

 

 

 

 

44.

 

Remove

leading

from the

 

number.

 

 

 

 

440

 

 

 

 

 

 

 

 

 

 

 

 

447sk ip_l e .. di ng_1 erolt.:

449

mo.

ah. bed_buteCsil

I

get

BCD

byte

 

••0

a!. ah

 

Cop"

value

 

451

.hr

0111.

cl

I

Get

high

ordar

digit

4 2

and

0111.

eh

I

Set

lero

flag

 

4""

JU

enter _odd

 

Exit loop if leading non ze1'O found

4'4

 

 

 

 

 

 

 

 

...

mo.

0111. ah

 

Get

BCD bute again

..0

and

al, eh

 

Get

low

order

digit

457

JU

ente1' _even

 

Exit loop if non IBro digit found

458

 

 

 

 

 

 

 

 

459

dec

5i

 

I

Decrlment BCD

indu

400

Jno

skip_lead ing_IB1'oes

 

 

 

 

 

401

 

 

 

 

 

 

 

 

40.

The

significand lIIas all

 

 

 

 

 

40'

 

 

 

 

 

 

 

 

40.

mov

al. '0'

I

Set

initial

 

'05

stosb

 

 

 

 

 

 

 

400

inc

bx

 

 

Bump

st1'ing length

407Jmp short exit_1II1th_value

46B

469NOIII elpand the BCD stTing into digit per byte values 0-9 .

• 70

.71.

 

 

 

 

 

 

mo.

ah. bcd_byte[siJ

Get

BCD

tU,Ite

47'

474

mov

0111. ah

get

 

 

'75

'hr

0111. cl

high

order digit

.70

 

 

 

 

 

 

'77

enter _odd:

 

 

 

 

.7B

add

 

, Convert

 

.79

al. '0'

to ASCII

'BO

stosb

 

Put digit into ASCII string

481

mo.

0111. ah

Get 10. order digit

4B.

and

al, ch

 

 

 

4B,

inc

b,

Dump

field size counte"

4B4

 

 

 

 

 

 

0198

 

4B5

0198

0430

.80

4B7

Ol9A

AA

4BB

0198

43

489

019C

4E

490

019D

79EA

491

 

 

49.

 

 

49'

 

 

494

019F

 

495

019F BB7EaA

496

497

01A2

891D

49B

VIA.. aa\..,:

..;r;;

01A6 E9BOFE

500

 

 

001

 

 

50.

 

 

50'

 

 

504

ASSEMIILY··COMPLETE.

NO ·WARNINGS.

enter _even:

 

 

 

 

 

add

011. '0'

Convert to

ASCII

stosb

b,

Put digit

into

ASCI I area

inc

Dump

field

size

counter

dec

.,

00 to

next

DCD

byte

In.

digit_loop

 

 

 

 

,Conversion complete. Set the string size IillJld remainder. ex it_lilith_value:

 

6i . slzeJtr

 

lIIoT'd ptr [dil, bx

 

.."'.;,,

Jmp

ex i tJroc

floating_to_... ciiendp

codeends end

NO ERRORS

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

4-12

Page 468
Image 468
Intel 80287, 80286 manual 4BB