Subversion Repositories Kolibri OS

Rev

Rev 702 | Rev 1075 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 702 Rev 703
Line 38... Line 38...
38
include mdef.inc
38
include mdef.inc
39
include stword.inc
39
include stword.inc
40
include env387.inc
40
include env387.inc
41
include fstatus.inc
41
include fstatus.inc
Line 42... Line -...
42
 
-
 
43
ifndef  __NETWARE__
-
 
44
        xref            __GETDS
-
 
45
endif
42
 
Line 46... Line 43...
46
        xref            __8087  ; indicate that NDP instructions are present
43
        xref            __8087  ; indicate that NDP instructions are present
Line 47... Line 44...
47
 
44
 
Line 53... Line 50...
53
        extrn   "C",_STACKLOW   : dword
50
        extrn   "C",_STACKLOW   : dword
Line 54... Line 51...
54
 
51
 
55
TInf    db 00h,00h,00h,00h,00h,00h,00h,80h,0ffh,7fh
52
TInf    db 00h,00h,00h,00h,00h,00h,00h,80h,0ffh,7fh
56
F8Inf   db 0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0efh,7fh
53
F8Inf   db 0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0efh,7fh
57
F4Inf   db 0ffh,0ffh,7fh,7fh
-
 
58
        db      512 dup(0)
-
 
59
FPEStk  label byte
-
 
60
SaveSS  dw      0
-
 
61
SaveESP dd      0
54
F4Inf   db 0ffh,0ffh,7fh,7fh
Line 62... Line -...
62
        enddata
-
 
63
 
55
        enddata
Line 64... Line 56...
64
 
56
 
65
; Interrupt handler for 80x87 exceptions.
57
; User handler for 80x87 exceptions.
66
 
-
 
67
xdefp   __FPEHandler_
-
 
68
defp    __FPEHandler_
-
 
69
public "C",__FPEHandlerStart_
-
 
70
__FPEHandlerStart_ label byte
-
 
71
        push    EAX                     ; save reg
-
 
72
        mov     AL,20h                  ; issue EOI to 8259 controller
-
 
73
        out     20h,AL                  ; ...
-
 
74
        out     0a0h,AL                 ; issue EOI to slave 8259
-
 
-
 
58
 
75
        xor     AX,AX                   ; clear busy signal
59
xdefp   __FPEHandler_
76
        out     0f0h,AL                 ; ...
60
defp    __FPEHandler_
-
 
61
 
77
        pop     EAX                     ; restore regs
62
public  __FPE2Handler_
78
public  __FPE2Handler_
63
__FPE2Handler_ label byte 
79
__FPE2Handler_ label byte
64
 
80
        push    EAX                     ; save regs
65
        push    EAX                     ; save regs
81
        push    EBX                     ; ...
66
        push    EBX                     ; ...
82
        push    ECX                     ; ...
67
        push    ECX                     ; ...
83
        push    EDX                     ; ...
68
        push    EDX                     ; ...
84
        push    ESI                     ; ...
-
 
85
        push    EDI                     ; ...
-
 
86
        push    EBP                     ; ...
69
        push    ESI                     ; ...
87
        push    DS                      ; ...
70
        push    EDI                     ; ...
88
        push    ES                      ; ...
71
        push    EBP                     ; ...
89
        sub     ESP,ENV_SIZE            ; make room for environment information
72
        sub     ESP,ENV_SIZE            ; make room for environment information
90
        mov     EBP,ESP                 ; point to buffer for 80x87 environment
-
 
91
        fnstenv [EBP]                   ; get 80x87 environment
-
 
92
        fwait                           ; wait for 80x87
-
 
93
        fdisi                           ; disable interrupts
-
 
94
        sti                             ; enable CPU interrupts
-
 
95
ifndef  __NETWARE__
-
 
96
     ;   call    __GETDS                 ; load DS
-
 
97
endif
-
 
98
ifdef __NETWARE__
-
 
99
      ;  push    SS                      ; load DS
73
        mov     EBP,ESP                 ; point to buffer for 80x87 environment
100
      ;  pop     DS                      ; ...
74
        fnstenv [EBP]                   ; get 80x87 environment
101
endif
75
        fwait                           ; wait for 80x87
102
        mov     EDX,ENV_CW[EBP]         ; get control word
76
        mov     EDX,ENV_CW[EBP]         ; get control word
103
        not     EDX                     ; flip the mask bits
-
 
104
        mov     DH,0FFh                 ; turn on top byte
77
        not     EDX                     ; flip the mask bits
-
 
78
        mov     DH,0FFh                 ; turn on top byte
105
        and     EDX,ENV_SW[EBP]         ; get status word
79
        and     EDX,ENV_SW[EBP]         ; get status word
106
      ;  mov     ES,ENV_IP+4[EBP]        ; get intruction address
80
        mov     EDI,ENV_IP[EBP]         ; ...
107
        mov     EDI,ENV_IP[EBP]         ; ...
81
opcode:
108
opcode: mov     BX,[EDI]                ; get opcode
82
        mov     BX,[EDI]                ; get opcode
109
        inc     EDI                     ; point to next opcode
83
        inc     EDI                     ; point to next opcode
110
        cmp     BL,0d8h                 ; check if its the opcode
84
        cmp     BL,0d8h                 ; check if its the opcode
