Subversion Repositories Kolibri OS

Rev

Rev 1075 | Details | Compare with Previous | 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
1075 Galkov 45
OldMask dd      0
703 serge 46
        enddata
47
 
48
 
49
        xdefp   "C",__Init_FPE_handler
50
defp    __Init_FPE_handler
51
        _guess                          ; guess initialization required
52
          cmp   dword ptr Save87,0      ; - quit if already initialized
53
          _quif ne                      ; - ...
54
        _admit                          ; admit: already initialized
55
           ret                          ; - return
56
        _endguess                       ; endguess
57
        push    EAX                     ; save registers
58
        push    EBX                     ; ...
59
        push    ECX                     ; ...
1075 Galkov 60
        push    EDX                     ; ...
61
 
703 serge 62
        mov     EAX, 68
1077 Galkov 63
        mov     EBX, 24
1075 Galkov 64
        mov     EDX, 10000h             ; 1 shl 16 - #MF
703 serge 65
        lea     ECX, __FPE2Handler_
1075 Galkov 66
        int     40h                     ; set new exception handler
703 serge 67
        mov     Save87, EAX             ; save old handler
1075 Galkov 68
        mov     OldMask,EBX             ; save old mask
703 serge 69
 
1075 Galkov 70
        pop     EDX                     ; ...
703 serge 71
        pop     ECX                     ; ...
72
        pop     EBX                     ; ...
73
        pop     EAX                     ; ...
74
        ret                             ; return
75
endproc __Init_FPE_handler
76
 
77
 
78
        xdefp   "C",__Fini_FPE_handler
79
defp    __Fini_FPE_handler
80
        cmp     dword ptr Save87,0      ; if not initialized
81
        _if     e                       ; - then
82
          ret                           ; - return
83
        _endif                          ; endif
84
        push    EAX                     ; save registers
85
        push    EBX                     ; ...
1075 Galkov 86
                                        ; ECX ????
703 serge 87
        push    EDX                     ; ...
88
        sub     ESP,4                   ; allocate space for control word
89
        fstcw   word ptr [ESP]          ; get control word
90
        fwait                           ; ...
91
        mov     byte ptr [ESP],7Fh      ; disable exception interrupts
92
        fldcw   word ptr [ESP]          ; ...
93
        fwait                           ; ...
94
        add     ESP,4                   ; remove temporary
95
 
96
        mov     EAX, 68
1077 Galkov 97
        mov     EBX, 24
1075 Galkov 98
        mov     ECX, dword ptr Save87   ; restore handler
99
        mov     EDX, dword ptr OldMask  ; restore mask
100
        int     40h                     ; set new ecxeption handler
101
 
703 serge 102
        pop     EDX                     ; ...
1075 Galkov 103
                                        ; ECX ????
703 serge 104
        pop     EBX                     ; ...
105
        pop     EAX                     ; ...
106
        ret
107
endproc __Fini_FPE_handler
108
 
109
        endmod
110
        end