Subversion Repositories Kolibri OS

Rev

Rev 703 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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