Intel 80287, 80286 manual Function. Partitioning

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 470
Image 470

NUMERIC PROGRAMMING EXAMPLES

iAPX2Bb MACRO

ASSEMBLER

Calculate the

value of

10**ax

 

 

 

 

 

12: 11: 08

09/25/83

PAGE

LOC

OBJ

 

 

LINE

SOURCE

 

 

 

 

 

 

 

 

 

 

 

COCA

O'9EO

 

 

5.

 

-Fchs

 

 

 

 

 

 

 

 

 

 

 

ooce

D9Cl

 

 

60

 

n.

st( 1)

I

COPV power value in base two

 

DOCE

D96EFC

 

 

61

 

fIldcw

word ptr [bp-4J

 

Set new control word value

 

 

0001

D9FC

 

 

6 .

 

f'rndint

 

TOS

= I:

-inf

 

< I

<= X.

I

is an int~g~r

0003

8946FC

 

 

63

 

mav

word ptr [bp-4], ax

I

R~5tor~

original

rounding

control

 

0006

D9bEFC

 

 

6'

 

fidew

wOl'd ptr [bp-4J

 

 

 

 

 

 

-1.0. 51(2) '" I

 

0009

D9CA

 

 

65

 

Fxch

st(2)

I

TOS

.. X.

91(U

""

 

DaDa

08E2

 

 

66

 

hub

st, st(2)

 

TOS. F -..

X-I:

a

<..

TOS <

1. a

 

DODD

BB46FE

 

 

67

 

mov

ax, Cbp-2J

 

Restore

power

 

of

ten

 

 

 

OOEO

D9FD

 

 

68

 

flscale

 

 

TOS

... F/2: a

<.. TOS < 0.5

 

 

00E2

D9FO

 

 

6 .

 

f'2xml

 

 

TOS

'" 2**(F/21

-

1. 0

 

 

 

00E4

C9

 

 

70

 

l ... v.

 

I

Restore

stack

 

 

 

 

 

 

ODES

DEE1

 

 

71

 

fsubl'

st. steOl

J

Form

2**(F/2)

 

 

 

 

 

 

OOE7

Dcca

 

 

7 .

 

flmul

 

Form

2**F

 

 

 

 

 

 

00E9

C3

 

 

73

 

rot

 

j

OK to leave fmul running

 

 

 

 

 

 

7 .

get_power _10

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

75

endp

 

 

 

 

 

 

 

 

 

 

 

 

 

 

76

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

77

code

 

ends

 

 

 

 

 

 

 

 

 

 

 

 

 

 

78

 

 

en.

 

 

 

 

 

 

 

 

 

 

A8SEMBL V COMPLETE,

NO

WARNINGS,

NO ERRORS

 

 

 

 

 

 

 

 

 

 

 

iAPX28b MACRO

ASSEMBLER

Det~rmin~ TOS

r~gist~r

cont~nts

 

 

 

 

12: 12: 13

09/25/83

PAGE

SERtES-I11 iAPX28b MACRO ASSEMBLER XI08 ASSEMBLV OF MODULE TOS_STATUS

 

 

 

 

 

 

 

 

 

 

OBJECT MODULE PLACED IN : F3: TOS8T. OBJ

 

 

 

 

 

 

 

 

 

 

 

 

ASSEMBLER INVOKED BV:

ASM28b.86: F3: T09ST. AP2

 

 

 

 

 

 

 

 

 

 

 

LaC OBJ

0000

0000 09E5

0002 9BDFEO

0005 8AC4

0007 250740 OOOA COEC03 0000 OAC4 OOOF B400 0011 C3

LINE SOURCE

1 +1 $title("D~t~rmine TOS register contents")

2

3This subr.outine will return a value from 0-15in AX corres,ponding

4to the contents of 80287 T09. All re!listlH's are transparent and no

5errors are possible The return value corresponds to c3,c2,cl.cO

6of FXAM instruction.

7

 

 

 

 

 

8

 

 

tos_status

 

 

10

 

pub lic

 

 

 

 

 

 

 

11

stack

 

stacks8g 6

) Allocate space on the stack

12

 

13

 

 

 

 

 

I.

code

 

se!lment

pub 1 ic

 

15

 

 

proc

 

 

16

 

 

 

 

17

 

fxam

 

) Get register contents status

18

 

a.

,.

 

fstsw

)

Get status

20

 

mov

OIl. ah

 

Put bit 10-8into bits 2-0

21

 

an.

al,4007h

 

Mask out bits c3,c2.c1.cO

22

 

,hr

ah,3

) Put bit c3 into bit 11

23

 

 

OIl. ah

J Put c3 into bit 3

2.

 

mov

ah.O

I

Clear return value

25ret

27

endp

28

 

 

2.

code

ends

 

30

 

end

ASSEMBLV COMPLETE,

NO WARNINGS,

NO

ERRORS

Fi!!~lrA 4-~~Flnllting-Point to ASCII Conversion Routine (Cont'd.l

Function. Partitioning

Three separate modules implement the conversion. Most of the work of the conversion is done in the module FLOATING_TO_ASCII. The other modules are provided separately, because they have a more general use. One of them, GET_POWER_IO, is also used by the ASCII to floating-point conver- sion routine. The other small module, TOS_STATUS, will identify what, if anything, is in the top of the numeric register stack.

4-14

Page 470
Image 470
Intel 80287, 80286 manual Function. Partitioning