home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 1.ddi / MWHC.001 / R < prev    next >
Encoding:
Text File  |  1992-12-09  |  3.8 KB  |  153 lines

  1. small_m = 1
  2. mach386 = 1
  3. GOC = 1
  4.     .287
  5.  
  6.     include init.inc
  7.  
  8. _TEXT    segment dword public 'CODE'
  9. _TEXT    ends
  10.  
  11. _DATA    segment dword public 'DATA'
  12.     extrn    _mw8087:word
  13.       extrn   _mwno87:dword
  14.     extrn    _mw387:word
  15.     extrn    _mwemc87:word
  16.     extrn    _mwwind:byte
  17.     extrn    _mwprintnochipmsg:byte
  18. temp    dw    0
  19. fp_init_cw dw 03FFH        ; For initializing 8087/287.
  20. fp_init_cw_emc dw 83FFH       ; For initializing EMC 87.
  21.     ; The 8000 is for testing presence of EMC 87 part.
  22.     public    _mwoops
  23. _mwoops    db    0dh,0ah,'Weitek ABACUS'
  24. msg2    db    ' required, but not present!',0dh,0ah,'$'
  25.  
  26. used    dw    0    ; set if an '87 chip is used
  27.  
  28. _DATA    ends
  29. DGROUP    group    _DATA
  30.     assume    ds:DGROUP
  31.  
  32. _TEXT    segment dword public 'CODE'
  33. CGROUP  group    _TEXT
  34.         assume cs:CGROUP
  35. ;-------------------------------------------------------------------------------
  36. ; init_87()
  37. ;-------------------------------------------------------------------------------
  38.     ; Deal with 8087/287
  39.     ; Discover whether 8087/287 exists unless no8087 has been set.
  40.  
  41. _mwinit_87 proc
  42.     mov    ecx,offset ds:fp_init_cw
  43.     public    _mwinit_87
  44.     jmp    short begin
  45. _mwinit_87u:
  46.     public    _mwinit_87u
  47.     mov    ecx,offset ds:_mw8087
  48.      mov    used,1
  49.     jmp    short begin
  50. _mwinit_387u:
  51.     public    _mwinit_387u
  52.     mov    ecx,offset ds:_mw387
  53.      mov    used,1
  54.     jmp    short begin
  55. _mwinit_emc87u:
  56.     public    _mwinit_emc87u
  57.     mov    ecx,offset ds:_mwemc87
  58. begin:
  59.     prolog
  60.     mov    edx,ecx
  61.  
  62. ifdef   no87
  63.     mov     byte ptr _mw8087,0
  64. else
  65.     ; Initialize floating point:  check for existence of 8087/287.
  66.     ; We have to do this here so that we can avoid printing out the contents
  67.     ; of NO87 if the machine doesn't have an 8087.
  68.  
  69.     fninit                  ; Initialize 8087 if one exists
  70.     xor     eax,eax         ; Initialize 8087 flag to zero.
  71.     mov     temp,ax
  72.     sub     ecx,ecx         ; One byte shorter than mov ecx,15.
  73.     mov     cl,15
  74. ;    mov     ecx,15          ; Set ch := 0 on first try.
  75. waste1: loop    waste1
  76.     fnstcw  temp            ; Store cntl word
  77.  
  78.     ; We used to just test for non-zero on 8087 systems; but that
  79.     ; didn't work for 287s.  Even if no 287, IBM ATs returned
  80.     ; garbage as the control word.
  81.     mov     cl,15
  82. waste2: loop    waste2
  83.     and     temp,00f3fh
  84.     cmp     temp,0033fh     ; Processor status after initialization.
  85.     jne     short no_8087
  86.     fnstsw  temp
  87.     mov     cl,15
  88. waste3: loop    waste3
  89.     test    temp,0b8bfh
  90.     jnz     short no_8087
  91.     fldcw    fp_init_cw_emc    ;load control word
  92.     ; EMC 87 will leave on the upper bit in the control word:
  93.     fstcw    temp
  94.     test    byte ptr temp+1,80h    ; EMC part there?
  95.     jz    short not_EMC
  96.     mov    byte ptr _mw387,1    ; EMC also looks like a 387.
  97.     ; We load the normal control word in case someone else stores
  98.     ; it and expects the top bit to be off.
  99.     fldcw    fp_init_cw        ;load normal control word
  100.     mov    byte ptr _mwemc87,1    ;Say that it's present.
  101.     ; Now fall through to the code that will determine it's also a 387 clone.
  102. not_EMC:
  103.     mov    byte ptr _mw8087,1 ;Set to TRUE unless he requested to ignore the chip.
  104.     fld1
  105.     fldz
  106.     fdiv            ; get infinity
  107.     fld     st          ; Duplicate TOS.
  108.     fchs
  109.     fcompp          ; compare negative infinity with infinity.
  110.     fstsw   ax
  111.     fwait
  112.     sahf
  113.     je      short no_8087    ; 387 says -inf <> +inf.
  114.                 ; 87/287 says they're equal.
  115.     mov     byte ptr _mw387,1
  116. no_8087:
  117.     ; over-ride findings if NO87 is set
  118.       mov    eax,_mwno87
  119.      or     eax,eax
  120.      jz    next
  121.      mov    byte ptr [edx],0
  122. next:
  123.     cmp    byte ptr [edx],0
  124.     jnz    aok            ; chip present
  125.     cmp    used,0
  126.     jz      aok            ; no chip, but not used
  127.  
  128. nochip:
  129.     cmp    _mwwind,1
  130.     jne    doserr
  131.     mov    _mwprintnochipmsg,1
  132.     jmp    short aok
  133.  
  134. doserr:
  135.     inc    edx
  136.     inc    edx
  137.     mov    ah,9    ;display chip name.
  138.     call    _mwint21
  139.     mov    edx,offset msg2
  140.     mov    ah,9    ;chip is required, but is not present in this machine.
  141.     call    _mwint21
  142.     extrnf    exit
  143.     call    exit
  144.  
  145. aok:
  146. endif
  147.  
  148.     epilog
  149. _mwinit_87    endp
  150.  
  151. _TEXT    ends
  152.     end
  153.