SYSTEM-LEVEL NUMERIC PROGRAMMING

8086/87/88/186 MACRO ASSEMBLER

Test for presence of 8 Nuner;cs Chip, Revision 1.0

PAGE

DOS 3.20 (033·N) 8086/87/88/186 MACRO ASSEMBLER V2.0 ASSEMBLY OF MOOULE TEST_NPX

 

OBJECT MOOULE PLACEO IN FINDNPX.OBJ

 

LOC OBJ

LINE

SOURCE

 

1 +1 Stitle('Test for presence of a Nuner;cs Chip, Revision 1.0 1 )

2

 

 

3

 

name

Test_NPX

 

 

 

 

 

 

 

 

4

 

 

 

 

 

 

 

 

 

 

 

0000

(100

5

stack

segment

stack

 

I stack I

 

 

 

 

 

6

 

dw

100 dup (1)

 

 

 

 

 

 

1??7

 

 

 

 

 

 

 

 

 

 

 

 

 

)

 

 

 

 

 

 

 

 

 

 

 

 

00C8

?171

7

sst

dw

 

 

 

 

 

 

 

 

 

 

 

8

stack

ends

 

 

 

 

 

 

 

 

 

 

 

9

 

 

 

 

 

 

 

 

 

 

 

0000

0000

10

data

segment

publ ie

'datal

 

 

 

 

 

11

t"""

dw

Oh

 

 

 

 

 

 

 

 

 

 

12

data

ends

 

 

 

 

 

 

 

 

 

 

 

13

 

 

 

 

 

 

 

 

 

 

 

 

 

14

dsroup

group

data,

 

stack

 

 

 

 

 

 

 

15

cgroup

group

code

 

 

 

 

 

 

 

 

 

 

16

 

 

 

 

 

 

 

 

 

 

 

 

 

17

code

segment

publ ic

'code'

 

 

 

 

 

 

 

18

 

assune

cs:cgroup, ds:dgroup

 

 

 

 

 

 

19

 

 

 

 

 

 

 

 

 

 

 

0000

 

20

start:

 

 

 

 

 

 

 

 

 

 

 

 

21

 

 

 

 

 

 

 

 

 

 

 

 

 

22

 

Look for

an 8087.

80287.

or 80387 NPX.

 

 

 

 

23

 

Note that we cannot execute \lA1T on 8086/88 if no 8087 is present.

0000

 

24

 

 

 

 

 

 

 

 

 

 

 

 

25

test_npx:

 

 

 

 

 

 

 

 

 

0000 900BE3

26

 

tninit

 

 

 

 

; Must use non-wait form

 

0003

BEOOOO

27

 

moy

si ,offset

dgroup:tefl1J

 

 

 

 

0006 C7045A5A

28

 

mov

word

ptr

[si] ,SASAH ;

Initial ize

tenp to non-zero value

OOOA 90003C

29

 

fnstsw

[si]

 

 

 

; Must use non-wait form of fstsw

 

 

30

 

 

 

 

 

 

It is not necessary to -use a WAIT instruction

0000

803COO

31

 

 

 

 

 

 

after

fnstsw

or fnstew.

00 not use one here.

32

 

cnp

byte

ptr

[si] ,0

; See

if

correct

status with zeroes was read

0010 752A

33

 

jne

no_npx

 

 

; JUTp if not a

val id status

word, meaning no NPX

 

 

34

 

 

 

 

 

 

 

 

 

 

 

 

 

35

 

 

36

 

 

37

 

 

38

0015

8804

39

0017 253Fl0

40

001A

303FOO

41

0010

751D

42

 

 

43

 

 

44

45

46

47

48

Now see if ones can be correctly written from the control word.

fnstcw

[si]

;

Look at the control word; do not use \iAIT form

 

ax, [si]

; Do not use a \iAIT instruction here!

moy

;

See if ones can be written by NPX

and

aX,10lfh

;

See if selected parts of control word look OK

c""

aX,lfh

i

Check that ones and zeroes were correct l y read

jne

no_npx

; Jurp if no NPX ;s installed

Some rn.merics chip h installed. NPX instructions and \iAIT are now safe. See if the NPX·is an 8087, 80287, or 80387.

This code is necessary if a denormal exception handler is used or the new 80387 instructions wi II be used.

001F

9809E8

49

fldl

 

; Must use default control word from fNINIT

0022

9B09EE

50

fld.

 

;

form infinity

0025

9BOEF9

51

fdiv

 

;

8087/287 says +fnf II • inf

0028

9B09CO

52

fld

st

;

Form negative Infinity

0028

9BD9EO

53

fchs

 

;

80387 says +Inf <> • inf

DD2E

9BDED9

54

fconw

 

i

See if they are the same and remove them

0031

9BD03C

55

fstSN

[si]

i

Look at status from FCOMPP

OD34

8B04

56

IIIOY

ax, [sf]

 

 

0036

9E

57

sahf

 

 

See if the infinities matched

0037

7406

58

je

fOAJnd_87_287

;

J"", if 8087/287 is present

 

 

59

 

 

 

 

Figure 3-1. Software Routine to Recognize the 80287

3-3

Page 449
Image 449
Intel 80286, 80287 manual SYSTEM-LEVEL Numeric Programming, Software Routine to Recognize