Subversion Repositories Kolibri OS

Rev

Rev 1075 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
703 serge 1
;*****************************************************************************
2
;*
3
;*                            Open Watcom Project
4
;*
5
;*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
6
;*
7
;*  ========================================================================
8
;*
9
;*    This file contains Original Code and/or Modifications of Original
10
;*    Code as defined in and that are subject to the Sybase Open Watcom
11
;*    Public License version 1.0 (the 'License'). You may not use this file
12
;*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
13
;*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
14
;*    provided with the Original Code and Modifications, and is also
15
;*    available at www.sybase.com/developer/opensource.
16
;*
17
;*    The Original Code and all software distributed under the License are
18
;*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
19
;*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
20
;*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
21
;*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
22
;*    NON-INFRINGEMENT. Please see the License for the specific language
23
;*    governing rights and limitations under the License.
24
;*
25
;*  ========================================================================
26
;*
27
;* Description:  Connect/disconnect 80x87 interrupt handler.
28
;*
29
;*****************************************************************************
30
 
31
 
32
.8087
33
.386p
34
 
35
include struct.inc
36
include mdef.inc
37
 
38
        xref            __FPE2Handler_
39
 
40
        modstart        fpe387
41
 
42
        datasegment
43
 
44
Save87  dd      0
45
        enddata
46
 
47
 
48
        xdefp   "C",__Init_FPE_handler
49
defp    __Init_FPE_handler
50
        _guess                          ; guess initialization required
51
          cmp   dword ptr Save87,0      ; - quit if already initialized
52
          _quif ne                      ; - ...
53
        _admit                          ; admit: already initialized
54
           ret                          ; - return
55
        _endguess                       ; endguess
56
        push    EAX                     ; save registers
57
        push    EBX                     ; ...
58
        push    ECX                     ; ...
59
 
60
        mov     EAX, 68
61
        mov     EBX, 15
62
        lea     ECX, __FPE2Handler_
63
        int     40h                     ; set new #FPE handler
64
        mov     Save87, EAX             ; save old handler
65
 
66
        pop     ECX                     ; ...
67
        pop     EBX                     ; ...
68
        pop     EAX                     ; ...
69
        ret                             ; return
70
endproc __Init_FPE_handler
71
 
72
 
73
        xdefp   "C",__Fini_FPE_handler
74
defp    __Fini_FPE_handler
75
        cmp     dword ptr Save87,0      ; if not initialized
76
        _if     e                       ; - then
77
          ret                           ; - return
78
        _endif                          ; endif
79
        push    EAX                     ; save registers
80
        push    EBX                     ; ...
81
        push    EDX                     ; ...
82
        sub     ESP,4                   ; allocate space for control word
83
        fstcw   word ptr [ESP]          ; get control word
84
        fwait                           ; ...
85
        mov     byte ptr [ESP],7Fh      ; disable exception interrupts
86
        fldcw   word ptr [ESP]          ; ...
87
        fwait                           ; ...
88
        add     ESP,4                   ; remove temporary
89
 
90
        mov     EAX, 68
91
        mov     EBX, 15
92
        mov     ECX, dword ptr Save87
93
        int     40h                     ; set new #FPE handler
94
 
95
        pop     EDX                     ; ...
96
        pop     EBX                     ; ...
97
        pop     EAX                     ; ...
98
        ret
99
endproc __Fini_FPE_handler
100
 
101
        endmod
102
        end