111
        jb      opcode                  ; ...
-
 
112
        cmp     BL,0dfh                 ; ...
85
        jb      opcode                  ; ...
113
        ja      opcode                  ; ...
86
        cmp     BL,0dfh                 ; ...
114
      ;  mov     ES,ENV_OP+4[EBP]        ; get pointer to operand
87
        ja      opcode                  ; ...
115
        mov     EDI,ENV_OP[EBP]         ; ...
88
        mov     EDI,ENV_OP[EBP]         ; ...
116
        xchg    BL,BH                   ; get opcode in right position
89
        xchg    BL,BH                   ; get opcode in right position
Line 152... Line 125...
152
          mov   CL,FPE_ZERODIVIDE       ; - indicate divide by zero
125
          mov   CL,FPE_ZERODIVIDE       ; - indicate divide by zero
153
        _endguess                       ; endguess
126
        _endguess                       ; endguess
154
        _guess                          ; guess exception to be handled
127
        _guess                          ; guess exception to be handled
155
          cmp   CL,FPE_OK               ; - check if exception allowed
128
          cmp   CL,FPE_OK               ; - check if exception allowed
156
          _quif e                       ; - quit if exception not allowed
129
          _quif e                       ; - quit if exception not allowed
157
;         cmp   SaveSS,0                ; - check if already in handler
-
 
158
;         _quif ne                      ; - quit if already in handler
-
 
159
          push  _STACKLOW               ; - save old stack low
-
 
160
          mov   SaveSS,SS               ; - save current stack pointer
-
 
161
          mov   SaveESP,ESP             ; - ...
-
 
162
          push  DS                      ; - get new stack pointer
-
 
163
          pop   SS                      ; - ...
-
 
164
          lea   ESP,FPEStk              ; - ...
-
 
165
          lea   EAX,FPEStk-512          ; - set stack low variable
-
 
166
          mov   _STACKLOW,EAX           ; - set stack low variable
-
 
167
          movzx EAX,CL                  ; - set floating point status
130
          movzx EAX,CL                  ; - set floating point status
168
          call  __FPE_exception_        ; - call user's handler
131
          call  __FPE_exception_        ; - call user's handler
169
          mov   SS,SaveSS               ; - restore stack pointer
-
 
170
          mov   ESP,SaveESP             ; - ...
-
 
171
          pop   _STACKLOW               ; - restore old stacklow
-
 
172
          mov   SaveSS,0                ; - indicate handler can be re-entered
-
 
173
        _endguess                       ; endguess
132
        _endguess                       ; endguess
174
        fclex                           ; clear exceptions that may have
133
        fclex                           ; clear exceptions that may have
175
                                        ; occurred as a result of handling the
134
                                        ; occurred as a result of handling the
176
                                        ; exception
135
                                        ; exception
177
        and     word ptr ENV_CW[EBP],0FF72h
136
        and     word ptr ENV_CW[EBP],0FF72h
178
        fldcw   word ptr ENV_CW[EBP]    ; enable interrupts
137
        fldcw   word ptr ENV_CW[EBP]    ; enable interrupts
179
        fwait                           ; ...
138
        fwait                           ; ...
180
        add     ESP,ENV_SIZE            ; clean up stack
139
        add     ESP,ENV_SIZE            ; clean up stack
181
        pop     ES                      ; restore registers
-
 
182
        pop     DS                      ; ...
-
 
183
        pop     EBP                     ; ...
140
        pop     EBP                     ; ...
184
        pop     EDI                     ; ...
141
        pop     EDI                     ; ...
185
        pop     ESI                     ; ...
142
        pop     ESI                     ; ...
186
        pop     EDX                     ; ...
143
        pop     EDX                     ; ...
187
        pop     ECX                     ; ...
144
        pop     ECX                     ; ...
188
        pop     EBX                     ; ...
145
        pop     EBX                     ; ...
189
        pop     EAX                     ; ...
146
        pop     EAX                     ; ...
190
        iretd                           ; return from interrupt handler
147
        ret                             ; return from interrupt handler
191
public  "C",__FPEHandlerEnd_
-
 
192
__FPEHandlerEnd_ label byte
-
 
193
endproc __FPEHandler_
-
 
Line -... Line 148...
-
 
148
 
Line 194... Line 149...
194
 
149
endproc __FPEHandler_
Line 195... Line 150...
195
 
150
 
196
; Process invalid operation.
151
; Process invalid operation.
Line 361... Line 316...
361
; Store the top element of the stack at ES:EDI.
316
; Store the top element of the stack at ES:EDI.
Line 362... Line 317...
362
 
317
 
363
Store   proc    near
318
Store   proc    near
364
        test    BH,04h
319
        test    BH,04h
365
        _if     ne                      ; if double
320
        _if     ne                      ; if double
366
          fst   qword ptr ES:[EDI]      ; - store as double precision result
321
          fst   qword ptr [EDI]         ; - store as double precision result
367
        _else                           ; else
322
        _else                           ; else
368
          fst   dword ptr ES:[EDI]      ; - store as single precision result
323
          fst   dword ptr [EDI]         ; - store as single precision result
369
        _endif                          ; endif
324
        _endif                          ; endif
370
        ret                             ; return
325
        ret                             ; return
Line 371... Line 326...
371
endproc Store
326
endproc Store