home *** CD-ROM | disk | FTP | other *** search
- small_m = 1
- mach386 = 1
- GOC = 1
- .287
-
- include init.inc
-
- _TEXT segment dword public 'CODE'
- _TEXT ends
-
- _DATA segment dword public 'DATA'
- extrn _mw8087:word
- extrn _mwno87:dword
- extrn _mw387:word
- extrn _mwemc87:word
- extrn _mwwind:byte
- extrn _mwprintnochipmsg:byte
- temp dw 0
- fp_init_cw dw 03FFH ; For initializing 8087/287.
- fp_init_cw_emc dw 83FFH ; For initializing EMC 87.
- ; The 8000 is for testing presence of EMC 87 part.
- public _mwoops
- _mwoops db 0dh,0ah,'Weitek ABACUS'
- msg2 db ' required, but not present!',0dh,0ah,'$'
-
- used dw 0 ; set if an '87 chip is used
-
- _DATA ends
- DGROUP group _DATA
- assume ds:DGROUP
-
- _TEXT segment dword public 'CODE'
- CGROUP group _TEXT
- assume cs:CGROUP
- ;-------------------------------------------------------------------------------
- ; init_87()
- ;-------------------------------------------------------------------------------
- ; Deal with 8087/287
- ; Discover whether 8087/287 exists unless no8087 has been set.
-
- _mwinit_87 proc
- mov ecx,offset ds:fp_init_cw
- public _mwinit_87
- jmp short begin
- _mwinit_87u:
- public _mwinit_87u
- mov ecx,offset ds:_mw8087
- mov used,1
- jmp short begin
- _mwinit_387u:
- public _mwinit_387u
- mov ecx,offset ds:_mw387
- mov used,1
- jmp short begin
- _mwinit_emc87u:
- public _mwinit_emc87u
- mov ecx,offset ds:_mwemc87
- begin:
- prolog
- mov edx,ecx
-
- ifdef no87
- mov byte ptr _mw8087,0
- else
- ; Initialize floating point: check for existence of 8087/287.
- ; We have to do this here so that we can avoid printing out the contents
- ; of NO87 if the machine doesn't have an 8087.
-
- fninit ; Initialize 8087 if one exists
- xor eax,eax ; Initialize 8087 flag to zero.
- mov temp,ax
- sub ecx,ecx ; One byte shorter than mov ecx,15.
- mov cl,15
- ; mov ecx,15 ; Set ch := 0 on first try.
- waste1: loop waste1
- fnstcw temp ; Store cntl word
-
- ; We used to just test for non-zero on 8087 systems; but that
- ; didn't work for 287s. Even if no 287, IBM ATs returned
- ; garbage as the control word.
- mov cl,15
- waste2: loop waste2
- and temp,00f3fh
- cmp temp,0033fh ; Processor status after initialization.
- jne short no_8087
- fnstsw temp
- mov cl,15
- waste3: loop waste3
- test temp,0b8bfh
- jnz short no_8087
- fldcw fp_init_cw_emc ;load control word
- ; EMC 87 will leave on the upper bit in the control word:
- fstcw temp
- test byte ptr temp+1,80h ; EMC part there?
- jz short not_EMC
- mov byte ptr _mw387,1 ; EMC also looks like a 387.
- ; We load the normal control word in case someone else stores
- ; it and expects the top bit to be off.
- fldcw fp_init_cw ;load normal control word
- mov byte ptr _mwemc87,1 ;Say that it's present.
- ; Now fall through to the code that will determine it's also a 387 clone.
- not_EMC:
- mov byte ptr _mw8087,1 ;Set to TRUE unless he requested to ignore the chip.
- fld1
- fldz
- fdiv ; get infinity
- fld st ; Duplicate TOS.
- fchs
- fcompp ; compare negative infinity with infinity.
- fstsw ax
- fwait
- sahf
- je short no_8087 ; 387 says -inf <> +inf.
- ; 87/287 says they're equal.
- mov byte ptr _mw387,1
- no_8087:
- ; over-ride findings if NO87 is set
- mov eax,_mwno87
- or eax,eax
- jz next
- mov byte ptr [edx],0
- next:
- cmp byte ptr [edx],0
- jnz aok ; chip present
- cmp used,0
- jz aok ; no chip, but not used
-
- nochip:
- cmp _mwwind,1
- jne doserr
- mov _mwprintnochipmsg,1
- jmp short aok
-
- doserr:
- inc edx
- inc edx
- mov ah,9 ;display chip name.
- call _mwint21
- mov edx,offset msg2
- mov ah,9 ;chip is required, but is not present in this machine.
- call _mwint21
- extrnf exit
- call exit
-
- aok:
- endif
-
- epilog
- _mwinit_87 endp
-
- _TEXT ends
- end
-