add fstatus.inc
git-svn-id: svn://kolibrios.org@702 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
275695e8c3
commit
616f769298
@ -4,8 +4,8 @@ projectIdent
|
||||
VpeMain
|
||||
1
|
||||
WRect
|
||||
32
|
||||
460
|
||||
-32
|
||||
330
|
||||
10304
|
||||
9950
|
||||
2
|
||||
@ -32,8 +32,8 @@ WVList
|
||||
VComponent
|
||||
9
|
||||
WRect
|
||||
2496
|
||||
30
|
||||
3384
|
||||
580
|
||||
5712
|
||||
7390
|
||||
0
|
||||
@ -42,8 +42,8 @@ WRect
|
||||
WFileName
|
||||
10
|
||||
clib_r.tgt
|
||||
24
|
||||
52
|
||||
0
|
||||
0
|
||||
11
|
||||
VComponent
|
||||
12
|
||||
@ -59,5 +59,5 @@ WFileName
|
||||
7
|
||||
crt.tgt
|
||||
0
|
||||
29
|
||||
0
|
||||
11
|
||||
|
@ -1,35 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Open Watcom Project
|
||||
*
|
||||
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original
|
||||
* Code as defined in and that are subject to the Sybase Open Watcom
|
||||
* Public License version 1.0 (the 'License'). You may not use this file
|
||||
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
|
||||
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
|
||||
* provided with the Original Code and Modifications, and is also
|
||||
* available at www.sybase.com/developer/opensource.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
||||
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
||||
* NON-INFRINGEMENT. Please see the License for the specific language
|
||||
* governing rights and limitations under the License.
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Description: 80x87 related globals for OSI.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
|
||||
unsigned char _8087;
|
||||
unsigned char _real87;
|
@ -270,7 +270,7 @@ extern void __chk8087( void )
|
||||
void __chk8087( void )
|
||||
/********************/
|
||||
{
|
||||
_RWD_real87 = 3; //387+ ; //__x87id();
|
||||
_RWD_real87 = __x87id();
|
||||
_RWD_8087 = _RWD_real87;
|
||||
__init_8087();
|
||||
}
|
||||
|
53
programs/develop/open watcom/trunk/clib/crt/cmodel.asm
Normal file
53
programs/develop/open watcom/trunk/clib/crt/cmodel.asm
Normal file
@ -0,0 +1,53 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Open Watcom Project
|
||||
;*
|
||||
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* This file contains Original Code and/or Modifications of Original
|
||||
;* Code as defined in and that are subject to the Sybase Open Watcom
|
||||
;* Public License version 1.0 (the 'License'). You may not use this file
|
||||
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
|
||||
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
|
||||
;* provided with the Original Code and Modifications, and is also
|
||||
;* available at www.sybase.com/developer/opensource.
|
||||
;*
|
||||
;* The Original Code and all software distributed under the License are
|
||||
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
||||
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
||||
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
||||
;* NON-INFRINGEMENT. Please see the License for the specific language
|
||||
;* governing rights and limitations under the License.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
|
||||
;* DESCRIBE IT HERE!
|
||||
;*
|
||||
;*****************************************************************************
|
||||
|
||||
|
||||
include mdef.inc
|
||||
|
||||
modstart cmodel
|
||||
|
||||
if _MODEL and _BIG_CODE
|
||||
public _big_code_
|
||||
_big_code_ label far
|
||||
else
|
||||
public _small_code_
|
||||
_small_code_ label near
|
||||
endif
|
||||
;
|
||||
; This is here so that if both _small_code_ and _big_code_ get hauled
|
||||
; in from seperate libraries, the linker will complain about
|
||||
; CodeModelMismatch being redefined
|
||||
;
|
||||
public CodeModelMismatch
|
||||
CodeModelMismatch label near
|
||||
|
||||
endmod
|
||||
end
|
@ -153,7 +153,11 @@ static void callit( pfn *f ) {
|
||||
; eax==15 -> run init routines whose priority is <= 15
|
||||
;
|
||||
*/
|
||||
|
||||
#if defined(M_I86)
|
||||
void _WCI86FAR __FInitRtns( unsigned limit ) {
|
||||
__InitRtns( limit );
|
||||
}
|
||||
#endif
|
||||
void __InitRtns( unsigned limit ) {
|
||||
__type_rtp local_limit;
|
||||
struct rt_init _WCI86NEAR *pnext;
|
||||
@ -175,13 +179,11 @@ void __InitRtns( unsigned limit ) {
|
||||
working_limit = local_limit;
|
||||
|
||||
// walk list of routines
|
||||
while( pcur < (struct rt_init _WCI86NEAR*)&_End_XI )
|
||||
{
|
||||
while( pcur < (struct rt_init _WCI86NEAR*)&_End_XI ) {
|
||||
// if this one hasn't been called
|
||||
if( pcur->rtn_type != PDONE ) {
|
||||
// if the priority is better than best so far
|
||||
if( pcur->priority <= working_limit )
|
||||
{
|
||||
if( pcur->priority <= working_limit ) {
|
||||
// remember this one
|
||||
pnext = pcur;
|
||||
working_limit = pcur->priority;
|
||||
@ -224,9 +226,7 @@ void _WCI86FAR __FFiniRtns( unsigned min_limit, unsigned max_limit ) {
|
||||
__FiniRtns( min_limit, max_limit );
|
||||
}
|
||||
#endif
|
||||
|
||||
void __FiniRtns( unsigned min_limit, unsigned max_limit )
|
||||
{
|
||||
void __FiniRtns( unsigned min_limit, unsigned max_limit ) {
|
||||
__type_rtp local_min_limit;
|
||||
__type_rtp local_max_limit;
|
||||
struct rt_init _WCI86NEAR *pnext;
|
||||
|
@ -41,26 +41,40 @@
|
||||
#include "initfini.h"
|
||||
#include "initarg.h"
|
||||
|
||||
void _cdecl mf_init();
|
||||
void _stdcall InitHeap(int heap_size);
|
||||
int __appcwdlen;
|
||||
char* __appcwd;
|
||||
extern char *LpCmdLine;
|
||||
extern char *LpPgmName;
|
||||
|
||||
_WCRTLINK void (*__process_fini)(unsigned,unsigned) = 0;
|
||||
|
||||
#ifdef __SW_BR
|
||||
_WCRTLINK extern void (*__process_fini)( unsigned, unsigned );
|
||||
extern void __CommonInit( void );
|
||||
extern int wmain( int, wchar_t ** );
|
||||
extern int main( int, char ** );
|
||||
extern char *LpCmdLine;
|
||||
extern char *LpPgmName;
|
||||
#else
|
||||
extern void __NTMainInit( void *, void * );
|
||||
#ifdef __WIDECHAR__
|
||||
extern void __wCMain( void );
|
||||
#if defined(_M_IX86)
|
||||
#pragma aux __wCMain "*"
|
||||
#endif
|
||||
#else
|
||||
extern void __CMain( void );
|
||||
#if defined(_M_IX86)
|
||||
#pragma aux __CMain "*"
|
||||
#endif
|
||||
#endif
|
||||
extern unsigned __ThreadDataSize;
|
||||
#endif
|
||||
|
||||
void __F_NAME(__NTMain,__wNTMain)( void )
|
||||
/***************************************/
|
||||
{
|
||||
|
||||
InitHeap(32*1024*1024);
|
||||
//mf_init();
|
||||
|
||||
InitHeap(0);
|
||||
|
||||
__process_fini = &__FiniRtns;
|
||||
__InitRtns( 255 );
|
||||
|
122
programs/develop/open watcom/trunk/clib/fpu/chipw32.asm
Normal file
122
programs/develop/open watcom/trunk/clib/fpu/chipw32.asm
Normal file
@ -0,0 +1,122 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Open Watcom Project
|
||||
;*
|
||||
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* This file contains Original Code and/or Modifications of Original
|
||||
;* Code as defined in and that are subject to the Sybase Open Watcom
|
||||
;* Public License version 1.0 (the 'License'). You may not use this file
|
||||
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
|
||||
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
|
||||
;* provided with the Original Code and Modifications, and is also
|
||||
;* available at www.sybase.com/developer/opensource.
|
||||
;*
|
||||
;* The Original Code and all software distributed under the License are
|
||||
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
||||
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
||||
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
||||
;* NON-INFRINGEMENT. Please see the License for the specific language
|
||||
;* governing rights and limitations under the License.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
|
||||
;* DESCRIBE IT HERE!
|
||||
;*
|
||||
;*****************************************************************************
|
||||
|
||||
|
||||
; static char sccs_id[] = "@(#)wrap32.asm 1.1 12/15/94 15:56:32";
|
||||
;
|
||||
; This code is being published by Intel to users of the Pentium(tm)
|
||||
; processor. Recipients are authorized to copy, modify, compile, use and
|
||||
; distribute the code.
|
||||
;
|
||||
; Intel makes no warranty of any kind with regard to this code, including
|
||||
; but not limited to, implied warranties or merchantability and fitness for
|
||||
; a particular purpose. Intel assumes no responsibility for any errors that
|
||||
; may appear in this code.
|
||||
;
|
||||
; No patent licenses are granted, express or implied.
|
||||
;
|
||||
;
|
||||
; The following code is a PRELIMINARY IMPLEMENTATION of a
|
||||
; software patch for the FPATAN instruction replacement.
|
||||
;
|
||||
;
|
||||
include mdef.inc
|
||||
|
||||
.386
|
||||
.387
|
||||
|
||||
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA'
|
||||
|
||||
|
||||
FPU_STATE STRUC
|
||||
CONTROL_WORD DW ?
|
||||
reserved_1 DW ?
|
||||
STATUS_WORD DW ?
|
||||
reserved_2 DW ?
|
||||
TAG_WORD DW ?
|
||||
reserved_3 DW ?
|
||||
IP_OFFSET DD ?
|
||||
CS_SLCT DW ?
|
||||
OPCODE DW ?
|
||||
DATA_OFFSET DD ?
|
||||
OPERAND_SLCT DW ?
|
||||
reserved_4 DW ?
|
||||
REGISTER_0 DT ?
|
||||
REGISTER_1 DT ?
|
||||
REGISTER_2 DT ?
|
||||
REGISTER_3 DT ?
|
||||
REGISTER_4 DT ?
|
||||
REGISTER_5 DT ?
|
||||
REGISTER_6 DT ?
|
||||
REGISTER_7 DT ?
|
||||
SAVE_REG_0 DT ?
|
||||
FPU_STATE ENDS
|
||||
|
||||
ENV_SIZE EQU 118
|
||||
|
||||
DATA32 ENDS
|
||||
|
||||
DGROUP GROUP DATA32
|
||||
|
||||
|
||||
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'
|
||||
|
||||
|
||||
assume cs:_TEXT, ds:DGROUP, es:DGROUP, ss:nothing
|
||||
public __fpatan_wrap
|
||||
|
||||
;
|
||||
; PRELIMINARY VERSION for FPATAN instruction replacement
|
||||
;
|
||||
|
||||
EXTRN __fpatan_chk:NEAR
|
||||
|
||||
defpe __fpatan_wrap
|
||||
push eax
|
||||
sub esp, ENV_SIZE
|
||||
fstp tbyte ptr [esp].SAVE_REG_0
|
||||
fnsave [esp]
|
||||
fld tbyte ptr [esp].REGISTER_0
|
||||
fld tbyte ptr [esp].SAVE_REG_0
|
||||
call __fpatan_chk
|
||||
fstsw ax
|
||||
fstp tbyte ptr [esp].REGISTER_0
|
||||
and ax, 0ffh
|
||||
or ax, [esp].STATUS_WORD
|
||||
mov [esp].STATUS_WORD, ax
|
||||
frstor [esp]
|
||||
add esp, ENV_SIZE
|
||||
pop eax
|
||||
ret
|
||||
__fpatan_wrap ENDP
|
||||
|
||||
_TEXT ENDS
|
||||
end
|
50
programs/develop/open watcom/trunk/clib/fpu/env387.inc
Normal file
50
programs/develop/open watcom/trunk/clib/fpu/env387.inc
Normal file
@ -0,0 +1,50 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Open Watcom Project
|
||||
;*
|
||||
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* This file contains Original Code and/or Modifications of Original
|
||||
;* Code as defined in and that are subject to the Sybase Open Watcom
|
||||
;* Public License version 1.0 (the 'License'). You may not use this file
|
||||
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
|
||||
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
|
||||
;* provided with the Original Code and Modifications, and is also
|
||||
;* available at www.sybase.com/developer/opensource.
|
||||
;*
|
||||
;* The Original Code and all software distributed under the License are
|
||||
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
||||
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
||||
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
||||
;* NON-INFRINGEMENT. Please see the License for the specific language
|
||||
;* governing rights and limitations under the License.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
|
||||
;* DESCRIBE IT HERE!
|
||||
;*
|
||||
;*****************************************************************************
|
||||
|
||||
|
||||
; Define 80387 environment:
|
||||
; ========================
|
||||
;
|
||||
; ---------------<--- offsets relative to here
|
||||
; | | stack grows
|
||||
; | | this way
|
||||
; | | /|\
|
||||
; | | |
|
||||
; | |
|
||||
; ---------------
|
||||
|
||||
ENV_SIZE equ 28 ; size of buffer required for 80387 environment
|
||||
|
||||
ENV_CW equ 0 ; control word
|
||||
ENV_SW equ 4 ; status word
|
||||
ENV_TW equ 8 ; tag word
|
||||
ENV_IP equ 12 ; instruction pointer
|
||||
ENV_OP equ 20 ; operand pointer
|
374
programs/develop/open watcom/trunk/clib/fpu/fpeinth.asm
Normal file
374
programs/develop/open watcom/trunk/clib/fpu/fpeinth.asm
Normal file
@ -0,0 +1,374 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Open Watcom Project
|
||||
;*
|
||||
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* This file contains Original Code and/or Modifications of Original
|
||||
;* Code as defined in and that are subject to the Sybase Open Watcom
|
||||
;* Public License version 1.0 (the 'License'). You may not use this file
|
||||
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
|
||||
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
|
||||
;* provided with the Original Code and Modifications, and is also
|
||||
;* available at www.sybase.com/developer/opensource.
|
||||
;*
|
||||
;* The Original Code and all software distributed under the License are
|
||||
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
||||
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
||||
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
||||
;* NON-INFRINGEMENT. Please see the License for the specific language
|
||||
;* governing rights and limitations under the License.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* Description: 80x87 interrupt handler.
|
||||
;*
|
||||
;*****************************************************************************
|
||||
|
||||
|
||||
;;; //e:\watcom\src\bld\watcom\h;E:\WATCOM\H;E:\WATCOM\H\NT
|
||||
|
||||
.8087
|
||||
.386p
|
||||
|
||||
include struct.inc
|
||||
include mdef.inc
|
||||
include stword.inc
|
||||
include env387.inc
|
||||
include fstatus.inc
|
||||
|
||||
ifndef __NETWARE__
|
||||
xref __GETDS
|
||||
endif
|
||||
xref __8087 ; indicate that NDP instructions are present
|
||||
|
||||
modstart fpeinth
|
||||
|
||||
datasegment
|
||||
|
||||
extrn __FPE_exception_: proc
|
||||
extrn "C",_STACKLOW : dword
|
||||
|
||||
TInf db 00h,00h,00h,00h,00h,00h,00h,80h,0ffh,7fh
|
||||
F8Inf db 0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0efh,7fh
|
||||
F4Inf db 0ffh,0ffh,7fh,7fh
|
||||
db 512 dup(0)
|
||||
FPEStk label byte
|
||||
SaveSS dw 0
|
||||
SaveESP dd 0
|
||||
enddata
|
||||
|
||||
|
||||
; Interrupt handler for 80x87 exceptions.
|
||||
|
||||
xdefp __FPEHandler_
|
||||
defp __FPEHandler_
|
||||
public "C",__FPEHandlerStart_
|
||||
__FPEHandlerStart_ label byte
|
||||
push EAX ; save reg
|
||||
mov AL,20h ; issue EOI to 8259 controller
|
||||
out 20h,AL ; ...
|
||||
out 0a0h,AL ; issue EOI to slave 8259
|
||||
xor AX,AX ; clear busy signal
|
||||
out 0f0h,AL ; ...
|
||||
pop EAX ; restore regs
|
||||
public __FPE2Handler_
|
||||
__FPE2Handler_ label byte
|
||||
push EAX ; save regs
|
||||
push EBX ; ...
|
||||
push ECX ; ...
|
||||
push EDX ; ...
|
||||
push ESI ; ...
|
||||
push EDI ; ...
|
||||
push EBP ; ...
|
||||
push DS ; ...
|
||||
push ES ; ...
|
||||
sub ESP,ENV_SIZE ; make room for environment information
|
||||
mov EBP,ESP ; point to buffer for 80x87 environment
|
||||
fnstenv [EBP] ; get 80x87 environment
|
||||
fwait ; wait for 80x87
|
||||
fdisi ; disable interrupts
|
||||
sti ; enable CPU interrupts
|
||||
ifndef __NETWARE__
|
||||
; call __GETDS ; load DS
|
||||
endif
|
||||
ifdef __NETWARE__
|
||||
; push SS ; load DS
|
||||
; pop DS ; ...
|
||||
endif
|
||||
mov EDX,ENV_CW[EBP] ; get control word
|
||||
not EDX ; flip the mask bits
|
||||
mov DH,0FFh ; turn on top byte
|
||||
and EDX,ENV_SW[EBP] ; get status word
|
||||
; mov ES,ENV_IP+4[EBP] ; get intruction address
|
||||
mov EDI,ENV_IP[EBP] ; ...
|
||||
opcode: mov BX,[EDI] ; get opcode
|
||||
inc EDI ; point to next opcode
|
||||
cmp BL,0d8h ; check if its the opcode
|
||||
jb opcode ; ...
|
||||
cmp BL,0dfh ; ...
|
||||
ja opcode ; ...
|
||||
; mov ES,ENV_OP+4[EBP] ; get pointer to operand
|
||||
mov EDI,ENV_OP[EBP] ; ...
|
||||
xchg BL,BH ; get opcode in right position
|
||||
mov CL,FPE_OK ; assume exception to be ignored
|
||||
_guess ; guess precision exception
|
||||
test DL,ST_EF_PR ; - check for precision exception
|
||||
_quif e ; - quit if not precision exception
|
||||
mov CL,FPE_INEXACT ; - indicate precision exception
|
||||
_admit ; guess stack under/overflow
|
||||
test DL,ST_EF_SF ; - check for stack under/overflow
|
||||
_quif e ; - quit if not stack under/overflow
|
||||
test DX,ST_C1 ; - check if underflow
|
||||
_if e ; - if underflow
|
||||
mov CL,FPE_STACKUNDERFLOW ; - - indicate stack underflow
|
||||
_else ; - else
|
||||
mov CL,FPE_STACKOVERFLOW ; - - indicate stack overflow
|
||||
_endif ; - endif
|
||||
_admit ; guess invalid operation
|
||||
test DL,ST_EF_IO ; - check for invalid operation
|
||||
_quif e ; - quit if not invalid operation
|
||||
call InvalidOp ; - process invalid operation
|
||||
_admit ; guess denormal operand
|
||||
test DL,ST_EF_DO ; - check for denormal operand
|
||||
_quif e ; - quit if not denormal operand
|
||||
mov CL,FPE_DENORMAL ; - indicate underflow
|
||||
_admit ; guess overflow
|
||||
test DL,ST_EF_OF ; - check for overflow
|
||||
_quif e ; - quit if not overflow
|
||||
call KOOverFlow ; - process overflow exception
|
||||
mov CL,FPE_OVERFLOW ; - set floating point error code
|
||||
_admit ; guess underflow
|
||||
test DL,ST_EF_UF ; - check for underflow
|
||||
_quif e ; - quit if not underflow
|
||||
mov CL,FPE_UNDERFLOW ; - indicate underflow
|
||||
_admit ; guess divide by 0
|
||||
test DL,ST_EF_ZD ; - check for divide by zero
|
||||
_quif e ; - quit if not divide by zero
|
||||
call GetInf ; - process divide by zero
|
||||
mov CL,FPE_ZERODIVIDE ; - indicate divide by zero
|
||||
_endguess ; endguess
|
||||
_guess ; guess exception to be handled
|
||||
cmp CL,FPE_OK ; - check if exception allowed
|
||||
_quif e ; - quit if exception not allowed
|
||||
; cmp SaveSS,0 ; - check if already in handler
|
||||
; _quif ne ; - quit if already in handler
|
||||
push _STACKLOW ; - save old stack low
|
||||
mov SaveSS,SS ; - save current stack pointer
|
||||
mov SaveESP,ESP ; - ...
|
||||
push DS ; - get new stack pointer
|
||||
pop SS ; - ...
|
||||
lea ESP,FPEStk ; - ...
|
||||
lea EAX,FPEStk-512 ; - set stack low variable
|
||||
mov _STACKLOW,EAX ; - set stack low variable
|
||||
movzx EAX,CL ; - set floating point status
|
||||
call __FPE_exception_ ; - call user's handler
|
||||
mov SS,SaveSS ; - restore stack pointer
|
||||
mov ESP,SaveESP ; - ...
|
||||
pop _STACKLOW ; - restore old stacklow
|
||||
mov SaveSS,0 ; - indicate handler can be re-entered
|
||||
_endguess ; endguess
|
||||
fclex ; clear exceptions that may have
|
||||
; occurred as a result of handling the
|
||||
; exception
|
||||
and word ptr ENV_CW[EBP],0FF72h
|
||||
fldcw word ptr ENV_CW[EBP] ; enable interrupts
|
||||
fwait ; ...
|
||||
add ESP,ENV_SIZE ; clean up stack
|
||||
pop ES ; restore registers
|
||||
pop DS ; ...
|
||||
pop EBP ; ...
|
||||
pop EDI ; ...
|
||||
pop ESI ; ...
|
||||
pop EDX ; ...
|
||||
pop ECX ; ...
|
||||
pop EBX ; ...
|
||||
pop EAX ; ...
|
||||
iretd ; return from interrupt handler
|
||||
public "C",__FPEHandlerEnd_
|
||||
__FPEHandlerEnd_ label byte
|
||||
endproc __FPEHandler_
|
||||
|
||||
|
||||
; Process invalid operation.
|
||||
|
||||
InvalidOp proc near
|
||||
mov CL,FPE_INVALID ; assume invalid operation
|
||||
_guess ; guess it's square root
|
||||
cmp BX,0D9FAh ; - ...
|
||||
_quif ne ; - quit if it's not that instruction
|
||||
mov CL,FPE_SQRTNEG ; - indicate sqrt(negative number)
|
||||
ret ; - return
|
||||
_endguess ; endguess
|
||||
_guess ; guess it's square root
|
||||
cmp BX,0D9F1h ; - ...
|
||||
_quif ne ; - quit if it's not that instruction
|
||||
mov CL,FPE_LOGERR ; - indicate sqrt(negative number)
|
||||
ret ; - return
|
||||
_endguess ; endguess
|
||||
_guess ; guess: 'fprem' instruction
|
||||
cmp BX,0D9F8h ; - check for 'fprem' 10-may-90
|
||||
_if ne ; - if not 'fprem'
|
||||
cmp BX,0D9F5h ; - - check for 'fprem1'
|
||||
_endif ; - endif
|
||||
_quif ne ; - quit if not 'fprem' or 'fprem1'
|
||||
mov CL,FPE_MODERR ; - indicate mod(negative number)
|
||||
_admit ; guess: integer overflow
|
||||
mov DX,BX ; - save op code
|
||||
and DX,0310h ; - check for fist/fistp instruction
|
||||
cmp DX,0310h ; - ...
|
||||
_quif ne ; - quit if its not that instruction
|
||||
mov CL,FPE_IOVERFLOW ; - indicate integer overflow
|
||||
_admit ; guess it's floating point underflow
|
||||
;; mov DX,BX ; - save op code
|
||||
and DX,0110h ; - check if fst or fstp instruction
|
||||
cmp DX,0110h ; - ...
|
||||
_quif ne ; - quit if it's not that instruction
|
||||
; Destination is short or long real and source register is an unnormal
|
||||
; with exponent in range.
|
||||
fstp st(0) ; - pop old result
|
||||
fldz ; - load zero
|
||||
mov DL,BL ; - save op code
|
||||
and DL,0C0h ; - check the MOD bits of instruction
|
||||
cmp DL,0C0h ; - ...
|
||||
_if ne ; - if result to be placed in memory
|
||||
call Store ; - - store result in memory
|
||||
_endif ; - endif
|
||||
test BL,08h ; - check if result to be popped
|
||||
_if ne ; - if result to be popped
|
||||
fstp st(0) ; - - pop the result
|
||||
_endif ; - endif
|
||||
mov CL,FPE_UNDERFLOW ; - indicate underflow
|
||||
_admit ; guess it's divide
|
||||
mov DX,BX ; - save op code
|
||||
and DX,0130h ; - check for fdiv/fidiv instruction
|
||||
cmp DX,0030h ; - ...
|
||||
_quif ne ; - quit if it's not that instruction
|
||||
mov DX,ENV_TW[EBP] ; - get tag word
|
||||
mov CL,AH ; - get stack pointer
|
||||
and CL,38h ; - ...
|
||||
shr CL,2 ; - ...
|
||||
ror DX,CL ; - make stack top low order bits
|
||||
and DL,05h ; - check if top two elements are 0
|
||||
cmp DL,05h ; - ...
|
||||
_quif ne ; - quif if they are not 0
|
||||
mov CL,FPE_ZERODIVIDE ; - indicate divide by zero
|
||||
_endguess ; endguess
|
||||
ret
|
||||
endproc InvalidOp
|
||||
|
||||
|
||||
; Process overflow exception (note that only floating point overflows
|
||||
; are handled - integer overflows are invalid operations).
|
||||
|
||||
KOOverFlow proc near
|
||||
_guess ; guess: fscale instruction 10-may-90
|
||||
cmp BX,0D9FDh ; - quit if not 'fscale' instruction
|
||||
_quif ne ; - ...
|
||||
_admit ; guess: fst/fstp instruction
|
||||
mov DX,BX ; - save op code
|
||||
and DX,0110h ; - check if fst or fstp instruction
|
||||
cmp DX,0110h ; - ...
|
||||
_quif ne ; - quit if not an fst/fstp instr.
|
||||
call GetInf ; - load infinity
|
||||
mov DL,BL ; - save op code
|
||||
and DL,0C0h ; - check the MOD bits of instruction
|
||||
cmp DL,0C0h ; - ...
|
||||
_if ne ; - if result to be placed in memory
|
||||
call Store ; - - store infinity
|
||||
_endif ; - endif
|
||||
test BL,08h ; - check if result to be popped
|
||||
_if ne ; - if result to be popped
|
||||
fstp st(0) ; - - pop result
|
||||
_endif ; - endif
|
||||
_admit ; admit arithmetic operation
|
||||
mov DL,BL ; - save op code
|
||||
and DL,0C0h ; - check if both operands on stack
|
||||
cmp DL,0C0h ; - ...
|
||||
_quif ne ; - quif both operands not on stack
|
||||
;
|
||||
; This code handles overflow on the following intructions:
|
||||
; fxxx ST,ST(i)
|
||||
; fxxx ST(i),ST where xxx is one of mul,div,sub or add
|
||||
; fxxxp ST(i),ST
|
||||
;
|
||||
lea ESI,TInf ; - load internal infinity
|
||||
call Load ; - ...
|
||||
_admit ; admit
|
||||
;
|
||||
; This admit block is to handle overflow on the following intructions:
|
||||
; fxxx short real
|
||||
; fxxx long real where xxx is one of mul,div,sub or add
|
||||
;
|
||||
call GetInf ; - load infinity
|
||||
_endguess ; endguess
|
||||
ret ; return
|
||||
endproc KOOverFlow
|
||||
|
||||
|
||||
; Replace the top element of the stack with the appropriate signed
|
||||
; infinity.
|
||||
|
||||
GetInf proc near
|
||||
ftst ; get sign of result
|
||||
fstsw word ptr ENV_OP[EBP]
|
||||
fstp st(0) ; pop argument off stack (does fwait)
|
||||
test BH,04h ; check if single or double
|
||||
_if ne ; if double
|
||||
fld qword ptr F8Inf ; - load double precision infinity
|
||||
_else ; else
|
||||
fld dword ptr F4Inf ; - load single precision infinity
|
||||
_endif ; endif
|
||||
test word ptr ENV_OP[EBP],ST_C0
|
||||
_if ne ; if argument is negative
|
||||
fchs ; - return negative infinity
|
||||
_endif ; endif
|
||||
ret ; return
|
||||
endproc GetInf
|
||||
|
||||
|
||||
; Replace an element on the stack with internal zero or infinity.
|
||||
|
||||
Load proc near
|
||||
test BH,04h ; check if result is top element
|
||||
_if e ; if result is not top element
|
||||
mov DL,0 ; - indicate we are at the top
|
||||
_else ; else
|
||||
mov DL,BL ; - get st(i)
|
||||
and DL,07h ; - . . .
|
||||
_endif ; endif
|
||||
push EDX ; save st(i)
|
||||
_loop ; loop
|
||||
dec DL ; - decrement counter
|
||||
_quif l ; - quit if we are at st(i)
|
||||
fincstp ; - increment stack pointer
|
||||
_endloop ; endloop
|
||||
fstp st(0) ; free the stack element
|
||||
fld tbyte ptr [ESI] ; load internal zero
|
||||
pop EDX ; get st(i)
|
||||
_loop ; loop
|
||||
dec DL ; - decrement counter
|
||||
_quif l ; - quit if we are at st(i)
|
||||
fdecstp ; - decrement stack pointer
|
||||
_endloop ; endloop
|
||||
ret ; return
|
||||
endproc Load
|
||||
|
||||
|
||||
; Store the top element of the stack at ES:EDI.
|
||||
|
||||
Store proc near
|
||||
test BH,04h
|
||||
_if ne ; if double
|
||||
fst qword ptr ES:[EDI] ; - store as double precision result
|
||||
_else ; else
|
||||
fst dword ptr ES:[EDI] ; - store as single precision result
|
||||
_endif ; endif
|
||||
ret ; return
|
||||
endproc Store
|
||||
|
||||
endmod
|
||||
end
|
47
programs/develop/open watcom/trunk/clib/h/fstatus.inc
Normal file
47
programs/develop/open watcom/trunk/clib/h/fstatus.inc
Normal file
@ -0,0 +1,47 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Open Watcom Project
|
||||
;*
|
||||
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* This file contains Original Code and/or Modifications of Original
|
||||
;* Code as defined in and that are subject to the Sybase Open Watcom
|
||||
;* Public License version 1.0 (the 'License'). You may not use this file
|
||||
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
|
||||
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
|
||||
;* provided with the Original Code and Modifications, and is also
|
||||
;* available at www.sybase.com/developer/opensource.
|
||||
;*
|
||||
;* The Original Code and all software distributed under the License are
|
||||
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
||||
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
||||
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
||||
;* NON-INFRINGEMENT. Please see the License for the specific language
|
||||
;* governing rights and limitations under the License.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
|
||||
;* DESCRIBE IT HERE!
|
||||
;*
|
||||
;*****************************************************************************
|
||||
|
||||
|
||||
FPE_OK equ 0
|
||||
FPE_INVALID equ 81h
|
||||
FPE_DENORMAL equ 82h
|
||||
FPE_ZERODIVIDE equ 83h
|
||||
FPE_OVERFLOW equ 84h
|
||||
FPE_UNDERFLOW equ 85h
|
||||
FPE_INEXACT equ 86h
|
||||
FPE_UNEMULATED equ 87h
|
||||
FPE_SQRTNEG equ 88h
|
||||
FPE_STACKOVERFLOW equ 8ah
|
||||
FPE_STACKUNDERFLOW equ 8bh
|
||||
FPE_EXPLICITGEN equ 8ch
|
||||
FPE_IOVERFLOW equ 8dh
|
||||
FPE_LOGERR equ 8eh
|
||||
FPE_MODERR equ 8fh
|
88
programs/develop/open watcom/trunk/clib/h/stword.inc
Normal file
88
programs/develop/open watcom/trunk/clib/h/stword.inc
Normal file
@ -0,0 +1,88 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Open Watcom Project
|
||||
;*
|
||||
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* This file contains Original Code and/or Modifications of Original
|
||||
;* Code as defined in and that are subject to the Sybase Open Watcom
|
||||
;* Public License version 1.0 (the 'License'). You may not use this file
|
||||
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
|
||||
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
|
||||
;* provided with the Original Code and Modifications, and is also
|
||||
;* available at www.sybase.com/developer/opensource.
|
||||
;*
|
||||
;* The Original Code and all software distributed under the License are
|
||||
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
||||
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
||||
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
||||
;* NON-INFRINGEMENT. Please see the License for the specific language
|
||||
;* governing rights and limitations under the License.
|
||||
;*
|
||||
;* ========================================================================
|
||||
;*
|
||||
;* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
|
||||
;* DESCRIBE IT HERE!
|
||||
;*
|
||||
;*****************************************************************************
|
||||
|
||||
|
||||
; Define 8087 status word:
|
||||
; ========================
|
||||
|
||||
ST_EF_IO equ 0001h ; invalid operation
|
||||
ST_EF_DO equ 0002h ; denormalized operand
|
||||
ST_EF_ZD equ 0004h ; zero divide
|
||||
ST_EF_OF equ 0008h ; overflow flag
|
||||
ST_EF_UF equ 0010h ; underflow flag
|
||||
ST_EF_PR equ 0020h ; precision
|
||||
ST_EF_SF equ 0040h ; stack under/overflow
|
||||
ST_EF_ES equ 0080h ; error summary
|
||||
|
||||
ST_C0 equ 0100h ; condition code 0
|
||||
ST_C1 equ 0200h ; condition code 1
|
||||
ST_C2 equ 0400h ; condition code 2
|
||||
ST_C3 equ 4000h ; condition code 3
|
||||
|
||||
ST_IR equ 0080h ; interrupt request
|
||||
|
||||
ST_ST equ 3800h ; stack top
|
||||
|
||||
ST_BF equ 8000h ; busy flag
|
||||
|
||||
; Define 8087 control word:
|
||||
; =========================
|
||||
|
||||
; Exception masks (1 = exception masked)
|
||||
CW_IM equ 0001h ; invalid operation
|
||||
CW_DM equ 0002h ; denormalized operand
|
||||
CW_ZM equ 0004h ; zero divide
|
||||
CW_OM equ 0008h ; overflow
|
||||
CW_UM equ 0010h ; underflow
|
||||
CW_PM equ 0020h ; precision
|
||||
|
||||
; reserved - xxx0 0000 0x00 0000
|
||||
CW_RESERVE equ 0e040h ; RESERVED
|
||||
|
||||
; interrupt enable mask 0000 0000 x000 0000
|
||||
CW_IEM_EN equ 0000h ; enabled
|
||||
CW_IEM_DIS equ 0080h ; disabled
|
||||
|
||||
CW_PC_MASK equ 0fcffh ; precision control - 0000 00xx 0000 0000
|
||||
CW_PC_64 equ 0300h ; precision control - 64 bits
|
||||
CW_PC_53 equ 0200h ; precision control - 53 bits
|
||||
CW_PC_RES equ 0100h ; precision control - reserved
|
||||
CW_PC_24 equ 0000h ; precision control - 24 bits
|
||||
|
||||
CW_RC_MASK equ 0f3ffh ; round control - 0000 xx00 0000 0000
|
||||
CW_RC_CHOP equ 0c00h ; round control - chop
|
||||
CW_RC_UP equ 0800h ; round control - round up
|
||||
CW_RC_DOWN equ 0400h ; round control - round down
|
||||
CW_RC_NEAR equ 0000h ; round control - round nearest
|
||||
|
||||
; infinity control - 000x 0000 0000 0000
|
||||
CW_IC_PROJ equ 0000h ; projective
|
||||
CW_IC_AFF equ 1000h ; affine
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user