/programs/develop/open watcom/trunk/clib/char/chartest.c |
---|
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: Non-exhaustive test of ctype.h functions and macros. |
* Note: Tests assume the C locale. |
* |
****************************************************************************/ |
#include <ctype.h> |
#include <wctype.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#define VERIFY( exp ) if( !(exp) ) { \ |
printf( "%s: ***FAILURE*** at line %d of %s.\n",\ |
ProgramName, __LINE__, \ |
strlwr(__FILE__) ); \ |
NumErrors++; \ |
} |
#define TEST_ARRAY_SIZE 256 |
#define TEST_ARRAY_SIZE_WIDE 512 |
struct CtypeBits { |
unsigned alnum : 1; |
unsigned alpha : 1; |
unsigned blank : 1; |
unsigned cntrl : 1; |
unsigned digit : 1; |
unsigned graph : 1; |
unsigned lower : 1; |
unsigned print : 1; |
unsigned punct : 1; |
unsigned space : 1; |
unsigned upper : 1; |
unsigned xdigit : 1; |
unsigned ascii : 1; |
unsigned csym : 1; |
unsigned csymf : 1; |
}; |
struct CtypeBits MacroResults[TEST_ARRAY_SIZE]; |
struct CtypeBits FunctResults[TEST_ARRAY_SIZE]; |
struct CtypeBits WideMacroResults[TEST_ARRAY_SIZE_WIDE]; |
struct CtypeBits WideFunctResults[TEST_ARRAY_SIZE_WIDE]; |
char ProgramName[_MAX_PATH]; /* executable filename */ |
int NumErrors = 0; /* number of errors */ |
int far far_data = 0; |
void TestClassifyMacro( void ) |
/****************************/ |
{ |
int i; |
far_data++; // set ds outside DGROUP |
MacroResults[0].alnum = isalnum( EOF ); |
MacroResults[0].alpha = isalpha( EOF ); |
MacroResults[0].blank = isblank( EOF ); |
MacroResults[0].cntrl = iscntrl( EOF ); |
MacroResults[0].digit = isdigit( EOF ); |
MacroResults[0].graph = isgraph( EOF ); |
MacroResults[0].lower = islower( EOF ); |
MacroResults[0].print = isprint( EOF ); |
MacroResults[0].punct = ispunct( EOF ); |
MacroResults[0].space = isspace( EOF ); |
MacroResults[0].upper = isupper( EOF ); |
MacroResults[0].xdigit = isxdigit( EOF ); |
MacroResults[0].ascii = isascii( EOF ); |
MacroResults[0].csym = __iscsym( EOF ); |
MacroResults[0].csymf = __iscsymf( EOF ); |
for( i = 1; i < TEST_ARRAY_SIZE; i++ ) { |
MacroResults[i].alnum = isalnum( i ); |
MacroResults[i].alpha = isalpha( i ); |
MacroResults[i].blank = isblank( i ); |
MacroResults[i].cntrl = iscntrl( i ); |
MacroResults[i].digit = isdigit( i ); |
MacroResults[i].graph = isgraph( i ); |
MacroResults[i].lower = islower( i ); |
MacroResults[i].print = isprint( i ); |
MacroResults[i].punct = ispunct( i ); |
MacroResults[i].space = isspace( i ); |
MacroResults[i].upper = isupper( i ); |
MacroResults[i].xdigit = isxdigit( i ); |
MacroResults[i].ascii = isascii( i ); |
MacroResults[i].csym = __iscsym( i ); |
MacroResults[i].csymf = __iscsymf( i ); |
} |
} |
void TestClassifyFunct( void ) |
/****************************/ |
{ |
int i; |
far_data++; // set ds outside DGROUP |
FunctResults[0].alnum = (isalnum)( EOF ); |
FunctResults[0].alpha = (isalpha)( EOF ); |
FunctResults[0].blank = (isblank)( EOF ); |
FunctResults[0].cntrl = (iscntrl)( EOF ); |
FunctResults[0].digit = (isdigit)( EOF ); |
FunctResults[0].graph = (isgraph)( EOF ); |
FunctResults[0].lower = (islower)( EOF ); |
FunctResults[0].print = (isprint)( EOF ); |
FunctResults[0].punct = (ispunct)( EOF ); |
FunctResults[0].space = (isspace)( EOF ); |
FunctResults[0].upper = (isupper)( EOF ); |
FunctResults[0].xdigit = (isxdigit)( EOF ); |
FunctResults[0].ascii = (isascii)( EOF ); |
FunctResults[0].csym = (__iscsym)( EOF ); |
FunctResults[0].csymf = (__iscsymf)( EOF ); |
for( i = 1; i < TEST_ARRAY_SIZE; i++ ) { |
FunctResults[i].alnum = (isalnum)( i ); |
FunctResults[i].alpha = (isalpha)( i ); |
FunctResults[i].blank = (isblank)( i ); |
FunctResults[i].cntrl = (iscntrl)( i ); |
FunctResults[i].digit = (isdigit)( i ); |
FunctResults[i].graph = (isgraph)( i ); |
FunctResults[i].lower = (islower)( i ); |
FunctResults[i].print = (isprint)( i ); |
FunctResults[i].punct = (ispunct)( i ); |
FunctResults[i].space = (isspace)( i ); |
FunctResults[i].upper = (isupper)( i ); |
FunctResults[i].xdigit = (isxdigit)( i ); |
FunctResults[i].ascii = (isascii)( i ); |
FunctResults[i].csym = (__iscsym)( i ); |
FunctResults[i].csymf = (__iscsymf)( i ); |
} |
} |
void TestClassifyWideMacro( void ) |
/********************************/ |
{ |
int i; |
far_data++; // set ds outside DGROUP |
WideMacroResults[0].alnum = iswalnum( WEOF ); |
WideMacroResults[0].alpha = iswalpha( WEOF ); |
WideMacroResults[0].blank = iswblank( WEOF ); |
WideMacroResults[0].cntrl = iswcntrl( WEOF ); |
WideMacroResults[0].digit = iswdigit( WEOF ); |
WideMacroResults[0].graph = iswgraph( WEOF ); |
WideMacroResults[0].lower = iswlower( WEOF ); |
WideMacroResults[0].print = iswprint( WEOF ); |
WideMacroResults[0].punct = iswpunct( WEOF ); |
WideMacroResults[0].space = iswspace( WEOF ); |
WideMacroResults[0].upper = iswupper( WEOF ); |
WideMacroResults[0].xdigit = iswxdigit( WEOF ); |
WideMacroResults[0].ascii = isascii( WEOF ); |
WideMacroResults[0].csym = __iscsym( WEOF ); |
WideMacroResults[0].csymf = __iscsymf( WEOF ); |
for( i = 1; i < TEST_ARRAY_SIZE_WIDE; i++ ) { |
WideMacroResults[i].alnum = iswalnum( i ); |
WideMacroResults[i].alpha = iswalpha( i ); |
WideMacroResults[i].blank = iswblank( i ); |
WideMacroResults[i].cntrl = iswcntrl( i ); |
WideMacroResults[i].digit = iswdigit( i ); |
WideMacroResults[i].graph = iswgraph( i ); |
WideMacroResults[i].lower = iswlower( i ); |
WideMacroResults[i].print = iswprint( i ); |
WideMacroResults[i].punct = iswpunct( i ); |
WideMacroResults[i].space = iswspace( i ); |
WideMacroResults[i].upper = iswupper( i ); |
WideMacroResults[i].xdigit = iswxdigit( i ); |
WideMacroResults[i].ascii = isascii( i ); |
WideMacroResults[i].csym = __iscsym( i ); |
WideMacroResults[i].csymf = __iscsymf( i ); |
} |
} |
void TestClassifyWideFunct( void ) |
/********************************/ |
{ |
int i; |
far_data++; // set ds outside DGROUP |
WideFunctResults[0].alnum = (iswalnum)( WEOF ); |
WideFunctResults[0].alpha = (iswalpha)( WEOF ); |
WideFunctResults[0].blank = (iswblank)( WEOF ); |
WideFunctResults[0].cntrl = (iswcntrl)( WEOF ); |
WideFunctResults[0].digit = (iswdigit)( WEOF ); |
WideFunctResults[0].graph = (iswgraph)( WEOF ); |
WideFunctResults[0].lower = (iswlower)( WEOF ); |
WideFunctResults[0].print = (iswprint)( WEOF ); |
WideFunctResults[0].punct = (iswpunct)( WEOF ); |
WideFunctResults[0].space = (iswspace)( WEOF ); |
WideFunctResults[0].upper = (iswupper)( WEOF ); |
WideFunctResults[0].xdigit = (iswxdigit)( WEOF ); |
WideFunctResults[0].ascii = (isascii)( WEOF ); |
WideFunctResults[0].csym = (__iscsym)( WEOF ); |
WideFunctResults[0].csymf = (__iscsymf)( WEOF ); |
for( i = 1; i < TEST_ARRAY_SIZE_WIDE; i++ ) { |
WideFunctResults[i].alnum = (iswalnum)( i ); |
WideFunctResults[i].alpha = (iswalpha)( i ); |
WideFunctResults[i].blank = (iswblank)( i ); |
WideFunctResults[i].cntrl = (iswcntrl)( i ); |
WideFunctResults[i].digit = (iswdigit)( i ); |
WideFunctResults[i].graph = (iswgraph)( i ); |
WideFunctResults[i].lower = (iswlower)( i ); |
WideFunctResults[i].print = (iswprint)( i ); |
WideFunctResults[i].punct = (iswpunct)( i ); |
WideFunctResults[i].space = (iswspace)( i ); |
WideFunctResults[i].upper = (iswupper)( i ); |
WideFunctResults[i].xdigit = (iswxdigit)( i ); |
WideFunctResults[i].ascii = (isascii)( i ); |
WideFunctResults[i].csym = (__iscsym)( i ); |
WideFunctResults[i].csymf = (__iscsymf)( i ); |
} |
} |
/* Helper function to print mismatches in human readable form */ |
void CheckResults( struct CtypeBits *s1, struct CtypeBits *s2, int count ) |
/************************************************************************/ |
{ |
int i; |
far_data++; // set ds outside DGROUP |
for( i = 0; i < TEST_ARRAY_SIZE; i++ ) { |
if( s1[i].alnum != WideMacroResults[i].alnum ) |
printf( "Mismatch at %d (alnum)\n", i ); |
if( s1[i].alpha != s2[i].alpha ) |
printf( "Mismatch at %d (alpha)\n", i ); |
if( s1[i].blank != s2[i].blank ) |
printf( "Mismatch at %d (blank)\n", i ); |
if( s1[i].cntrl != s2[i].cntrl ) |
printf( "Mismatch at %d (cntrl)\n", i ); |
if( s1[i].digit != s2[i].digit ) |
printf( "Mismatch at %d (digit)\n", i ); |
if( s1[i].graph != s2[i].graph ) |
printf( "Mismatch at %d (graph)\n", i ); |
if( s1[i].lower != s2[i].lower ) |
printf( "Mismatch at %d (lower)\n", i ); |
if( s1[i].print != s2[i].print ) |
printf( "Mismatch at %d (print)\n", i ); |
if( s1[i].punct != s2[i].punct ) |
printf( "Mismatch at %d (punct)\n", i ); |
if( s1[i].space != s2[i].space ) |
printf( "Mismatch at %d (space)\n", i ); |
if( s1[i].upper != s2[i].upper ) |
printf( "Mismatch at %d (upper)\n", i ); |
if( s1[i].xdigit != s2[i].xdigit ) |
printf( "Mismatch at %d (xdigit)\n", i ); |
if( s1[i].ascii != s2[i].ascii ) |
printf( "Mismatch at %d (ascii)\n", i ); |
if( s1[i].csym != s2[i].csym ) |
printf( "Mismatch at %d (csym)\n", i ); |
if( s1[i].csymf != s2[i].csymf ) |
printf( "Mismatch at %d (csymf)\n", i ); |
} |
} |
void TestResults( void ) |
/**********************/ |
{ |
size_t len; |
size_t wide_len; |
far_data++; // set ds outside DGROUP |
len = sizeof( MacroResults ); |
wide_len = sizeof( WideMacroResults ); |
CheckResults( MacroResults, FunctResults, TEST_ARRAY_SIZE ); |
VERIFY( !memcmp( MacroResults, FunctResults, len ) ); |
VERIFY( !memcmp( WideMacroResults, WideFunctResults, wide_len ) ); |
VERIFY( !memcmp( MacroResults, WideMacroResults, len ) ); |
VERIFY( !memcmp( MacroResults, WideFunctResults, len ) ); |
} |
void TestConversion( void ) |
/*************************/ |
{ |
int c, c1, c2; |
far_data++; // set ds outside DGROUP |
for( c = 0; c < 256; c++ ) { |
c1 = tolower( c ); |
c2 = toupper( c ); |
if( isalpha( c ) ) { |
if( islower( c ) ) |
VERIFY( (c1 == c) && (c2 != c) ); |
if( isupper( c ) ) |
VERIFY( (c1 != c) && (c2 == c) ); |
} else { |
VERIFY( !isalpha( c1 ) && !isalpha( c2 ) ); |
} |
} |
} |
void TestWideConversion( void ) |
/*****************************/ |
{ |
wchar_t c, c1, c2; |
far_data++; // set ds outside DGROUP |
for( c = 0; c < 1024; c++ ) { |
c1 = towlower( c ); |
c2 = towupper( c ); |
if( iswalpha( c ) ) { |
if( iswlower( c ) ) |
VERIFY( (c1 == c) && (c2 != c) ); |
if( iswupper( c ) ) |
VERIFY( (c1 != c) && (c2 == c) ); |
} else { |
VERIFY( !iswalpha( c1 ) && !iswalpha( c2 ) ); |
} |
} |
} |
int main( int argc, char *argv[] ) |
/********************************/ |
{ |
far_data++; // set ds outside DGROUP |
/*** Initialize ***/ |
strcpy( ProgramName, strlwr(argv[0]) ); |
/*** Test stuff ***/ |
TestClassifyMacro(); |
TestClassifyFunct(); |
TestClassifyWideMacro(); |
TestClassifyWideFunct(); |
TestResults(); |
TestConversion(); |
TestWideConversion(); |
/*** Print a pass/fail message and quit ***/ |
if( NumErrors == 0 ) { |
printf( "%s: SUCCESS.\n", ProgramName ); |
return( EXIT_SUCCESS ); |
} else { |
printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors ); |
return( EXIT_FAILURE ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/intwctrn.h |
---|
0,0 → 1,38 |
/**************************************************************************** |
* |
* 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: Identifiers for internal use by wctrans() and towctrans(). |
* |
****************************************************************************/ |
#ifndef INTWCTRN_H |
#define INTWCTRN_H |
#define WCTRANS_TOLOWER 128 |
#define WCTRANS_TOUPPER 129 |
#endif |
/programs/develop/open watcom/trunk/clib/char/intwctyp.h |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Identifiers for internal use by iswctype() and wctype(). |
* |
****************************************************************************/ |
#ifndef INTWCTYP_H |
#define INTWCTYP_H |
#define WCTYPE_ALNUM 1 |
#define WCTYPE_ALPHA 2 |
#define WCTYPE_CNTRL 3 |
#define WCTYPE_DIGIT 4 |
#define WCTYPE_GRAPH 5 |
#define WCTYPE_LOWER 6 |
#define WCTYPE_PRINT 7 |
#define WCTYPE_PUNCT 8 |
#define WCTYPE_SPACE 9 |
#define WCTYPE_UPPER 10 |
#define WCTYPE_XDIGIT 11 |
#define WCTYPE_BLANK 12 |
#endif |
/programs/develop/open watcom/trunk/clib/char/isalnum.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation of isalnum(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef isalnum |
_WCRTLINK int __F_NAME(isalnum,iswalnum)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & (_LOWER|_UPPER|_DIGIT) ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/isalpha.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation of isalpha(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef isalpha |
_WCRTLINK int __F_NAME(isalpha,iswalpha)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & (_LOWER|_UPPER) ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/isascii.c |
---|
0,0 → 1,43 |
/**************************************************************************** |
* |
* 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: Implementation of isascii(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#undef isascii |
_WCRTLINK int __F_NAME(isascii,iswascii)( INTCHAR_TYPE c ) |
{ |
return( (unsigned)(c) <= 0x7f ); |
} |
/programs/develop/open watcom/trunk/clib/char/isblank.c |
---|
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: Implementation if isblank(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#undef isblank |
_WCRTLINK int __F_NAME(isblank,iswblank)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( (c == ' ') || (c == '\t') ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/iscntrl.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation of iscntrl(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef iscntrl |
_WCRTLINK int __F_NAME(iscntrl,iswcntrl)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & _CNTRL ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/iscsym.c |
---|
0,0 → 1,45 |
/**************************************************************************** |
* |
* 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: Implementation of __iscsym(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include <ctype.h> |
#include "widechar.h" |
#include "istable.h" |
#undef __iscsym |
_WCRTLINK int (__iscsym)( int c ) |
{ |
if( IS_ASCII( c ) ) { |
return( (IsWhat( c ) & (_LOWER|_UPPER|_DIGIT)) || (c == '_') ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/iscsymf.c |
---|
0,0 → 1,45 |
/**************************************************************************** |
* |
* 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: Implementation of __iscsymf(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include <ctype.h> |
#include "widechar.h" |
#include "istable.h" |
#undef __iscsymf |
_WCRTLINK int (__iscsymf)( int c ) |
{ |
if( IS_ASCII( c ) ) { |
return( (IsWhat( c ) & (_LOWER|_UPPER)) || (c == '_') ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/isdigit.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation of isdigit(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef isdigit |
_WCRTLINK int __F_NAME(isdigit,iswdigit)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & _DIGIT ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/isgraph.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation if isgraph(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef isgraph |
_WCRTLINK int __F_NAME(isgraph,iswgraph)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII(c) ) { |
return( (IsWhat( c ) & (_PRINT|_SPACE)) == _PRINT ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/islower.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation of islower(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef islower |
_WCRTLINK int __F_NAME(islower,iswlower)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & _LOWER ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/isprint.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation if isprint(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef isprint |
_WCRTLINK int __F_NAME(isprint,iswprint)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & _PRINT ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/ispunct.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation of ispunct(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef ispunct |
_WCRTLINK int __F_NAME(ispunct,iswpunct)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & _PUNCT ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/isspace.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation if isspace(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef isspace |
_WCRTLINK int __F_NAME(isspace,iswspace)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & _SPACE ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/istable.c |
---|
0,0 → 1,295 |
/**************************************************************************** |
* |
* 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: Character classification table. |
* |
****************************************************************************/ |
#include "variety.h" |
#include <ctype.h> |
_WCRTLINKD const char _HUGEDATA _IsTable[257] = { |
#define ___0__ 0 |
/* -1,EOF */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 00,NUL */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 01,SOH */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 02,STX */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 03,ETX */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 04,EOT */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 05,ENQ */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 06,NAK */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 07,BEL */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 08,BS */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 09,TAB */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL, |
/* 0A,LF */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL, |
/* 0B,VT */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL, |
/* 0C,FF */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL, |
/* 0D,CR */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL, |
/* 0E,SI */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 0F,SO */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 10, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 11, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 12, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 13, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 14, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 15, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 16, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 17, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 18, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 19, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 1A, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 1B, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 1C, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 1D, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 1E, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 1F, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 20, */ ___0__|___0__|___0__|___0__|_PRINT|___0__|_SPACE|___0__, |
/* 21, ! */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 22, " */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 23, # */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 24, $ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 25, % */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 26, & */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 27, ' */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 28, ( */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 29, ) */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 2A, * */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 2B, + */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 2C, , */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 2D, - */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 2E, . */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 2F, / */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 30, 0 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 31, 1 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 32, 2 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 33, 3 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 34, 4 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 35, 5 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 36, 6 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 37, 7 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 38, 8 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 39, 9 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 3A, : */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 3B, ; */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 3C, < */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 3D, = */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 3E, > */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 3F, ? */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 40, @ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 41, A */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 42, B */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 43, C */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 44, D */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 45, E */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 46, F */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 47, G */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 48, H */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 49, I */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 4A, J */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 4B, K */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 4C, L */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 4D, M */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 4E, N */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 4F, O */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 50, P */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 51, Q */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 52, R */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 53, S */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 54, T */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 55, U */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 56, V */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 57, W */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 58, X */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 59, Y */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 5A, Z */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 5B, [ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 5C, \ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 5D, ] */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 5E, ^ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 5F, _ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 60, ` */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 61, a */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 62, b */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 63, c */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 64, d */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 65, e */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 66, f */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__, |
/* 67, g */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 68, h */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 69, i */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 6A, j */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 6B, k */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 6C, l */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 6D, m */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 6E, n */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 6F, o */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 70, p */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 71, q */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 72, r */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 73, s */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 74, t */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 75, u */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 76, v */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 77, w */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 78, x */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 79, y */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 7A, z */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__, |
/* 7B, { */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 7C, | */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 7D, } */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 7E, ~ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__, |
/* 7F,DEL */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL, |
/* 80, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 81, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 82, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 83, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 84, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 85, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 86, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 87, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 88, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 89, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 8A, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 8B, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 8C, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 8D, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 8E, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 8F, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 90, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 91, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 92, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 93, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 94, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 95, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 96, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 97, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 98, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 99, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 9A, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 9B, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 9C, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 9D, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 9E, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* 9F, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* A9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* AA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* AB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* AC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* AD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* AE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* AF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* B9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* BA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* BB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* BC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* BD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* BE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* BF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* C9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* CA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* CB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* CC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* CD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* CE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* CF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* D9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* DA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* DB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* DC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* DD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* DE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* DF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* E9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* EA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* EB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* EC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* ED, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* EE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* EF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* F9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* FA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* FB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* FC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* FD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* FE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__, |
/* FF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__ }; |
/programs/develop/open watcom/trunk/clib/char/istable.h |
---|
0,0 → 1,68 |
/**************************************************************************** |
* |
* 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: _IsTable accessors (with x86 optimized versions). |
* |
****************************************************************************/ |
#ifndef _ISTABLE_H_INCLUDED |
#define _ISTABLE_H_INCLUDED |
#if defined(__386__) |
extern int IsWhat( int ); |
#pragma aux IsWhat = \ |
"and eax,0xff" \ |
"mov al,_IsTable+0x1[eax]" \ |
parm loadds [eax] |
#elif defined(M_I86HM) |
extern int IsWhat( int ); |
#pragma aux IsWhat = \ |
"push bx" \ |
"mov bx,seg _IsTable" \ |
"mov ds,bx" \ |
"and ax,0xff" \ |
"mov bx,ax" \ |
"mov al,_IsTable+0x1[bx]" \ |
"pop bx" \ |
parm [ax] modify [ds] |
#elif defined(__I86__) |
extern int IsWhat( int ); |
#pragma aux IsWhat = \ |
"push bx" \ |
"and ax,0xff" \ |
"mov bx,ax" \ |
"mov al,_IsTable+0x1[bx]" \ |
"pop bx" \ |
parm loadds [ax] |
#else |
static int IsWhat( int c ) |
{ |
return( _IsTable[TO_ASCII( c )+1] ); |
} |
#endif |
#endif |
/programs/develop/open watcom/trunk/clib/char/isupper.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation of isupper(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef isupper |
_WCRTLINK int __F_NAME(isupper,iswupper)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & _UPPER ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/iswctype.c |
---|
0,0 → 1,54 |
/**************************************************************************** |
* |
* 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: Implementation if iswctype(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include <wctype.h> |
#include "intwctyp.h" |
/* Determine if the given character is of the specified type. */ |
_WCRTLINK int iswctype( wint_t wc, wctype_t desc ) |
{ |
switch( desc ) { |
case WCTYPE_ALNUM: return( iswalnum( wc ) ); |
case WCTYPE_ALPHA: return( iswalpha( wc ) ); |
case WCTYPE_BLANK: return( iswblank( wc ) ); |
case WCTYPE_CNTRL: return( iswcntrl( wc ) ); |
case WCTYPE_DIGIT: return( iswdigit( wc ) ); |
case WCTYPE_GRAPH: return( iswgraph( wc ) ); |
case WCTYPE_LOWER: return( iswlower( wc ) ); |
case WCTYPE_PRINT: return( iswprint( wc ) ); |
case WCTYPE_PUNCT: return( iswpunct( wc ) ); |
case WCTYPE_SPACE: return( iswspace( wc ) ); |
case WCTYPE_UPPER: return( iswupper( wc ) ); |
case WCTYPE_XDIGIT: return( iswxdigit( wc ) ); |
default: return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/isxdigit.c |
---|
0,0 → 1,48 |
/**************************************************************************** |
* |
* 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: Implementation if isxdigit(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#endif |
#include "istable.h" |
#undef isxdigit |
_WCRTLINK int __F_NAME(isxdigit,iswxdigit)( INTCHAR_TYPE c ) |
{ |
if( IS_ASCII( c ) ) { |
return( IsWhat( c ) & _XDIGT ); |
} else { |
return( 0 ); |
} |
} |
/programs/develop/open watcom/trunk/clib/char/tolower.c |
---|
0,0 → 1,45 |
/**************************************************************************** |
* |
* 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: Implementation of tolower(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wchar.h> |
#endif |
_WCRTLINK INTCHAR_TYPE __F_NAME(tolower,towlower)( INTCHAR_TYPE c ) |
{ |
if( c >= 'A' && c <= 'Z' ) { |
c = c - 'A' + 'a'; |
} |
return( c ); |
} |
/programs/develop/open watcom/trunk/clib/char/toupper.c |
---|
0,0 → 1,46 |
/**************************************************************************** |
* |
* 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: Implementation of toupper(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <ctype.h> |
#ifdef __WIDECHAR__ |
#include <wchar.h> |
#endif |
_WCRTLINK INTCHAR_TYPE __F_NAME(toupper,towupper)( INTCHAR_TYPE c ) |
{ |
if( c >= 'a' && c <= 'z' ) { |
c = c - 'a' + 'A'; |
} |
return( c ); |
} |
/programs/develop/open watcom/trunk/clib/char/towctrns.c |
---|
0,0 → 1,45 |
/**************************************************************************** |
* |
* 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: Implementation of towctrans(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include <wctype.h> |
#include "intwctrn.h" |
/* Transform character as specified by 'desc'. */ |
_WCRTLINK wint_t towctrans( wint_t wc, wctrans_t desc ) |
{ |
switch( desc ) { |
case WCTRANS_TOLOWER: return( towlower( wc ) ); |
case WCTRANS_TOUPPER: return( towupper( wc ) ); |
default: return( wc ); |
} |
} |
/programs/develop/open watcom/trunk/clib/convert/alphabet.c |
---|
0,0 → 1,33 |
/**************************************************************************** |
* |
* 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: Shared alphabet array for conversion of integers to ASCII. |
* |
****************************************************************************/ |
const char __based(__segname("_CONST")) __Alphabet[] = "0123456789abcdefghijklmnopqrstuvwxyz"; |
/programs/develop/open watcom/trunk/clib/convert/atoi.c |
---|
0,0 → 1,59 |
/**************************************************************************** |
* |
* 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 "variety.h" |
#include "widechar.h" |
#include <stdio.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#else |
#include <ctype.h> |
#endif |
_WCRTLINK int __F_NAME(atoi,_wtoi)( const CHAR_TYPE *p ) /* convert ASCII string to integer */ |
{ |
register int value; |
CHAR_TYPE sign; |
__ptr_check( p, 0 ); |
while( __F_NAME(isspace,iswspace)( *p ) ) ++p; |
sign = *p; |
if( sign == '+' || sign == '-' ) ++p; |
value = 0; |
while( __F_NAME(isdigit,iswdigit)(*p) ) { |
value = value * 10 + *p - '0'; |
++p; |
} |
if( sign == '-' ) value = - value; |
return( value ); |
} |
/programs/develop/open watcom/trunk/clib/convert/atol.c |
---|
0,0 → 1,61 |
/**************************************************************************** |
* |
* 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 "variety.h" |
#include "widechar.h" |
#include <stdio.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#else |
#include <ctype.h> |
#endif |
#include <stdlib.h> |
_WCRTLINK long int __F_NAME(atol,_wtol)( const CHAR_TYPE *p ) /* convert ASCII string to long integer */ |
{ |
register long int value; |
CHAR_TYPE sign; |
__ptr_check( p, 0 ); |
while( __F_NAME(isspace,iswspace)( *p ) ) ++p; |
sign = *p; |
if( sign == '+' || sign == '-' ) ++p; |
value = 0; |
while( __F_NAME(isdigit,iswdigit)(*p) ) { |
value = value * 10 + *p - '0'; |
++p; |
} |
if( sign == '-' ) value = - value; |
return( value ); |
} |
/programs/develop/open watcom/trunk/clib/convert/atoll.c |
---|
0,0 → 1,61 |
/**************************************************************************** |
* |
* 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: ASCII to long long conversion routine. |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include "watcom.h" |
#include <stdio.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#else |
#include <ctype.h> |
#endif |
#include <stdlib.h> |
_WCRTLINK long long int __F_NAME(atoll,_wtoll)( const CHAR_TYPE *p ) /* convert ASCII string to long long int */ |
{ |
unsigned long long int value = 0; |
CHAR_TYPE sign; |
__ptr_check( p, 0 ); |
while( __F_NAME(isspace,iswspace)( *p ) ) |
++p; |
sign = *p; |
if( sign == '+' || sign == '-' ) ++p; |
while( __F_NAME(isdigit,iswdigit)(*p) ) { |
value = value * 10 + *p - '0'; |
++p; |
} |
if( sign == '-' ) |
value = -value; |
return( value ); |
} |
/programs/develop/open watcom/trunk/clib/convert/fdmd386.asm |
---|
0,0 → 1,118 |
;***************************************************************************** |
;* |
;* 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 |
include struct.inc |
modstart fdmd386 |
xdefp "C",_dieeetomsbin |
defpe _dieeetomsbin |
ifdef __STACK__ |
mov eax,dword ptr +4H[esp] ; load src double ptr |
mov edx,dword ptr +8H[esp] ; load dst double ptt |
else |
push ecx ; save register |
endif |
; At this point: |
; eax - ptr to IEEE source double |
; edx - ptr to MBF dest double |
; ecx - spare register |
; Check for IEEE Underflow first |
mov ecx,+4h[eax] ; load IEEE double (hi) |
rol ecx,1 ; rotate sign bit away for comparisons |
cmp ecx,6fe00000H ; exponent < 1023 - 128 ? |
jae IEEENoUnderflow ; yes, jump |
; IEEE Underflow, store MBF 0.0 |
xor eax,eax ; make 0 |
mov [edx],eax ; store MBF 0.0 (lo) |
mov +4h[edx],eax ; store MBF 0.0 (hi) |
ifndef __STACK__ |
pop ecx ; clean up |
endif |
ret ; return 0 (no overflow) |
; Check for IEEE Overflow |
IEEENoUnderflow: |
cmp ecx,8fc00000H ; exponent >= 1023 + 127 ? |
jae IEEEOverflow ; yes, jump |
; General IEEE case, load rest of double |
mov eax,[eax] ; load IEEE double (lo) |
ror ecx,1 ; rotate sign bit back into place |
; At this point: |
; ecx:eax - IEEE source double |
; edx - ptr to MBF dest double |
push ecx ; save sign bit |
; shift exponent & mantissa into place |
shld ecx,eax,3 ; shift exponent and mantissa |
shl eax,3 ; : |
mov [edx],eax ; save mantissa |
rol ecx,9 ; convert IEEE exponent to MBF |
shr ecx,1 ; : |
adc cl,cl ; : |
add cl,82h ; correct MBF exponent |
pop eax ; restore sign bit |
add eax,eax ; shift sign bit into carry |
adc ecx,ecx ; add in sign bit |
ror ecx,9 ; MBF double (hi) |
mov +4h[edx],ecx ; store MBF double (hi) |
xor eax,eax ; 0 |
ifndef __STACK__ |
pop ecx ; clean up |
endif |
ret ; return 0 (no overflow) |
; IEEE Overflow, store maximum MBF, preserving sign |
IEEEOverflow: or ecx,0FFFFFFFFEh ; set MBF exponent and mantissa to maximum |
mov eax,ecx ; : |
ror ecx,9 ; rotate sign bit into place for MBF |
sar eax,1 ; now -1 |
mov +4h[edx],ecx ; store IEEE double (hi) |
mov [edx],eax ; store IEEE double (lo) |
neg eax ; 1 |
ifndef __STACK__ |
pop ecx ; clean up |
endif |
ret ; return 1 (overflow) |
endproc _dieeetomsbin |
endmod |
end |
/programs/develop/open watcom/trunk/clib/convert/fsms386.asm |
---|
0,0 → 1,109 |
;***************************************************************************** |
;* |
;* 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 |
include struct.inc |
modstart fsms386 |
xdefp "C",_fieeetomsbin |
defpe _fieeetomsbin |
ifdef __STACK__ |
mov eax,dword ptr +4H[esp] |
mov edx,dword ptr +8H[esp] |
endif |
; At this point: |
; eax - ptr to IEEE source float |
; edx - ptr to MBF dest float |
mov eax,[eax] ; load IEEE float |
test eax,7fe00000h ; IEEE exponent != 0 or convertable |
; denormal ? |
jne IEEENonZero ; : |
; IEEE Zero or IEEE unconvertable denormal, store MBF Zero |
xor eax,eax ; 0 |
mov [edx],eax ; store MBF 0.0F |
ret ; return 0 (no overflow) |
; At this point: |
; eax - IEEE source float |
; edx - ptr to MBF dest float |
IEEENonZero: rol eax,9 ; rotate for exponent analysis |
test al,al ; IEEE convertable denormal ? |
je IEEEDenormal ; yes, jump |
add al,2 ; MBF exponent = IEEE exponent + 2 |
jc IEEEOverflow ; jump if overflow |
shr eax,1 ; rotate sign bit and exponent |
adc al,al ; : |
adc eax,eax ; : |
ror eax,9 ; rotate so MBF float |
MBFStore: mov [edx],eax ; store MBF float |
xor eax,eax ; 0 |
ret ; return 0 (no overflow) |
; One of leading 2 bits of mantissa is a 1 |
IEEEDenormal: |
ifndef __STACK__ |
push ecx ; save register |
endif |
mov ecx,eax ; save sign bit and exponent |
and ah,0FEh ; eliminate sign bit |
DenormalLoop: inc ecx ; increment count |
add eax,eax ; shift mantissa |
jnc DenormalLoop ; loop while no implied 1 |
xor ecx,3h ; invert count (new exponent) |
shr ecx,1 ; rotate exponent and sign bit |
adc cl,cl ; : |
adc ecx,ecx ; : |
shrd eax,ecx,9 ; combine mantissa (eax) and |
; exponent& sign bit (ecx) |
ifndef __STACK__ |
pop ecx ; restore register |
endif |
jmp MBFStore ; continue |
IEEEOverflow: rol eax,15 ; rotate sign bit into place |
or eax,0FF7FFFFFh ; set MBF exponent and mantissa to |
; maximum but preserve MBF sign |
mov [edx],eax ; store MBF float |
and eax,1 ; 1 |
ret ; return 1 (overflow) |
endproc _fieeetomsbin |
endmod |
end |
/programs/develop/open watcom/trunk/clib/convert/itoa.c |
---|
0,0 → 1,106 |
/**************************************************************************** |
* |
* 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: Implementation of itoa() and utoa(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <stdlib.h> |
extern const char __based(__segname("_CONST")) __Alphabet[]; |
unsigned __udiv( unsigned, unsigned _WCNEAR * ); |
#if defined(__386__) |
#pragma aux __udiv = \ |
"xor edx,edx" \ |
"div dword ptr [ebx]" \ |
"mov [ebx],eax" \ |
parm caller [eax] [ebx] \ |
modify exact [eax edx] \ |
value [edx]; |
#elif defined(M_I86) && defined(__BIG_DATA__) |
#pragma aux __udiv = \ |
"xor dx,dx" \ |
"div word ptr ss:[bx]" \ |
"mov ss:[bx],ax" \ |
parm caller [ax] [bx] \ |
modify exact [ax dx] \ |
value [dx]; |
#elif defined(M_I86) && defined(__SMALL_DATA__) |
#pragma aux __udiv = \ |
"xor dx,dx" \ |
"div word ptr [bx]" \ |
"mov [bx],ax" \ |
parm caller [ax] [bx] \ |
modify exact [ax dx] \ |
value [dx]; |
#endif |
_WCRTLINK CHAR_TYPE *__F_NAME(utoa,_utow)( unsigned value, CHAR_TYPE *buffer, int radix ) |
{ |
CHAR_TYPE *p = buffer; |
char *q; |
unsigned rem; |
unsigned quot; |
char buf[34]; // only holds ASCII so 'char' is OK |
buf[0] = '\0'; |
q = &buf[1]; |
do { |
#if defined(_M_IX86) && defined(__WATCOMC__) |
quot = radix; |
rem = __udiv( value, (unsigned _WCNEAR *) " ); |
#else |
rem = value % radix; |
quot = value / radix; |
#endif |
*q = __Alphabet[rem]; |
++q; |
value = quot; |
} while( value != 0 ); |
while( (*p++ = (CHAR_TYPE)*--q) ) |
; |
return( buffer ); |
} |
_WCRTLINK CHAR_TYPE *__F_NAME(itoa,_itow)( int value, CHAR_TYPE *buffer, int radix ) |
{ |
CHAR_TYPE *p = buffer; |
if( radix == 10 ) { |
if( value < 0 ) { |
*p++ = '-'; |
value = - value; |
} |
} |
__F_NAME(utoa,_utow)( value, p, radix ); |
return( buffer ); |
} |
/programs/develop/open watcom/trunk/clib/convert/lltoa.c |
---|
0,0 → 1,212 |
/**************************************************************************** |
* |
* 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: Long long integer to ASCII conversion routines. |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include "watcom.h" |
#include "clibi64.h" |
#include <stdlib.h> |
extern const char __based(__segname("_CONST")) __Alphabet[]; |
#if defined(__386__) || defined(M_I86) |
unsigned long long __ulldiv( unsigned long long, unsigned _WCNEAR *); |
#if defined(__386__) |
#pragma aux __ulldiv = \ |
"xor ecx,ecx" /* set high word of quotient to 0 */ \ |
"cmp edx,dword ptr[ebx]" /* if quotient will be >= 4G */ \ |
"jb less4g" /* then */ \ |
"mov ecx,eax" /* - save low word of dividend */ \ |
"mov eax,edx" /* - get high word of dividend */ \ |
"xor edx,edx" /* - zero high part */ \ |
"div dword ptr[ebx]" /* - divide into high part of dividend */ \ |
"xchg eax,ecx" /* - swap high part of quot,low word of dvdnd */ \ |
"less4g:" \ |
"div dword ptr[ebx]" /* calculate low part */ \ |
"mov [ebx],edx" /* store remainder */ \ |
parm [eax edx] [ebx] value [eax ecx]; |
#elif defined(M_I86) && defined(__BIG_DATA__) |
#pragma aux __ulldiv = \ |
"mov di,dx" /* initial dividend = ax:bx:cx:dx(di); save dx */ \ |
"test ax,ax" /* less work to do if ax == 0 */ \ |
"jz skip1" \ |
"mov dx,ax" /* dx:ax = ax:bx */ \ |
"mov ax,bx" \ |
"xor bx,bx" /* set word 3 of quotient to 0 */ \ |
"cmp dx,word ptr ss:[si]" /* if quotient will be >= 64K */ \ |
"jb div2" /* then */ \ |
"mov bx,ax" /* restore word 2 of dividend */ \ |
"mov ax,dx" /* restore word 3 of dividend */ \ |
"xor dx,dx" /* - zero high part */ \ |
"div word ptr ss:[si]" /* - divide into word 3 of dividend */ \ |
"xchg ax,bx" /* - swap word 3,word 2 of dvdnd */ \ |
"div2:" \ |
"div word ptr ss:[si]" /* - divide into word 2 of dividend */ \ |
"xchg ax,cx" /* - swap word 2,word 1 of dvdnd */ \ |
"div3:" \ |
"div word ptr ss:[si]" /* - divide into word 1 of dividend */ \ |
"xchg ax,di" /* - swap word 1,word 0 of dvdnd */ \ |
"div4:" \ |
"div word ptr ss:[si]" /* calculate low part */ \ |
"mov ss:[si],dx" /* store remainder */ \ |
"mov dx,ax" /* dx is word 0 */ \ |
"mov ax,bx" /* ax:bx:cx:dx = bx:cx:di:ax */ \ |
"mov bx,cx" \ |
"mov cx,di" \ |
"jmp end_div" \ |
"skip1:" /* ax==0 */ \ |
"test bx,bx" /* even less work to do if bx == 0 too */ \ |
"jz skip2" \ |
"mov dx,bx" /* dx:ax = bx:cx */ \ |
"mov ax,cx" \ |
"xor bx,bx" /* set word 3 of quotient to 0 */ \ |
"xor cx,cx" /* set word 2 of quotient to 0 */ \ |
"cmp dx,word ptr ss:[si]" /* if quotient will be < 64K */ \ |
"jb div3" /* then need to do two divisions */ \ |
"mov cx,ax" /* restore word 1 of dividend */ \ |
"mov ax,dx" /* restore word 2 of dividend */ \ |
"xor dx,dx" /* zero high part */ \ |
"jmp div2" /* do three divisions*/ \ |
"skip2:" /* ax==bx==0 */ \ |
"mov dx,cx" /* dx:ax = cx:di */ \ |
"mov ax,di" \ |
"xor cx,cx" /* set word 2 of quotient to 0 */ \ |
"xor di,di" /* set word 1 of quotient to 0 */ \ |
"cmp dx,word ptr ss:[si]" /* if quotient will be < 64K */ \ |
"jb div4" /* then only one division to do */ \ |
"mov di,ax" /* restore word 0 of dividend */ \ |
"mov ax,dx" /* restore word 1 of dividend */ \ |
"xor dx,dx" /* zero high part */ \ |
"jmp div3" /* do two divisions */ \ |
"end_div:" \ |
parm [ax bx cx dx] [si] modify [di] value [ax bx cx dx]; |
#elif defined(M_I86) && defined(__SMALL_DATA__) |
#pragma aux __ulldiv = \ |
"mov di,dx" /* initial dividend = ax:bx:cx:dx(di); save dx */ \ |
"test ax,ax" /* less work to do if ax == 0 */ \ |
"jz skip1" \ |
"mov dx,ax" /* dx:ax = ax:bx */ \ |
"mov ax,bx" \ |
"xor bx,bx" /* set word 3 of quotient to 0 */ \ |
"cmp dx,word ptr[si]" /* if quotient will be >= 64K */ \ |
"jb div2" /* then */ \ |
"mov bx,ax" /* restore word 2 of dividend */ \ |
"mov ax,dx" /* restore word 3 of dividend */ \ |
"xor dx,dx" /* - zero high part */ \ |
"div word ptr[si]" /* - divide into word 3 of dividend */ \ |
"xchg ax,bx" /* - swap word 3,word 2 of dvdnd */ \ |
"div2:" \ |
"div word ptr[si]" /* - divide into word 2 of dividend */ \ |
"xchg ax,cx" /* - swap word 2,word 1 of dvdnd */ \ |
"div3:" \ |
"div word ptr[si]" /* - divide into word 1 of dividend */ \ |
"xchg ax,di" /* - swap word 1,word 0 of dvdnd */ \ |
"div4:" \ |
"div word ptr[si]" /* calculate low part */ \ |
"mov [si],dx" /* store remainder */ \ |
"mov dx,ax" /* dx is word 0 */ \ |
"mov ax,bx" /* ax:bx:cx:dx = bx:cx:di:ax */ \ |
"mov bx,cx" \ |
"mov cx,di" \ |
"jmp end_div" \ |
"skip1:" /* dx==0 */ \ |
"test bx,bx" /* even less work to do if bx == 0 too */ \ |
"jz skip2" \ |
"mov dx,bx" /* dx:ax = bx:cx */ \ |
"mov ax,cx" \ |
"xor bx,bx" /* set word 3 of quotient to 0 */ \ |
"xor cx,cx" /* set word 2 of quotient to 0 */ \ |
"cmp dx,word ptr[si]" /* if quotient will be < 64K */ \ |
"jb div3" /* then need to do two divisions */ \ |
"mov cx,ax" /* restore word 1 of dividend */ \ |
"mov ax,dx" /* restore word 2 of dividend */ \ |
"xor dx,dx" /* zero high part */ \ |
"jmp div2" /* do three divisions*/ \ |
"skip2:" /* ax==bx==0 */ \ |
"mov dx,cx" /* dx:ax = cx:di */ \ |
"mov ax,di" \ |
"xor cx,cx" /* set word 2 of quotient to 0 */ \ |
"xor di,di" /* set word 1 of quotient to 0 */ \ |
"cmp dx,word ptr[si]" /* if quotient will be < 64K */ \ |
"jb div4" /* then only one division to do */ \ |
"mov di,ax" /* restore word 0 of dividend */ \ |
"mov ax,dx" /* restore word 1 of dividend */ \ |
"xor dx,dx" /* zero high part */ \ |
"jmp div3" /* do two divisions */ \ |
"end_div:" \ |
parm [ax bx cx dx] [si] modify [di] value [ax bx cx dx]; |
#endif |
#endif |
_WCRTLINK CHAR_TYPE *__F_NAME(ulltoa,_ulltow)( |
unsigned long long int value, |
CHAR_TYPE *buffer, |
int radix ) |
{ |
CHAR_TYPE *p = buffer; |
char *q; |
unsigned rem; |
auto char buf[66]; // only holds ASCII so 'char' is OK |
buf[0] = '\0'; |
q = &buf[1]; |
do { |
#if defined(__386__) || defined(M_I86) |
rem = radix; |
value = __ulldiv( value, (unsigned _WCNEAR *) &rem ); |
#else |
rem = value % radix; |
value = value / radix; |
#endif |
*q = __Alphabet[ rem ]; |
++q; |
} while( value ); |
while( *p++ = (CHAR_TYPE)*--q ); |
return( buffer ); |
} |
_WCRTLINK CHAR_TYPE *__F_NAME(lltoa,_lltow)( |
long long int value, |
CHAR_TYPE *buffer, |
int radix ) |
{ |
register CHAR_TYPE *p = buffer; |
if( radix == 10 ) { |
if( value < 0 ) { |
*p++ = '-'; |
value = -value; |
} |
} |
__F_NAME(ulltoa,_ulltow)( value, p, radix ); |
return( buffer ); |
} |
/programs/develop/open watcom/trunk/clib/convert/ltoa.c |
---|
0,0 → 1,120 |
/**************************************************************************** |
* |
* 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: Implementation of ltoa(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <stdlib.h> |
extern const char __based(__segname("_CONST")) __Alphabet[]; |
unsigned long __uldiv( unsigned long, unsigned _WCNEAR * ); |
#if defined(__386__) |
#pragma aux __uldiv = \ |
"xor edx,edx" \ |
"div dword ptr [ebx]" \ |
"mov [ebx],edx" \ |
parm caller [eax] [ebx] \ |
modify exact [eax edx] \ |
value [eax]; |
#elif defined(M_I86) && defined(__BIG_DATA__) |
#pragma aux __uldiv = \ |
"xor cx,cx" \ |
"cmp dx,ss:[bx]" \ |
"jb short SMALL_ENOUGH" \ |
"xchg ax,dx" \ |
"xchg cx,dx" \ |
"div word ptr ss:[bx]" \ |
"xchg ax,cx" \ |
"SMALL_ENOUGH:" \ |
"div word ptr ss:[bx]" \ |
"mov ss:[bx],dx" \ |
"mov dx,cx" \ |
parm caller [ax dx] [bx] \ |
modify exact [ax cx dx] \ |
value [ax dx]; |
#elif defined(M_I86) && defined(__SMALL_DATA__) |
#pragma aux __uldiv = \ |
"xor cx,cx" \ |
"cmp dx,[bx]" \ |
"jb short SMALL_ENOUGH" \ |
"xchg ax,dx" \ |
"xchg cx,dx" \ |
"div word ptr [bx]" \ |
"xchg ax,cx" \ |
"SMALL_ENOUGH:" \ |
"div word ptr [bx]" \ |
"mov [bx],dx" \ |
"mov dx,cx" \ |
parm caller [ax dx] [bx] \ |
modify exact [ax cx dx] \ |
value [ax dx]; |
#endif |
_WCRTLINK CHAR_TYPE *__F_NAME(ultoa,_ultow)( unsigned long value, CHAR_TYPE *buffer, int radix ) |
{ |
CHAR_TYPE *p = buffer; |
char *q; |
unsigned rem; |
char buf[34]; // only holds ASCII so 'char' is OK |
buf[0] = '\0'; |
q = &buf[1]; |
do { |
#if defined(_M_IX86) && defined(__WATCOMC__) |
rem = radix; |
value = __uldiv( value, (unsigned _WCNEAR *) &rem ); |
#else |
rem = value % radix; |
value = value / radix; |
#endif |
*q = __Alphabet[rem]; |
++q; |
} while( value != 0 ); |
while( (*p++ = (CHAR_TYPE)*--q) ) |
; |
return( buffer ); |
} |
_WCRTLINK CHAR_TYPE *__F_NAME(ltoa,_ltow)( long value, CHAR_TYPE *buffer, int radix ) |
{ |
CHAR_TYPE *p = buffer; |
if( radix == 10 ) { |
if( value < 0 ) { |
*p++ = '-'; |
value = - value; |
} |
} |
__F_NAME(ultoa,_ultow)( value, p, radix ); |
return( buffer ); |
} |
/programs/develop/open watcom/trunk/clib/convert/mdfd386.asm |
---|
0,0 → 1,105 |
;***************************************************************************** |
;* |
;* 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 |
include struct.inc |
modstart mdfd386 |
xdefp "C",_dmsbintoieee |
defpe _dmsbintoieee |
ifdef __STACK__ |
mov eax,dword ptr +4H[esp] |
mov edx,dword ptr +8H[esp] |
else |
push ecx |
endif |
; At this point: |
; eax - ptr to MBF source double |
; edx - ptr to IEEE dest double |
; ecx - spare register |
; Check for and process MBF 0.0 first |
mov ecx,+4h[eax] ; load MBF double (hi) |
test ecx,0ff000000h ; MBF exponent = 0 ? |
jne MBFNonZero ; no, jump |
; MBF 0.0, store IEEE 0.0 |
xor eax,eax ; make 0 |
mov [edx],eax ; store IEEE 0.0 (lo) |
mov +4h[edx],eax ; store IEEE 0.0 (hi) |
ifndef __STACK__ |
pop ecx ; clean up |
endif |
ret ; return 0 (no overflow) |
MBFNonZero: mov eax,[eax] ; load MBF double (lo) |
; At this point: |
; ecx:eax - MBF source double |
; edx - ptr to IEEE dest double |
rol ecx,9 ; rotate exponent & sign bit low |
shr ecx,1 ; move sign bit before exponent |
rcr cl,1 ; : |
adc ecx,ecx ; : |
ror ecx,9 ; rotate exponent & sign bit back |
; shift mantissa into place |
shrd eax,ecx,2 ; shift mantissa |
sar ecx,3 ; shift exponent & mantissa, save sign bit |
rcr eax,1 ; shift mantissa |
jc MBFRound ; jump if rounding up |
and ecx,8FFFFFFFh ; mask out surplus sign bits |
add ecx,37e00000h ; convert MBF to IEEE exponent |
IEEEStore: |
mov [edx],eax ; store IEEE double (lo) |
mov +4h[edx],ecx ; store IEEE double (hi) |
xor eax,eax ; 0 |
ifndef __STACK__ |
pop ecx ; clean up |
endif |
ret ; return 0 (no overflow) |
; add rounding bit |
MBFRound: and ecx,8FFFFFFFh ; mask out surplus sign bits |
add eax,1 ; add round bit |
adc ecx,37e00000h ; convert MBF to IEEE exponent |
jmp IEEEStore ; store result |
endproc _dmsbintoieee |
endmod |
end |
/programs/develop/open watcom/trunk/clib/convert/msfs386.asm |
---|
0,0 → 1,93 |
;***************************************************************************** |
;* |
;* 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 |
include struct.inc |
modstart msfs386 |
xdefp "C",_fmsbintoieee |
defpe _fmsbintoieee |
ifdef __STACK__ |
mov eax,dword ptr +4H[esp] |
mov edx,dword ptr +8H[esp] |
endif |
; At this point: |
; eax - ptr to MBF source float |
; edx - ptr to IEEE dest float |
mov eax,[eax] ; load MBF float |
; MBF exponent = 0 ? |
test eax,0ff000000h |
jne MBFNonZero ; yes, jump |
xor eax,eax ; IEEE 0.0 |
mov [edx],eax ; store IEEE float |
ret ; return 0 (no overflow) |
; At this point: |
; eax - MBF source float |
; edx - ptr to IEEE dest float |
MBFNonZero: rol eax,9 ; rotate exponent for better analysis |
shr eax,1 ; shift out |
rcr al,1 ; move sign bit |
adc eax,eax ; shift back |
sub al,2 ; convert exponent |
jc MBFExp1 ; jump if MBF exponent 1 |
je MBFExp2 ; jump if MBF exponent 2 |
ror eax,9 ; rotate so IEEE float |
IEEEStore: |
mov [edx],eax ; store IEEE float |
xor eax,eax ; return 0 (no overflow) |
ret ; : |
MBFExp1: and al,1 ; zero exponent except implied 1 |
ror eax,9 ; rotate so IEEE float |
sar eax,2 ; convert to IEEE denormal |
adc eax,0 ; add in round bit |
and eax,80FFFFFFh ; zero surplus sign bits |
jmp short IEEEStore ; continue |
MBFExp2: or al,1 ; set implied 1 |
ror eax,9 ; rotate so IEEE float |
sar eax,1 ; convert to IEEE denormal |
adc eax,0 ; add in round bit |
and eax,80FFFFFFh ; zero surplus sign bit |
jmp short IEEEStore ; continue |
endproc _fmsbintoieee |
endmod |
end |
/programs/develop/open watcom/trunk/clib/convert/strtol.c |
---|
0,0 → 1,148 |
/**************************************************************************** |
* |
* 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 "variety.h" |
#include "widechar.h" |
#include <stdio.h> |
#include <stdlib.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#else |
#include <ctype.h> |
#endif |
#include <errno.h> |
#include <limits.h> |
#include "seterrno.h" |
/* |
* this table is the largest value that can safely be multiplied |
* by the associated base without overflowing |
*/ |
static unsigned long nearly_overflowing[] = { |
ULONG_MAX / 2, ULONG_MAX / 3, ULONG_MAX / 4, ULONG_MAX / 5, |
ULONG_MAX / 6, ULONG_MAX / 7, ULONG_MAX / 8, ULONG_MAX / 9, |
ULONG_MAX / 10, ULONG_MAX / 11, ULONG_MAX / 12, ULONG_MAX / 13, |
ULONG_MAX / 14, ULONG_MAX / 15, ULONG_MAX / 16, ULONG_MAX / 17, |
ULONG_MAX / 18, ULONG_MAX / 19, ULONG_MAX / 20, ULONG_MAX / 21, |
ULONG_MAX / 22, ULONG_MAX / 23, ULONG_MAX / 24, ULONG_MAX / 25, |
ULONG_MAX / 26, ULONG_MAX / 27, ULONG_MAX / 28, ULONG_MAX / 29, |
ULONG_MAX / 30, ULONG_MAX / 31, ULONG_MAX / 32, ULONG_MAX / 33, |
ULONG_MAX / 34, ULONG_MAX / 35, ULONG_MAX / 36 |
}; |
#define hexstr(p) (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) |
static int radix_value( CHAR_TYPE c ) |
{ |
if( c >= '0' && c <= '9' ) return( c - '0' ); |
c = __F_NAME(tolower,towlower)(c); |
if( c >= 'a' && c <= 'i' ) return( c - 'a' + 10 ); |
if( c >= 'j' && c <= 'r' ) return( c - 'j' + 19 ); |
if( c >= 's' && c <= 'z' ) return( c - 's' + 28 ); |
return( 37 ); |
} |
static unsigned long int _stol( const CHAR_TYPE *nptr,CHAR_TYPE **endptr,int base,int who) |
{ |
const CHAR_TYPE *p; |
const CHAR_TYPE *startp; |
int digit; |
unsigned long int value; |
unsigned long int prev_value; |
CHAR_TYPE sign; |
char overflow; /*overflow is used as a flag so it does not |
*need to be of type CHAR_TYPE */ |
if( endptr != NULL ) *endptr = (CHAR_TYPE *)nptr; |
p = nptr; |
while( __F_NAME(isspace,iswspace)(*p) ) ++p; |
sign = *p; |
if( sign == '+' || sign == '-' ) ++p; |
if( base == 0 ) { |
if( hexstr(p) ) base = 16; |
else if( *p == '0' ) base = 8; |
else base = 10; |
} |
if( base < 2 || base > 36 ) { |
__set_errno( EDOM ); |
return( 0 ); |
} |
if( base == 16 ) { |
if( hexstr(p) ) p += 2; /* skip over '0x' */ |
} |
startp = p; |
overflow = 0; |
value = 0; |
for(;;) { |
digit = radix_value( *p ); |
if( digit >= base ) break; |
if( value > nearly_overflowing[base-2] ) overflow = 1; |
prev_value = value; |
value = value * base + digit; |
if( value < prev_value ) overflow = 1; |
++p; |
} |
if( p == startp ) p = nptr; |
if( endptr != NULL ) *endptr = (CHAR_TYPE *)p; |
if( who == 1 ) { |
if( value >= 0x80000000 ) { |
if( value == 0x80000000 && sign == '-' ) { |
; /* OK */ |
} else { |
overflow = 1; |
} |
} |
} |
if( overflow ) { |
__set_errno( ERANGE ); |
if( who == 0 ) return( ULONG_MAX ); |
if( sign == '-' ) return( LONG_MIN ); |
return( LONG_MAX ); |
} |
if( sign == '-' ) value = - value; |
return( value ); |
} |
_WCRTLINK unsigned long int __F_NAME(strtoul,wcstoul)( const CHAR_TYPE *nptr, |
CHAR_TYPE **endptr, int base ) |
{ |
return( _stol( nptr, endptr, base, 0 ) ); |
} |
_WCRTLINK long int __F_NAME(strtol,wcstol)( const CHAR_TYPE *nptr, CHAR_TYPE **endptr, int base ) |
{ |
return( _stol( nptr, endptr, base, 1 ) ); |
} |
/programs/develop/open watcom/trunk/clib/convert/strtoll.c |
---|
0,0 → 1,177 |
/**************************************************************************** |
* |
* 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: String to long long conversion routines. |
* |
****************************************************************************/ |
#include "variety.h" |
#include "widechar.h" |
#include <stdio.h> |
#include <stdlib.h> |
#include <inttypes.h> |
#ifdef __WIDECHAR__ |
#include <wctype.h> |
#else |
#include <ctype.h> |
#endif |
#include <errno.h> |
#include <limits.h> |
#include "seterrno.h" |
/* This is heavily based on strtol() implementation; however this code needs |
* to use 64-bit arithmetic and there is little need to drag in all the |
* supporting code for people who just need 16- or 32-bit string to integer |
* conversion. |
*/ |
/* |
* this table is the largest value that can safely be multiplied |
* by the associated base without overflowing |
*/ |
static unsigned long long nearly_overflowing[] = { |
ULLONG_MAX / 2, ULLONG_MAX / 3, ULLONG_MAX / 4, ULLONG_MAX / 5, |
ULLONG_MAX / 6, ULLONG_MAX / 7, ULLONG_MAX / 8, ULLONG_MAX / 9, |
ULLONG_MAX / 10, ULLONG_MAX / 11, ULLONG_MAX / 12, ULLONG_MAX / 13, |
ULLONG_MAX / 14, ULLONG_MAX / 15, ULLONG_MAX / 16, ULLONG_MAX / 17, |
ULLONG_MAX / 18, ULLONG_MAX / 19, ULLONG_MAX / 20, ULLONG_MAX / 21, |
ULLONG_MAX / 22, ULLONG_MAX / 23, ULLONG_MAX / 24, ULLONG_MAX / 25, |
ULLONG_MAX / 26, ULLONG_MAX / 27, ULLONG_MAX / 28, ULLONG_MAX / 29, |
ULLONG_MAX / 30, ULLONG_MAX / 31, ULLONG_MAX / 32, ULLONG_MAX / 33, |
ULLONG_MAX / 34, ULLONG_MAX / 35, ULLONG_MAX / 36 |
}; |
static int radix_value( CHAR_TYPE c ) |
{ |
if( c >= '0' && c <= '9' ) return( c - '0' ); |
c = __F_NAME(tolower,towlower)(c); |
if( c >= 'a' && c <= 'i' ) return( c - 'a' + 10 ); |
if( c >= 'j' && c <= 'r' ) return( c - 'j' + 19 ); |
if( c >= 's' && c <= 'z' ) return( c - 's' + 28 ); |
return( 37 ); |
} |
#define hexstr(p) (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) |
static unsigned long long int _stoll( const CHAR_TYPE *nptr, CHAR_TYPE **endptr, int base, int who ) |
{ |
const CHAR_TYPE *p; |
const CHAR_TYPE *startp; |
int digit; |
unsigned long long int value; |
unsigned long long int prev_value; |
CHAR_TYPE sign; |
char overflow; /*overflow is used as a flag so it does not |
*need to be of type CHAR_TYPE */ |
if( endptr != NULL ) |
*endptr = (CHAR_TYPE *)nptr; |
p = nptr; |
while( __F_NAME(isspace,iswspace)(*p) ) |
++p; |
sign = *p; |
if( sign == '+' || sign == '-' ) |
++p; |
if( base == 0 ) { |
if( hexstr(p) ) |
base = 16; |
else if( *p == '0' ) |
base = 8; |
else |
base = 10; |
} |
if( base < 2 || base > 36 ) { |
__set_errno( EDOM ); |
return( 0 ); |
} |
if( base == 16 ) { |
if( hexstr(p) ) |
p += 2; /* skip over '0x' */ |
} |
startp = p; |
overflow = 0; |
value = 0; |
for(;;) { |
digit = radix_value( *p ); |
if( digit >= base ) |
break; |
if( value > nearly_overflowing[base-2] ) |
overflow = 1; |
prev_value = value; |
value = value * base + digit; |
if( value < prev_value ) |
overflow = 1; |
++p; |
} |
if( p == startp ) |
p = nptr; |
if( endptr != NULL ) |
*endptr = (CHAR_TYPE *)p; |
if( who == 1 ) { |
if( value >= 0x8000000000000000 ) { |
if( value == 0x8000000000000000 && sign == '-' ) { |
; /* OK */ |
} else { |
overflow = 1; |
} |
} |
} |
if( overflow ) { |
__set_errno( ERANGE ); |
if( who == 0 ) |
return( ULLONG_MAX ); |
if( sign == '-' ) |
return( LLONG_MIN ); |
return( LLONG_MAX ); |
} |
if( sign == '-' ) |
value = - value; |
return( value ); |
} |
_WCRTLINK unsigned long long int __F_NAME(strtoull,wcstoull)( const CHAR_TYPE *nptr, CHAR_TYPE **endptr, int base ) |
{ |
return( _stoll( nptr, endptr, base, 0 ) ); |
} |
_WCRTLINK long long int __F_NAME(strtoll,wcstoll)( const CHAR_TYPE *nptr, CHAR_TYPE **endptr, int base ) |
{ |
return( _stoll( nptr, endptr, base, 1 ) ); |
} |
/* Assuming that intmax_t is equal to long long and uintmax_t to unsigned long long */ |
_WCRTLINK uintmax_t __F_NAME(strtoumax,wcstoumax)( const CHAR_TYPE *nptr, CHAR_TYPE **endptr, int base ) |
{ |
return( _stoll( nptr, endptr, base, 0 ) ); |
} |
_WCRTLINK intmax_t __F_NAME(strtoimax,wcstoimax)( const CHAR_TYPE *nptr, CHAR_TYPE **endptr, int base ) |
{ |
return( _stoll( nptr, endptr, base, 1 ) ); |
} |
/programs/develop/open watcom/trunk/clib/fpu/chipa32.asm |
---|
0,0 → 1,397 |
;***************************************************************************** |
;* |
;* 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[] = "@(#)fpatan32.asm 1.7 12/21/94 08:33:45"; |
; |
; 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. |
; |
; |
include mdef.inc |
.386 |
.387 |
_TEXT SEGMENT PARA PUBLIC USE32 'CODE' |
_TEXT ENDS |
CONST SEGMENT DWORD PUBLIC USE32 'DATA' |
CONST ENDS |
CONST2 SEGMENT DWORD PUBLIC USE32 'DATA' |
CONST2 ENDS |
DATA32 SEGMENT DWORD PUBLIC USE32 'DATA' |
Y EQU 0 |
X EQU 12 |
PREV_CW EQU 24 |
PATCH_CW EQU 28 |
SPILL EQU 32 |
STACK_SIZE EQU 36 |
pos_1 DD 00000000H |
DD 3ff00000H |
neg_1 DD 00000000H |
DD 0bff00000H |
dispatch_table DD offset label0 |
DD offset label1 |
DD offset label2 |
DD offset label3 |
DD offset label4 |
DD offset label5 |
DD offset label6 |
DD offset label7 |
;end dispatch table |
pi DB 35H |
DB 0c2H |
DD 0daa22168H |
DD 4000c90fH |
pi_by_2 DB 35H |
DB 0c2H |
DD 0daa22168H |
DD 3fffc90fH |
flt_sixteen DD 41800000H |
one_by_sixteen DD 3d800000H |
B1 DW 0AAA8H |
DD 0AAAAAAAAH |
DD 0BFFDAAAAH |
B2 DW 2D6EH |
DD 0CCCCCCCCH |
DD 3FFCCCCCH |
B3 DW 4892H |
DD 249241F9H |
DD 0BFFC9249H |
B4 DW 0C592H |
DD 3897CDECH |
DD 3FFBE38EH |
B5 DW 5DDDH |
DD 0C17BC162H |
DD 0BFFBBA2DH |
B6 DW 4854H |
DD 77C7C78EH |
DD 3FFB9C80H |
atan_k_by_16 dd 000000000H, 000000000H, 000000000H, 000000000H |
dd 067EF4E37H, 0FFAADDB9H, 000003FFAH, 000000000H |
dd 0617B6E33H, 0FEADD4D5H, 000003FFBH, 000000000H |
dd 072D81135H, 0BDCBDA5EH, 000003FFCH, 000000000H |
dd 06406EB15H, 0FADBAFC9H, 000003FFCH, 000000000H |
dd 03F5E5E6AH, 09B13B9B8H, 000003FFDH, 000000000H |
dd 026F78474H, 0B7B0CA0FH, 000003FFDH, 000000000H |
dd 0611FE5B6H, 0D327761EH, 000003FFDH, 000000000H |
dd 00DDA7B45H, 0ED63382BH, 000003FFDH, 000000000H |
dd 0D9867E2AH, 0832BF4A6H, 000003FFEH, 000000000H |
dd 0F7F59F9BH, 08F005D5EH, 000003FFEH, 000000000H |
dd 071BDDA20H, 09A2F80E6H, 000003FFEH, 000000000H |
dd 034F70924H, 0A4BC7D19H, 000003FFEH, 000000000H |
dd 0B4D8C080H, 0AEAC4C38H, 000003FFEH, 000000000H |
dd 0C2319E74H, 0B8053E2BH, 000003FFEH, 000000000H |
dd 0AC526641H, 0C0CE85B8H, 000003FFEH, 000000000H |
dd 02168C235H, 0C90FDAA2H, 000003FFEH, 000000000H |
DATA32 ENDS |
BSS32 SEGMENT DWORD PUBLIC USE32 'BSS' |
BSS32 ENDS |
EXTRN __fdiv_fpr:NEAR |
DGROUP GROUP CONST,CONST2,DATA32,BSS32 |
_TEXT SEGMENT PARA PUBLIC USE32 'CODE' |
ASSUME CS:_TEXT,DS:DGROUP,ES:DGROUP, SS:nothing |
public __fpatan_chk |
defpe __fpatan_chk |
push eax |
push ecx |
push edx |
sub esp, STACK_SIZE |
fstp tbyte ptr [esp+X] ; save X |
fstp tbyte ptr [esp+Y] ; save Y |
mov ecx, [esp+Y+4] |
add ecx, ecx |
jnc hw_fpatan ; unnormals (explicit 1 missing) |
mov eax, [esp+X+4] |
add eax, eax |
jnc hw_fpatan ; unnormals (explicit 1 missing) |
mov ecx, [esp+Y+8] ; save high part of Y |
mov eax, [esp+X+8] ; save high part of Y |
and ecx, 7fffh ; Ey = exponent Y |
jz hw_fpatan ; Ey = 0 |
and eax, 7fffh ; Ex = exponent X |
jz hw_fpatan ; Ex = 0 |
cmp ecx, 7fffh ; check if Ey = 0x7fffh |
je hw_fpatan |
cmp eax, 7fffh ; check if Ex = 0x7fffh |
je hw_fpatan |
fld tbyte ptr [esp+X] ; reload X |
fabs ; |X| = u |
fld tbyte ptr [esp+Y] ; reload Y |
fabs ; |Y| = v |
; The following five lines turn off exceptions and set the |
; precision control to 80 bits. The former is necessary to |
; force any traps to be taken at the divide instead of the scaling |
; code. The latter is necessary in order to get full precision for |
; codes with incoming 32 and 64 bit precision settings. If |
; it can be guaranteed that before reaching this point, the underflow |
; exception is masked and the precision control is at 80 bits, these |
; five lines can be omitted. |
; |
fnstcw [PREV_CW+esp] ; save caller's control word |
mov edx, [PREV_CW+esp] |
or edx, 033fh ; mask exceptions, pc=80 |
and edx, 0f3ffh |
mov [PATCH_CW+esp], edx |
fldcw [PATCH_CW+esp] ; mask exceptions & pc=80 |
xor edx, edx ; initialize sflag = 0 |
fcom ; |Y| > |x| |
push eax |
fstsw ax |
sahf |
pop eax |
jb order_X_Y_ok |
fxch |
inc edx ; sflag = 1 |
order_X_Y_ok: |
push eax |
mov eax, 0fh |
call __fdiv_fpr ; v/u = z |
pop eax |
fld dword ptr flt_sixteen ; 16.0 |
fmul st, st(1) ; z*16.0 |
; Top of stack looks like k, z |
fistp dword ptr [SPILL+esp] ; store k as int |
mov ecx, [SPILL+esp] |
shl ecx, 4 |
fild dword ptr[SPILL+esp] |
fmul dword ptr one_by_sixteen; 1.0/16.0 |
; Top of stack looks like g, z |
fld st(1) ; duplicate g |
fsub st, st(1) ; z-g = r |
fxch |
; Top of stack looks like g, r, z |
fmulp st(2), st ; g*z |
; Top of stack looks like r, g*z |
fld qword ptr pos_1 ; load 1.0 |
faddp st(2), st ; 1+g*z |
; Top of stack looks like r, 1+g*z |
push eax |
mov eax, 0fh |
call __fdiv_fpr ; v/u = z |
pop eax |
fld st(0) ; duplicate s |
fmul st,st(1) ; t = s*s |
; Top of stack looks like t, s |
fld st(0) |
fmul st, st(1) |
; Top of stack looks like t2, t, s |
fld st(0) |
fmul st, st(1) |
fld tbyte ptr B6 |
fld tbyte ptr B5 |
; Top of stack looks like B5, B6, t4, t2, t, s |
fxch |
fmul st, st(2) |
fld tbyte ptr B4 |
fxch st(2) |
fmul st, st(3) |
; Top of stack looks like B5t4, B6t4, B4, t4, t2, t, s |
fld tbyte ptr B3 |
fxch st(2) |
fmul st, st(5) |
; Top of stack looks like B6t6, B5t4, B3, B4, t4, t2, t, s |
fxch st(3) |
fmulp st(4), st |
fld tbyte ptr B2 |
; Top of stack looks like B2, B5t4, B3, B6t6, B4t4, t2, t, s |
fxch st(3) |
faddp st(4), st |
mov eax, [esp+X+8] |
fld tbyte ptr B1 |
fxch |
shl eax, 16 |
; Top of stack looks like B5t4, B1, B3, B2, even, t2, t, s |
fmul st, st(6) |
fxch st(2) |
add eax, eax |
fmul st, st(5) |
; Top of stack looks like B3t2, B1, B5t5, B2, even, t2, t, s |
fxch st(3) |
adc edx, edx ; |sflag|Sx| |
fmulp st(5), st |
fxch st(2) |
mov eax, [Y+8+esp] ; save high part of Y |
fmul st, st(5) |
; Top of stack looks like B3t3, B5t5, B1, even, B2t2, t, s |
fxch st(2) |
shl eax, 16 |
fmulp st(5), st |
; Top of stack looks like B5t5, B3t3, even, B2t2, B1t, s |
fxch st(2) |
faddp st(3), st |
add eax, eax |
faddp st(1), st |
adc edx, edx ; |sflag|Sx|Sy| |
; Top of stack looks like odd, even, B1t, s |
faddp st(2), st |
faddp st(1), st |
fmul st,st(1) ; s*(odd+even) |
faddp st(1), st ; poly |
fld tbyte ptr atan_k_by_16[ecx] ; arctan[k;16] |
faddp st(1), st ; w = poly + arctan(g) |
jmp dword ptr dispatch_table[edx*4] |
label0: |
fldcw [esp+PREV_CW] |
add esp, STACK_SIZE |
pop edx |
pop ecx |
pop eax |
ret |
label1: |
fchs |
fldcw [esp+PREV_CW] |
add esp, STACK_SIZE |
pop edx |
pop ecx |
pop eax |
ret |
label2: |
fld tbyte ptr pi |
fsubrp st(1), st ; pi - w |
fldcw [esp+PREV_CW] |
add esp, STACK_SIZE |
pop edx |
pop ecx |
pop eax |
ret |
label3: |
fld tbyte ptr pi |
fsubrp st(1), st ; pi - w |
fchs ; - (pi - w) |
fldcw [esp+PREV_CW] |
add esp, STACK_SIZE |
pop edx |
pop ecx |
pop eax |
ret |
label4: |
fld tbyte ptr pi_by_2 |
fsubrp st(1), st ; pi/2 - w |
fldcw [esp+PREV_CW] |
add esp, STACK_SIZE |
pop edx |
pop ecx |
pop eax |
ret |
label5: |
fld tbyte ptr pi_by_2 |
fsubrp st(1), st ; pi/2 - w |
fchs ; - (pi/2 - w) |
fldcw [esp+PREV_CW] |
add esp, STACK_SIZE |
pop edx |
pop ecx |
pop eax |
ret |
label6: |
fld tbyte ptr pi_by_2 |
faddp st(1), st ; pi/2 + w |
fldcw [esp+PREV_CW] |
add esp, STACK_SIZE |
pop edx |
pop ecx |
pop eax |
ret |
label7: |
fld tbyte ptr pi_by_2 |
faddp st(1), st ; pi/2 + w |
fchs ; -(pi/2+w) |
fldcw [esp+PREV_CW] |
add esp, STACK_SIZE |
pop edx |
pop ecx |
pop eax |
ret |
hw_fpatan: |
fld tbyte ptr [esp+Y] ; reload Y |
fld tbyte ptr [esp+X] ; reload X |
fpatan |
add esp, STACK_SIZE |
pop edx |
pop ecx |
pop eax |
ret |
__fpatan_chk ENDP |
_TEXT ENDS |
END |
/programs/develop/open watcom/trunk/clib/fpu/chipd32.asm |
---|
0,0 → 1,991 |
;***************************************************************************** |
;* |
;* 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[] = "@(#)patch32.asm 1.12 12/21/94 14:53:51"; |
; |
; 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. |
; |
; |
include mdef.inc |
.386 |
.387 |
DENOM EQU 0 |
NUMER EQU 12 |
PREV_CW EQU 28 ; 24 + 4 (return size) |
PATCH_CW EQU 32 ; 28 + 4 (return size) |
DENOM_SAVE EQU 32 |
MAIN_DENOM EQU 4 |
MAIN_NUMER EQU 16 |
SPILL_SIZE EQU 12 |
MEM_OPERAND EQU 8 |
STACK_SIZE EQU 44 |
SPILL_MEM_OPERAND EQU 20 |
ONESMASK EQU 0e000000h |
SINGLE_NAN EQU 07f800000h |
DOUBLE_NAN EQU 07ff00000h |
ILLEGAL_OPC EQU 6 |
f_stsw macro where |
fstsw where |
endm |
fdivr_st MACRO reg_index, reg_index_minus1 |
fstp tbyte ptr [esp+DENOM] |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fstp tbyte ptr [esp+NUMER] |
call fdiv_main_routine |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fld tbyte ptr [esp+NUMER] |
fxch st(reg_index) |
add esp, STACK_SIZE |
ENDM |
fdivr_sti MACRO reg_index, reg_index_minus1 |
fstp tbyte ptr [esp+NUMER] |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fstp tbyte ptr [esp+DENOM] |
call fdiv_main_routine |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fld tbyte ptr [esp+NUMER] |
add esp, STACK_SIZE |
ENDM |
fdivrp_sti MACRO reg_index, reg_index_minus1 |
fstp tbyte ptr [esp+NUMER] |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fstp tbyte ptr [esp+DENOM] |
call fdiv_main_routine |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
add esp, STACK_SIZE |
ENDM |
fdiv_st MACRO reg_index, reg_index_minus1 |
fstp tbyte ptr [esp+NUMER] |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fld st |
fstp tbyte ptr [esp+DENOM] |
fstp tbyte ptr [esp+DENOM_SAVE] ; save original denom, |
call fdiv_main_routine |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fld tbyte ptr [esp+DENOM_SAVE] |
fxch st(reg_index) |
add esp, STACK_SIZE |
ENDM |
fdiv_sti MACRO reg_index, reg_index_minus1 |
fxch st(reg_index) |
fstp tbyte ptr [esp+NUMER] |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fld st |
fstp tbyte ptr [esp+DENOM] |
fstp tbyte ptr [esp+DENOM_SAVE] ; save original denom, |
call fdiv_main_routine |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fld tbyte ptr [esp+DENOM_SAVE] |
add esp, STACK_SIZE |
ENDM |
fdivp_sti MACRO reg_index, reg_index_minus1 |
fstp tbyte ptr [esp+DENOM] |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
fstp tbyte ptr [esp+NUMER] |
call fdiv_main_routine |
IF reg_index_minus1 GE 1 |
fxch st(reg_index_minus1) |
ENDIF |
add esp, STACK_SIZE |
ENDM |
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE' |
_TEXT ENDS |
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' |
DATA32 ENDS |
CONST32 SEGMENT DWORD USE32 PUBLIC 'CONST' |
CONST32 ENDS |
BSS32 SEGMENT DWORD USE32 PUBLIC 'BSS' |
BSS32 ENDS |
DGROUP GROUP CONST32, BSS32, DATA32 |
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' |
fdiv_risc_table DB 0, 1, 0, 0, 4, 0, 0, 7, 0, 0, 10, 0, 0, 13, 0, 0 |
fdiv_scale_1 DD 03f700000h ;0.9375 |
fdiv_scale_2 DD 03f880000h ;1.0625 |
one_shl_63 DD 05f000000h |
dispatch_table DD offset label0 |
DD offset label1 |
DD offset label2 |
DD offset label3 |
DD offset label4 |
DD offset label5 |
DD offset label6 |
DD offset label7 |
DD offset label8 |
DD offset label9 |
DD offset label10 |
DD offset label11 |
DD offset label12 |
DD offset label13 |
DD offset label14 |
DD offset label15 |
DD offset label16 |
DD offset label17 |
DD offset label18 |
DD offset label19 |
DD offset label20 |
DD offset label21 |
DD offset label22 |
DD offset label23 |
DD offset label24 |
DD offset label25 |
DD offset label26 |
DD offset label27 |
DD offset label28 |
DD offset label29 |
DD offset label30 |
DD offset label31 |
DD offset label32 |
DD offset label33 |
DD offset label34 |
DD offset label35 |
DD offset label36 |
DD offset label37 |
DD offset label38 |
DD offset label39 |
DD offset label40 |
DD offset label41 |
DD offset label42 |
DD offset label43 |
DD offset label44 |
DD offset label45 |
DD offset label46 |
DD offset label47 |
DD offset label48 |
DD offset label49 |
DD offset label50 |
DD offset label51 |
DD offset label52 |
DD offset label53 |
DD offset label54 |
DD offset label55 |
DD offset label56 |
DD offset label57 |
DD offset label58 |
DD offset label59 |
DD offset label60 |
DD offset label61 |
DD offset label62 |
DD offset label63 |
DATA32 ENDS |
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE' |
assume cs:_TEXT, ds:DGROUP, es:DGROUP, ss:nothing |
; |
; PRELIMINARY VERSION for register-register divides. |
; |
; In this implementation the |
; fdiv_main_routine is called, |
; therefore all the stack frame |
; locations are adjusted for the |
; return pointer. |
fdiv_main_routine PROC NEAR |
fld tbyte ptr [esp+MAIN_NUMER] ; load the numerator |
fld tbyte ptr [esp+MAIN_DENOM] ; load the denominator |
retry: |
; The following three lines test for denormals and zeros. |
; A denormal or zero has a 0 in the explicit digit to the left of the |
; binary point. Since that bit is the high bit of the word, adding |
; it to itself will produce a carry if and only if the number is not |
; denormal or zero. |
; |
mov eax, [esp+MAIN_DENOM+4] ; get mantissa bits 32-64 |
add eax,eax ; shift the one's bit onto carry |
jnc denormal ; if no carry, we're denormal |
; The following three lines test the three bits after the four bit |
; pattern (1,4,7,a,d). If these three bits are not all one, then |
; the denominator cannot expose the flaw. This condition is tested by |
; inverting the bits and testing that all are equal to zero afterward. |
xor eax, ONESMASK ; invert the bits that must be ones |
test eax, ONESMASK ; and make sure they are all ones |
jz scale_if_needed ; if all are one scale numbers |
fdivp st(1), st ; use of hardware is OK. |
ret |
; |
; Now we test the four bits for one of the five patterns. |
; |
scale_if_needed: |
shr eax, 28 ; keep first 4 bits after point |
cmp byte ptr fdiv_risc_table[eax], 0 ; check for (1,4,7,a,d) |
jnz divide_scaled ; are in potential problem area |
fdivp st(1), st ; use of hardware is OK. |
ret |
divide_scaled: |
mov eax, [esp + MAIN_DENOM+8] ; test denominator exponent |
and eax, 07fffh ; if pseudodenormal ensure that only |
jz invalid_denom ; invalid exception flag is set |
cmp eax, 07fffh ; if NaN or infinity ensure that only |
je invalid_denom ; invalid exception flag is set |
; |
; The following six lines turn off exceptions and set the |
; precision control to 80 bits. The former is necessary to |
; force any traps to be taken at the divide instead of the scaling |
; code. The latter is necessary in order to get full precision for |
; codes with incoming 32 and 64 bit precision settings. If |
; it can be guaranteed that before reaching this point, the underflow |
; exception is masked and the precision control is at 80 bits, these |
; six lines can be omitted. |
; |
fnstcw [esp+PREV_CW] ; save caller's control word |
mov eax, [esp+PREV_CW] |
or eax, 033fh ; mask exceptions, pc=80 |
and eax, 0f3ffh ; set rounding mode to nearest |
mov [esp+PATCH_CW], eax |
fldcw [esp+PATCH_CW] ; mask exceptions & pc=80 |
; The following lines check the numerator exponent before scaling. |
; This in order to prevent undeflow when scaling the numerator, |
; which will cause a denormal exception flag to be set when the |
; actual divide is preformed. This flag would not have been set |
; normally. If there is a risk of underflow, the scale factor is |
; 17/16 instead of 15/16. |
; |
mov eax, [esp+MAIN_NUMER+8] ; test numerator exponent |
and eax, 07fffh |
cmp eax, 00001h |
je small_numer |
fmul fdiv_scale_1 ; scale denominator by 15/16 |
fxch |
fmul fdiv_scale_1 ; scale numerator by 15/16 |
fxch |
; |
; The next line restores the users control word. If the incoming |
; control word had the underflow exception masked and precision |
; control set to 80 bits, this line can be omitted. |
; |
fldcw [esp+PREV_CW] ; restore caller's control word |
fdivp st(1), st ; use of hardware is OK. |
ret |
small_numer: |
fmul fdiv_scale_2 ; scale denominator by 17/16 |
fxch |
fmul fdiv_scale_2 ; scale numerator by 17/16 |
fxch |
; |
; The next line restores the users control word. If the incoming |
; control word had the underflow exception masked and precision |
; control set to 80 bits, this line can be omitted. |
; |
fldcw [esp+PREV_CW] ; restore caller's control word |
fdivp st(1), st ; use of hardware is OK. |
ret |
denormal: |
mov eax, [esp+MAIN_DENOM] ; test for whole mantissa == 0 |
or eax, [esp+MAIN_DENOM+4] ; test for whole mantissa == 0 |
jnz denormal_divide_scaled ; denominator is not zero |
invalid_denom: ; zero or invalid denominator |
fdivp st(1), st ; use of hardware is OK. |
ret |
denormal_divide_scaled: |
mov eax, [esp + MAIN_DENOM + 8] ; get exponent |
and eax, 07fffh ; check for zero exponent |
jnz invalid_denom ; |
; |
; The following six lines turn off exceptions and set the |
; precision control to 80 bits. The former is necessary to |
; force any traps to be taken at the divide instead of the scaling |
; code. The latter is necessary in order to get full precision for |
; codes with incoming 32 and 64 bit precision settings. If |
; it can be guaranteed that before reaching this point, the underflow |
; exception is masked and the precision control is at 80 bits, these |
; five lines can be omitted. |
; |
fnstcw [esp+PREV_CW] ; save caller's control word |
mov eax, [esp+PREV_CW] |
or eax, 033fh ; mask exceptions, pc=80 |
and eax, 0f3ffh ; set rounding mode to nearest |
mov [esp+PATCH_CW], eax |
fldcw [esp+PATCH_CW] ; mask exceptions & pc=80 |
mov eax, [esp + MAIN_NUMER +8] ; test numerator exponent |
and eax, 07fffh ; check for denormal numerator |
je denormal_numer |
cmp eax, 07fffh ; NaN or infinity |
je invalid_numer |
mov eax, [esp + MAIN_NUMER + 4] ; get bits 32..63 of mantissa |
add eax, eax ; shift the first bit into carry |
jnc invalid_numer ; if there is no carry, we have an |
; invalid numer |
jmp numer_ok |
denormal_numer: |
mov eax, [esp + MAIN_NUMER + 4] ; get bits 32..63 of mantissa |
add eax, eax ; shift the first bit into carry |
jc invalid_numer ; if there is a carry, we have an |
; invalid numer |
numer_ok: |
fxch |
fstp st ; pop numerator |
fld st ; make copy of denominator |
fmul dword ptr[one_shl_63] ; make denominator not denormal |
fstp tbyte ptr [esp+MAIN_DENOM] ; save modified denominator |
fld tbyte ptr [esp+MAIN_NUMER] ; load numerator |
fxch ; restore proper order |
fwait |
; The next line restores the users control word. If the incoming |
; control word had the underflow exception masked and precision |
; control set to 80 bits, this line can be omitted. |
; |
fldcw [esp+PREV_CW] ; restore caller's control word |
jmp retry ; start the whole thing over |
invalid_numer: |
; |
; The next line restores the users control word. If the incoming |
; control word had the underflow exception masked and precision |
; control set to 80 bits, this line can be omitted. |
; |
fldcw [esp + PREV_CW] |
fdivp st(1), st ; use of hardware is OK. |
ret |
fdiv_main_routine ENDP |
public __fdiv_fpr |
defpe __fdiv_fpr |
sub esp, STACK_SIZE |
jmp dword ptr dispatch_table[eax*4] |
label0: |
fdiv st,st(0) ; D8 F0 FDIV ST,ST(0) |
add esp, STACK_SIZE |
ret |
label1: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label2: |
fdivr st,st(0) ; D8 F8 FDIVR ST,ST(0) |
add esp, STACK_SIZE |
ret |
label3: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label4: |
fdiv st(0),st ; DC F8/D8 F0 FDIV ST(0),ST |
add esp, STACK_SIZE |
ret |
label5: |
fdivp st(0),st ; DE F8 FDIVP ST(0),ST |
add esp, STACK_SIZE |
ret |
label6: |
fdivr st(0),st ; DC F0/DE F0 FDIVR ST(0),ST |
add esp, STACK_SIZE |
ret |
label7: |
fdivrp st(0),st ; DE F0 FDIVRP ST(0),ST |
add esp, STACK_SIZE |
ret |
label8: |
fdiv_st 1, 0 |
ret |
label9: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label10: |
fdivr_st 1, 0 |
ret |
label11: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label12: |
fdiv_sti 1, 0 |
ret |
label13: |
fdivp_sti 1, 0 |
ret |
label14: |
fdivr_sti 1, 0 |
ret |
label15: |
fdivrp_sti 1, 0 |
ret |
label16: |
fdiv_st 2, 1 |
ret |
label17: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label18: |
fdivr_st 2, 1 |
ret |
label19: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label20: |
fdiv_sti 2, 1 |
ret |
label21: |
fdivp_sti 2, 1 |
ret |
label22: |
fdivr_sti 2, 1 |
ret |
label23: |
fdivrp_sti 2, 1 |
ret |
label24: |
fdiv_st 3, 2 |
ret |
label25: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label26: |
fdivr_st 3, 2 |
ret |
label27: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label28: |
fdiv_sti 3, 2 |
ret |
label29: |
fdivp_sti 3, 2 |
ret |
label30: |
fdivr_sti 3, 2 |
ret |
label31: |
fdivrp_sti 3, 2 |
ret |
label32: |
fdiv_st 4, 3 |
ret |
label33: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label34: |
fdivr_st 4, 3 |
ret |
label35: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label36: |
fdiv_sti 4, 3 |
ret |
label37: |
fdivp_sti 4, 3 |
ret |
label38: |
fdivr_sti 4, 3 |
ret |
label39: |
fdivrp_sti 4, 3 |
ret |
label40: |
fdiv_st 5, 4 |
ret |
label41: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label42: |
fdivr_st 5, 4 |
ret |
label43: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label44: |
fdiv_sti 5, 4 |
ret |
label45: |
fdivp_sti 5, 4 |
ret |
label46: |
fdivr_sti 5, 4 |
ret |
label47: |
fdivrp_sti 5, 4 |
ret |
label48: |
fdiv_st 6, 5 |
ret |
label49: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label50: |
fdivr_st 6, 5 |
ret |
label51: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label52: |
fdiv_sti 6, 5 |
ret |
label53: |
fdivp_sti 6, 5 |
ret |
label54: |
fdivr_sti 6, 5 |
ret |
label55: |
fdivrp_sti 6, 5 |
ret |
label56: |
fdiv_st 7, 6 |
ret |
label57: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label58: |
fdivr_st 7, 6 |
ret |
label59: |
add esp, STACK_SIZE |
int ILLEGAL_OPC |
label60: |
fdiv_sti 7, 6 |
ret |
label61: |
fdivp_sti 7, 6 |
ret |
label62: |
fdivr_sti 7, 6 |
ret |
label63: |
fdivrp_sti 7, 6 |
ret |
__fdiv_fpr ENDP |
__fdivp_sti_st PROC NEAR |
; for calling from mem routines |
sub esp, STACK_SIZE |
fdivp_sti 1, 0 |
ret |
__fdivp_sti_st ENDP |
__fdivrp_sti_st PROC NEAR |
; for calling from mem routines |
sub esp, STACK_SIZE |
fdivrp_sti 1, 0 |
ret |
__fdivrp_sti_st ENDP |
public __fdiv_chk |
defpe __fdiv_chk |
; for calling from mem routines |
sub esp, STACK_SIZE |
fdivrp_sti 1, 0 |
ret |
__fdiv_chk ENDP |
; |
; PRELIMINARY VERSIONS of the routines for register-memory |
; divide instructions |
; |
;;; FDIV_M32 - FDIV m32real FIX |
;; |
;; Input : Value of the m32real in the top of STACK |
;; |
;; Output: Result of FDIV in ST |
PUBLIC __fdiv_m32 |
defpe __fdiv_m32 |
push eax ; save eax |
mov eax, [esp + MEM_OPERAND] ; check for |
and eax, SINGLE_NAN ; NaN |
cmp eax, SINGLE_NAN ; |
je memory_divide_m32 ; |
f_stsw ax ; get status word |
and eax, 3800h ; get top of stack |
je spill_fpstack ; is FP stack full? |
fld dword ptr[esp + MEM_OPERAND] ; load m32real in ST |
call __fdivp_sti_st ; do actual divide |
pop eax |
ret 4 |
spill_fpstack: |
fxch |
sub esp, SPILL_SIZE ; make temp space |
fstp tbyte ptr[esp ] ; save user's ST(1) |
fld dword ptr[esp + SPILL_MEM_OPERAND] ; load m32 real |
call __fdivp_sti_st ; do actual divide |
fld tbyte ptr[esp] ; restore user's ST(1) |
;esp is adjusted by fdivrp fn |
fxch |
add esp, SPILL_SIZE |
pop eax |
ret 4 |
memory_divide_m32: |
fdiv dword ptr[esp + MEM_OPERAND] ; do actual divide |
pop eax |
ret 4 |
__fdiv_m32 ENDP |
;;; FDIV_M64 - FDIV m64real FIX |
;; |
;; Input : Value of the m64real in the top of STACK |
;; |
;; Output: Result of FDIV in ST |
PUBLIC __fdiv_m64 |
defpe __fdiv_m64 |
push eax ; save eax |
mov eax, [esp + MEM_OPERAND + 4] ; check for |
and eax, DOUBLE_NAN ; NaN |
cmp eax, DOUBLE_NAN ; |
je memory_divide_m64 ; |
f_stsw ax ; get status word |
and eax, 3800h ; get top of stack |
je spill_fpstack_m64 ; is FP stack full? |
fld qword ptr[esp + MEM_OPERAND] ; load m64real in ST |
call __fdivp_sti_st ; do actual divide |
pop eax |
ret 8 |
spill_fpstack_m64: |
fxch |
sub esp, SPILL_SIZE ; make temp space |
fstp tbyte ptr[esp] ; save user's ST(1) |
fld qword ptr[esp + SPILL_MEM_OPERAND] ; load m64real |
call __fdivp_sti_st ; do actual divide |
fld tbyte ptr[esp] ; restore user's ST(1) |
;esp is adjusted by fdivrp fn |
fxch |
add esp, SPILL_SIZE |
pop eax |
ret 8 |
memory_divide_m64: |
fdiv qword ptr[esp + MEM_OPERAND] ; do actual divide |
pop eax |
ret 8 |
__fdiv_m64 ENDP |
;;; FDIVR_M32 - FDIVR m32real FIX |
;; |
;; Input : Value of the m32real in the top of STACK |
;; |
;; Output: Result of FDIVR in ST |
PUBLIC __fdiv_m32r |
defpe __fdiv_m32r |
push eax ; save eax |
mov eax, [esp + MEM_OPERAND] ; check for |
and eax, SINGLE_NAN ; NaN |
cmp eax, SINGLE_NAN ; |
je memory_divide_m32r ; |
f_stsw ax ; get status word |
and eax, 3800h ; get top of stack |
je spill_fpstack_m32r ; is FP stack full? |
fld dword ptr[esp + MEM_OPERAND] ; load m32real in ST |
call __fdivrp_sti_st ; do actual divide |
pop eax |
ret 4 |
spill_fpstack_m32r: |
fxch |
sub esp, SPILL_SIZE ; make temp space |
fstp tbyte ptr[esp ] ; save user's ST(1) |
fld dword ptr[esp + SPILL_MEM_OPERAND] ; load m32 real |
call __fdivrp_sti_st ; do actual divide |
fld tbyte ptr[esp] ; restore user's ST(1) |
;esp is adjusted by fdivp fn |
fxch |
add esp, SPILL_SIZE |
pop eax |
ret 4 |
memory_divide_m32r: |
fdivr dword ptr[esp + MEM_OPERAND] ; do actual divide |
pop eax |
ret 4 |
__fdiv_m32r ENDP |
;;; FDIVR_M64 - FDIVR m64real FIX |
;; |
;; Input : Value of the m64real in the top of STACK |
;; |
;; Output: Result of FDIVR in ST |
PUBLIC __fdiv_m64r |
defpe __fdiv_m64r |
push eax ; save eax |
mov eax, [esp + MEM_OPERAND + 4] ; check for |
and eax, DOUBLE_NAN ; NaN |
cmp eax, DOUBLE_NAN ; |
je memory_divide_m64r ; |
f_stsw ax ; get status word |
and eax, 3800h ; get top of stack |
je spill_fpstack_m64r ; is FP stack full? |
fld qword ptr[esp + MEM_OPERAND] ; load m64real in ST |
call __fdivrp_sti_st ; do actual divide |
pop eax |
ret 8 |
spill_fpstack_m64r: |
fxch |
sub esp, SPILL_SIZE ; make temp space |
fstp tbyte ptr[esp ] ; save user's ST(1) |
fld qword ptr[esp + SPILL_MEM_OPERAND] ; load m64real |
call __fdivrp_sti_st ; do actual divide |
fld tbyte ptr[esp] ; restore user's ST(1) |
;esp is adjusted by fdivp fn |
fxch |
add esp, SPILL_SIZE |
pop eax |
ret 8 |
memory_divide_m64r: |
fdivr qword ptr[esp + MEM_OPERAND] ; do actual divide |
pop eax |
ret 8 |
__fdiv_m64r ENDP |
comment ~****************************************************************** |
;;; FDIV_M16I - FDIV m16int FIX |
;; |
;; Input : Value of the m16int in the top of STACK |
;; |
;; Output: Result of FDIV in ST |
PUBLIC FDIV_M16I |
FDIV_M16I PROC NEAR |
push eax ; save eax |
f_stsw ax ; get status word |
and eax, 3800h ; get top of stack |
je spill_fpstack_m16i ; is FP stack full? |
fild word ptr[esp + MEM_OPERAND] ; load m16int in ST |
call __fdivp_sti_st ; do actual divide |
pop eax |
ret |
spill_fpstack_m16i: |
fxch |
sub esp, SPILL_SIZE ; make temp space |
fstp tbyte ptr[esp ] ; save user's ST(1) |
fild word ptr[esp + SPILL_MEM_OPERAND] ; load m16int |
call __fdivp_sti_st ; do actual divide |
fld tbyte ptr[esp] ; restore user's ST(1) |
;esp is adjusted by fdivrp fn |
fxch |
add esp, SPILL_SIZE |
pop eax |
ret |
FDIV_M16I ENDP |
;;; FDIV_M32I - FDIV m16int FIX |
;; |
;; Input : Value of the m16int in the top of STACK |
;; |
;; Output: Result of FDIV in ST |
PUBLIC FDIV_M32I |
FDIV_M32I PROC NEAR |
push eax ; save eax |
f_stsw ax ; get status word |
and eax, 3800h ; get top of stack |
je spill_fpstack_m32i ; is FP stack full? |
fild dword ptr[esp + MEM_OPERAND] ; load m32int in ST |
call __fdivp_sti_st ; do actual divide |
pop eax |
ret |
spill_fpstack_m32i: |
fxch |
sub esp, SPILL_SIZE ; make temp space |
fstp tbyte ptr[esp ] ; save user's ST(1) |
fild dword ptr[esp + SPILL_MEM_OPERAND] ; load m32int |
call __fdivp_sti_st ; do actual divide |
fld tbyte ptr[esp] ; restore user's ST(1) |
;esp is adjusted by fdivrp fn |
fxch |
add esp, SPILL_SIZE |
pop eax |
ret |
FDIV_M32I ENDP |
;;; FDIVR_M16I - FDIVR m16int FIX |
;; |
;; Input : Value of the m16int in the top of STACK |
;; |
;; Output: Result of FDIVR in ST |
PUBLIC FDIVR_M16I |
FDIVR_M16I PROC NEAR |
push eax ; save eax |
f_stsw ax ; get status word |
and eax, 3800h ; get top of stack |
je spill_fpstack_m16ir ; is FP stack full? |
fild word ptr[esp + MEM_OPERAND] ; load m16int in ST |
call __fdivrp_sti_st ; do actual divide |
pop eax |
ret |
spill_fpstack_m16ir: |
fxch |
sub esp, SPILL_SIZE ; make temp space |
fstp tbyte ptr[esp ] ; save user's ST(1) |
fild word ptr[esp + SPILL_MEM_OPERAND] ; load m16int |
call __fdivrp_sti_st ; do actual divide |
fld tbyte ptr[esp] ; restore user's ST(1) |
;esp is adjusted by fdivp fn |
fxch |
add esp, SPILL_SIZE |
pop eax |
ret |
FDIVR_M16I ENDP |
;;; FDIVR_M32I - FDIVR m32int FIX |
;; |
;; Input : Value of the m32int in the top of STACK |
;; |
;; Output: Result of FDIVR in ST |
PUBLIC FDIVR_M32I |
FDIVR_M32I PROC NEAR |
push eax ; save eax |
f_stsw ax ; get status word |
and eax, 3800h ; get top of stack |
je spill_fpstack_m32ir ; is FP stack full? |
fild dword ptr[esp + MEM_OPERAND] ; load m32int in ST |
call __fdivrp_sti_st ; do actual divide |
pop eax |
ret |
spill_fpstack_m32ir: |
fxch |
sub esp, SPILL_SIZE ; make temp space |
fstp tbyte ptr[esp ] ; save user's ST(1) |
fild dword ptr[esp + SPILL_MEM_OPERAND] ; load m32int |
call __fdivrp_sti_st ; do actual divide |
fld tbyte ptr[esp] ; restore user's ST(1) |
;esp is adjusted by fdivp fn |
fxch |
add esp, SPILL_SIZE |
pop eax |
ret |
FDIVR_M32I ENDP |
**********************************************************************~ |
_TEXT ENDS |
end |
/programs/develop/open watcom/trunk/clib/fpu/chipr32.asm |
---|
0,0 → 1,851 |
;***************************************************************************** |
;* |
;* 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[] = "@(#)fprem32.asm 1.5 12/22/94 12:48:07"; |
; |
; 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. |
; |
; |
include mdef.inc |
.386 |
.387 |
; |
; PRELIMINARY VERSION of the software patch for the floating |
; point remainder. |
; |
CHECKSW MACRO |
ifdef DEBUG |
fnstsw [fpsw] |
fnstcw [fpcw] |
endif |
ENDM |
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' |
; |
; Stack variables for remainder routines. |
; |
FLT_SIZE EQU 12 |
DENOM EQU 0 |
DENOM_SAVE EQU DENOM + FLT_SIZE |
NUMER EQU DENOM_SAVE + FLT_SIZE |
PREV_CW EQU NUMER + FLT_SIZE |
PATCH_CW EQU PREV_CW + 4 |
FPREM_SW EQU PATCH_CW + 4 |
STACK_SIZE EQU FPREM_SW + 4 |
RET_SIZE EQU 4 |
PUSH_SIZE EQU 4 |
MAIN_FUDGE EQU RET_SIZE + PUSH_SIZE + PUSH_SIZE + PUSH_SIZE |
MAIN_DENOM EQU DENOM + MAIN_FUDGE |
MAIN_DENOM_SAVE EQU DENOM_SAVE + MAIN_FUDGE |
MAIN_NUMER EQU NUMER + MAIN_FUDGE |
MAIN_PREV_CW EQU PREV_CW + MAIN_FUDGE |
MAIN_PATCH_CW EQU PATCH_CW + MAIN_FUDGE |
MAIN_FPREM_SW EQU FPREM_SW + MAIN_FUDGE |
ONESMASK EQU 700h |
fprem_risc_table DB 0, 1, 0, 0, 4, 0, 0, 7, 0, 0, 10, 0, 0, 13, 0, 0 |
fprem_scale DB 0, 0, 0, 0, 0, 0, 0eeh, 03fh |
one_shl_64 DB 0, 0, 0, 0, 0, 0, 0f0h, 043h |
one_shr_64 DB 0, 0, 0, 0, 0, 0, 0f0h, 03bh |
one DB 0, 0, 0, 0, 0, 0, 0f0h, 03fh |
half DB 0, 0, 0, 0, 0, 0, 0e0h, 03fh |
big_number DB 0, 0, 0, 0, 0, 0, 0ffh, 0ffh, 0feh, 07fh |
ifdef DEBUG |
public fpcw |
public fpsw |
fpcw dw 0 |
fpsw dw 0 |
endif |
FPU_STATE STRUC |
CONTROL_WORD DW ? |
reserved_1 DW ? |
STATUS_WORD DD ? |
TAG_WORD DW ? |
reserved_3 DW ? |
IP_OFFSET DD ? |
CS_SLCT DW ? |
OPCODE DW ? |
DATA_OFFSET DD ? |
OPERAND_SLCT DW ? |
reserved_4 DW ? |
FPU_STATE ENDS |
ENV_SIZE EQU 28 |
DATA32 ENDS |
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE' |
_TEXT ENDS |
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' |
DATA32 ENDS |
CONST32 SEGMENT DWORD USE32 PUBLIC 'CONST' |
CONST32 ENDS |
BSS32 SEGMENT DWORD USE32 PUBLIC 'BSS' |
BSS32 ENDS |
DGROUP GROUP CONST32, BSS32, DATA32 |
CODE32 SEGMENT DWORD USE32 PUBLIC 'CODE' |
assume cs:_TEXT, ds:DGROUP, es:DGROUP, ss:nothing |
fprem_common PROC NEAR |
push eax |
push ebx |
push ecx |
mov eax, [MAIN_DENOM+6+esp] ; exponent and high 16 bits of mantissa |
xor eax, ONESMASK ; invert bits that have to be one |
test eax, ONESMASK ; check bits that have to be one |
jnz remainder_hardware_ok |
shr eax, 11 |
and eax, 0fh |
cmp byte ptr fprem_risc_table[eax], 0 ; check for (1,4,7,a,d) |
jz remainder_hardware_ok |
; The denominator has the bit pattern. Weed out the funny cases like NaNs |
; before applying the software version. Our caller guarantees that the |
; denominator is not a denormal. Here we check for: |
; denominator inf, NaN, unnormal |
; numerator inf, NaN, unnormal, denormal |
mov eax, [MAIN_DENOM+6+esp] ; exponent and high 16 bits of mantissa |
and eax, 07fff0000h ; mask the exponent only |
cmp eax, 07fff0000h ; check for INF or NaN |
je remainder_hardware_ok |
mov eax, [MAIN_NUMER+6+esp] ; exponent and high 16 bits of mantissa |
and eax, 07fff0000h ; mask the exponent only |
jz remainder_hardware_ok ; jif numerator denormal |
cmp eax, 07fff0000h ; check for INF or NaN |
je remainder_hardware_ok |
mov eax, [esp + MAIN_NUMER + 4] ; high mantissa bits - numerator |
add eax, eax ; set carry if explicit bit set |
jnz remainder_hardware_ok ; jmp if numerator is unnormal |
mov eax, [esp + MAIN_DENOM + 4] ; high mantissa bits - denominator |
add eax, eax ; set carry if explicit bit set |
jnz remainder_hardware_ok ; jmp if denominator is unnormal |
rem_patch: |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
and eax, 07fffh ; clear sy |
add eax, 63 ; evaluate ey + 63 |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
sub ebx, eax ; evaluate the exponent difference (ex - ey) |
ja rem_large ; if ex > ey + 63, case of large arguments |
rem_patch_loop: |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
and eax, 07fffh ; clear sy |
add eax, 10 ; evaluate ey + 10 |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
sub ebx, eax ; evaluate the exponent difference (ex - ey) |
js remainder_hardware_ok ; safe if ey + 10 > ex |
fld tbyte ptr [MAIN_NUMER+esp] ; load the numerator |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
mov ecx, ebx |
sub ebx, eax |
and ebx, 07h |
or ebx, 04h |
sub ecx, ebx |
mov ebx, eax |
and ebx, 08000h ; keep sy |
or ecx, ebx ; merge the sign of y |
mov dword ptr [MAIN_DENOM+8+esp], ecx |
fld tbyte ptr [MAIN_DENOM+esp] ; load the shifted denominator |
mov dword ptr [MAIN_DENOM+8+esp], eax ; restore the initial denominator |
fxch |
fprem ; this rem is safe |
fstp tbyte ptr [MAIN_NUMER+esp] ; update the numerator |
fstp st(0) ; pop the stack |
jmp rem_patch_loop |
rem_large: |
test edx, 02h ; is denominator already saved |
jnz already_saved |
fld tbyte ptr[esp + MAIN_DENOM] |
fstp tbyte ptr[esp + MAIN_DENOM_SAVE] ; save denominator |
already_saved: |
; Save user's precision control and institute 80. The fp ops in |
; rem_large_loop must not round to user's precision (if it is less |
; than 80) because the hardware would not have done so. We are |
; aping the hardware here, which is all extended. |
fnstcw [esp+MAIN_PREV_CW] ; save caller's control word |
mov eax, dword ptr[esp + MAIN_PREV_CW] |
or eax, 033fh ; mask exceptions, pc=80 |
mov [esp + MAIN_PATCH_CW], eax |
fldcw [esp + MAIN_PATCH_CW] |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
and eax, 07fffh ; clear sy |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
sub ebx, eax ; evaluate the exponent difference |
and ebx, 03fh |
or ebx, 020h |
add ebx, 1 |
mov ecx, ebx |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
and eax, 08000h ; keep sy |
or ebx, eax ; merge the sign of y |
mov dword ptr[MAIN_DENOM+8+esp], ebx ; make ey equal to ex (scaled denominator) |
fld tbyte ptr [MAIN_DENOM+esp] ; load the scaled denominator |
fabs |
fld tbyte ptr [MAIN_NUMER+esp] ; load the numerator |
fabs |
rem_large_loop: |
fcom |
fstsw ax |
and eax, 00100h |
jnz rem_no_sub |
fsub st, st(1) |
rem_no_sub: |
fxch |
fmul qword ptr half |
fxch |
sub ecx, 1 ; decrement the loop counter |
jnz rem_large_loop |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
fstp tbyte ptr[esp + MAIN_NUMER] ; save result |
fstp st ; toss modified denom |
fld tbyte ptr[esp + MAIN_DENOM_SAVE] |
fld tbyte ptr[big_number] ; force C2 to be set |
fprem |
fstp st |
fld tbyte ptr[esp + MAIN_NUMER] ; restore saved result |
fldcw [esp + MAIN_PREV_CW] ; restore caller's control word |
and ebx, 08000h ; keep sx |
jz rem_done |
fchs |
jmp rem_done |
remainder_hardware_ok: |
fld tbyte ptr [MAIN_DENOM+esp] ; load the denominator |
fld tbyte ptr [MAIN_NUMER+esp] ; load the numerator |
fprem ; and finally do a remainder |
; prem_main_routine end |
rem_done: |
test edx, 03h |
jz rem_exit |
fnstsw [esp + MAIN_FPREM_SW] ; save Q0 Q1 and Q2 |
test edx, 01h |
jz do_not_de_scale |
; De-scale the result. Go to pc=80 to prevent from fmul |
; from user precision (fprem does not round the result). |
fnstcw [esp + MAIN_PREV_CW] ; save callers control word |
mov eax, [esp + MAIN_PREV_CW] |
or eax, 0300h ; pc = 80 |
mov [esp + MAIN_PATCH_CW], eax |
fldcw [esp + MAIN_PATCH_CW] |
fmul qword ptr one_shr_64 |
fldcw [esp + MAIN_PREV_CW] ; restore callers CW |
do_not_de_scale: |
mov eax, [esp + MAIN_FPREM_SW] |
fxch |
fstp st |
fld tbyte ptr[esp + MAIN_DENOM_SAVE] |
fxch |
and eax, 04300h ; restore saved Q0, Q1, Q2 |
sub esp, ENV_SIZE |
fnstenv [esp] |
and [esp].STATUS_WORD, 0bcffh |
or [esp].STATUS_WORD, eax |
fldenv [esp] |
add esp, ENV_SIZE |
rem_exit: |
pop ecx |
pop ebx |
pop eax |
CHECKSW ; debug only: save status |
ret |
fprem_common ENDP |
comment ~**************************************************************** |
; |
; float frem_chk (float numer, float denom) |
; |
public frem_chk |
frem_chk PROC NEAR |
push edx |
sub esp, STACK_SIZE |
fld dword ptr [STACK_SIZE+8+esp] |
fstp tbyte ptr [NUMER+esp] |
fld dword ptr [STACK_SIZE+12+esp] |
fstp tbyte ptr [DENOM+esp] |
mov edx, 0 ; dx = 1 if denormal extended divisor |
call fprem_common |
fxch |
fstp st |
add esp, STACK_SIZE |
pop edx |
ret |
frem_chk ENDP |
; end frem_chk |
; |
; double drem_chk (double numer, double denom) |
; |
public drem_chk |
drem_chk PROC NEAR |
push edx |
sub esp, STACK_SIZE |
fld qword ptr [STACK_SIZE+8+esp] |
fstp tbyte ptr [NUMER+esp] |
fld qword ptr [STACK_SIZE+16+esp] |
fstp tbyte ptr [DENOM+esp] |
mov edx, 0 ; dx = 1 if denormal extended divisor |
call fprem_common |
fxch |
fstp st |
add esp, STACK_SIZE |
pop edx |
ret |
drem_chk ENDP |
; end drem_chk |
; |
; long double lrem_chk(long double number,long double denom) |
; |
public lrem_chk |
lrem_chk PROC NEAR |
fld tbyte ptr [20+esp] |
fld tbyte ptr [4+esp] |
call fprem_chk |
fxch |
fstp st |
ret |
lrem_chk ENDP |
**********************************************************************~ |
; |
; FPREM: ST = remainder(ST, ST(1)) |
; |
; Compiler version of the FPREM must preserve the arguments in the floating |
; point stack. |
public __fprem_chk |
defpe __fprem_chk |
push edx |
sub esp, STACK_SIZE |
fstp tbyte ptr [NUMER+esp] |
fstp tbyte ptr [DENOM+esp] |
xor edx, edx |
; prem_main_routine begin |
mov eax,[DENOM+6+esp] ; exponent and high 16 bits of mantissa |
test eax,07fff0000h ; check for denormal |
jz denormal |
call fprem_common |
add esp, STACK_SIZE |
pop edx |
ret |
denormal: |
fld tbyte ptr [DENOM+esp] ; load the denominator |
fld tbyte ptr [NUMER+esp] ; load the numerator |
mov eax, [DENOM+esp] ; test for whole mantissa == 0 |
or eax, [DENOM+4+esp] ; test for whole mantissa == 0 |
jz remainder_hardware_ok_l ; denominator is zero |
fxch |
fstp tbyte ptr[esp + DENOM_SAVE] ; save org denominator |
fld tbyte ptr[esp + DENOM] |
fxch |
or edx, 02h |
; |
; For this we need pc=80. Also, mask exceptions so we don't take any |
; denormal operand exceptions. It is guaranteed that the descaling |
; later on will take underflow, which is what the hardware would have done |
; on a normal fprem. |
; |
fnstcw [PREV_CW+esp] ; save caller's control word |
mov eax, [PREV_CW+esp] |
or eax, 0033fh ; mask exceptions, pc=80 |
mov [PATCH_CW+esp], eax |
fldcw [PATCH_CW+esp] ; mask exceptions & pc=80 |
; The denominator is a denormal. For most numerators, scale both numerator |
; and denominator to get rid of denormals. Then execute the common code |
; with the flag set to indicate that the result must be de-scaled. |
; For large numerators this won't work because the scaling would cause |
; overflow. In this case we know the numerator is large, the denominator |
; is small (denormal), so the exponent difference is also large. This means |
; the rem_large code will be used and this code depends on the difference |
; in exponents modulo 64. Adding 64 to the denominators exponent |
; doesn't change the modulo 64 difference. So we can scale the denominator |
; by 64, making it not denormal, and this won't effect the result. |
; |
; To start with, figure out if numerator is large |
mov eax, [esp + NUMER + 8] ; load numerator exponent |
and eax, 7fffh ; isolate numerator exponent |
cmp eax, 7fbeh ; compare Nexp to Maxexp-64 |
ja big_numer_rem_de ; jif big numerator |
; So the numerator is not large scale both numerator and denominator |
or edx, 1 ; edx = 1, if denormal extended divisor |
fmul qword ptr one_shl_64 ; make numerator not denormal |
fstp tbyte ptr[esp + NUMER] |
fmul qword ptr one_shl_64 ; make denominator not denormal |
fstp tbyte ptr[esp + DENOM] |
jmp scaling_done |
; The numerator is large. Scale only the denominator, which will not |
; change the result which we know will be partial. Set the scale flag |
; to false. |
big_numer_rem_de: |
; We must do this with pc=80 to avoid rounding to single/double. |
; In this case we do not mask exceptions so that we will take |
; denormal operand, as would the hardware. |
fnstcw [PREV_CW+esp] ; save caller's control word |
mov eax, [PREV_CW+esp] |
or eax, 00300h ; pc=80 |
mov [PATCH_CW+esp], eax |
fldcw [PATCH_CW+esp] ; pc=80 |
fstp st ; Toss numerator |
fmul qword ptr one_shl_64 ; make denominator not denormal |
fstp tbyte ptr[esp + DENOM] |
; Restore the control word which was fiddled to scale at 80-bit precision. |
; Then call the common code. |
scaling_done: |
fldcw [esp + PREV_CW] ; restore callers control word |
call fprem_common |
add esp, STACK_SIZE |
pop edx |
ret |
remainder_hardware_ok_l: |
fprem ; and finally do a remainder |
CHECKSW |
add esp, STACK_SIZE |
pop edx |
ret |
__fprem_chk ENDP |
; end fprem_chk |
; |
; FPREM1 code begins here |
; |
fprem1_common PROC NEAR |
push eax |
push ebx |
push ecx |
mov eax, [MAIN_DENOM+6+esp] ; exponent and high 16 bits of mantissa |
xor eax, ONESMASK ; invert bits that have to be one |
test eax, ONESMASK ; check bits that have to be one |
jnz remainder1_hardware_ok |
shr eax, 11 |
and eax, 0fh |
cmp byte ptr fprem_risc_table[eax], 0 ; check for (1,4,7,a,d) |
jz remainder1_hardware_ok |
; The denominator has the bit pattern. Weed out the funny cases like NaNs |
; before applying the software version. Our caller guarantees that the |
; denominator is not a denormal. Here we check for: |
; denominator inf, NaN, unnormal |
; numerator inf, NaN, unnormal, denormal |
mov eax, [MAIN_DENOM+6+esp] ; exponent and high 16 bits of mantissa |
and eax, 07fff0000h ; mask the exponent only |
cmp eax, 07fff0000h ; check for INF or NaN |
je remainder1_hardware_ok |
mov eax, [MAIN_NUMER+6+esp] ; exponent and high 16 bits of mantissa |
and eax, 07fff0000h ; mask the exponent only |
jz remainder1_hardware_ok ; jif numerator denormal |
cmp eax, 07fff0000h ; check for INF or NaN |
je remainder1_hardware_ok |
mov eax, [esp + MAIN_NUMER + 4] ; high mantissa bits - numerator |
add eax, eax ; set carry if explicit bit set |
jnz remainder1_hardware_ok ; jmp if numerator is unnormal |
mov eax, [esp + MAIN_DENOM + 4] ; high mantissa bits - denominator |
add eax, eax ; set carry if explicit bit set |
jnz remainder1_hardware_ok ; jmp if denominator is unnormal |
rem1_patch: |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
and eax, 07fffh ; clear sy |
add eax, 63 ; evaluate ey + 63 |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
sub ebx, eax ; evaluate the exponent difference (ex - ey) |
ja rem1_large ; if ex > ey + 63, case of large arguments |
rem1_patch_loop: |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
and eax, 07fffh ; clear sy |
add eax, 10 ; evaluate ey + 10 |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
sub ebx, eax ; evaluate the exponent difference (ex - ey) |
js remainder1_hardware_ok ; safe if ey + 10 > ex |
fld tbyte ptr [MAIN_NUMER+esp] ; load the numerator |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
mov ecx, ebx |
sub ebx, eax |
and ebx, 07h |
or ebx, 04h |
sub ecx, ebx |
mov ebx, eax |
and ebx, 08000h ; keep sy |
or ecx, ebx ; merge the sign of y |
mov dword ptr [MAIN_DENOM+8+esp], ecx |
fld tbyte ptr [MAIN_DENOM+esp] ; load the shifted denominator |
mov dword ptr [MAIN_DENOM+8+esp], eax ; restore the initial denominator |
fxch |
fprem ; this rem is safe |
fstp tbyte ptr [MAIN_NUMER+esp] ; update the numerator |
fstp st(0) ; pop the stack |
jmp rem1_patch_loop |
rem1_large: |
test ebx, 02h ; is denominator already saved |
jnz already_saved1 |
fld tbyte ptr[esp + MAIN_DENOM] |
fstp tbyte ptr[esp + MAIN_DENOM_SAVE] ; save denominator |
already_saved1: |
; Save user's precision control and institute 80. The fp ops in |
; rem1_large_loop must not round to user's precision (if it is less |
; than 80) because the hardware would not have done so. We are |
; aping the hardware here, which is all extended. |
fnstcw [esp+MAIN_PREV_CW] ; save caller's control word |
mov eax, dword ptr[esp + MAIN_PREV_CW] |
or eax, 033fh ; mask exceptions, pc=80 |
mov [esp + MAIN_PATCH_CW], eax |
fldcw [esp + MAIN_PATCH_CW] |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
and eax, 07fffh ; clear sy |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
sub ebx, eax ; evaluate the exponent difference |
and ebx, 03fh |
or ebx, 020h |
add ebx, 1 |
mov ecx, ebx |
mov eax, [MAIN_DENOM+8+esp] ; sign and exponent of y (denominator) |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
and ebx, 07fffh ; clear sx |
and eax, 08000h ; keep sy |
or ebx, eax ; merge the sign of y |
mov dword ptr[MAIN_DENOM+8+esp], ebx ; make ey equal to ex (scaled denominator) |
fld tbyte ptr [MAIN_DENOM+esp] ; load the scaled denominator |
fabs |
fld tbyte ptr [MAIN_NUMER+esp] ; load the numerator |
fabs |
rem1_large_loop: |
fcom |
fstsw ax |
and eax, 00100h |
jnz rem1_no_sub |
fsub st, st(1) |
rem1_no_sub: |
fxch |
fmul qword ptr half |
fxch |
sub ecx, 1 ; decrement the loop counter |
jnz rem1_large_loop |
mov ebx, [MAIN_NUMER+8+esp] ; sign and exponent of x (numerator) |
fstp tbyte ptr[esp + MAIN_NUMER] ; save result |
fstp st ; toss modified denom |
fld tbyte ptr[esp + MAIN_DENOM_SAVE] |
fld tbyte ptr[big_number] ; force C2 to be set |
fprem1 |
fstp st |
fld tbyte ptr[esp + MAIN_NUMER] ; restore saved result |
fldcw [esp + MAIN_PREV_CW] ; restore caller's control word |
and ebx, 08000h ; keep sx |
jz rem1_done |
fchs |
jmp rem1_done |
remainder1_hardware_ok: |
fld tbyte ptr [MAIN_DENOM+esp] ; load the denominator |
fld tbyte ptr [MAIN_NUMER+esp] ; load the numerator |
fprem1 ; and finally do a remainder |
; prem1_main_routine end |
rem1_done: |
test edx, 03h |
jz rem1_exit |
fnstsw [esp + MAIN_FPREM_SW] ; save Q0 Q1 and Q2 |
test edx, 01h |
jz do_not_de_scale1 |
; De-scale the result. Go to pc=80 to prevent from fmul |
; from user precision (fprem does not round the result). |
fnstcw [esp + MAIN_PREV_CW] ; save callers control word |
mov eax, [esp + MAIN_PREV_CW] |
or eax, 0300h ; pc = 80 |
mov [esp + MAIN_PATCH_CW], eax |
fldcw [esp + MAIN_PATCH_CW] |
fmul qword ptr one_shr_64 |
fldcw [esp + MAIN_PREV_CW] ; restore callers CW |
do_not_de_scale1: |
mov eax, [esp + MAIN_FPREM_SW] |
fxch |
fstp st |
fld tbyte ptr[esp + MAIN_DENOM_SAVE] |
fxch |
and eax, 04300h ; restore saved Q0, Q1, Q2 |
sub esp, ENV_SIZE |
fnstenv [esp] |
and [esp].STATUS_WORD, 0bcffh |
or [esp].STATUS_WORD, eax |
fldenv [esp] |
add esp, ENV_SIZE |
rem1_exit: |
pop ecx |
pop ebx |
pop eax |
CHECKSW ; debug only: save status |
ret |
fprem1_common ENDP |
comment ~*************************************************************** |
; |
; float frem1_chk (float numer, float denom) |
; |
public frem1_chk |
frem1_chk PROC NEAR |
push edx |
sub esp, STACK_SIZE |
fld dword ptr [STACK_SIZE+8+esp] |
fstp tbyte ptr [NUMER+esp] |
fld dword ptr [STACK_SIZE+12+esp] |
fstp tbyte ptr [DENOM+esp] |
mov edx, 0 ; dx = 1 if denormal extended divisor |
call fprem1_common |
fxch |
fstp st |
add esp, STACK_SIZE |
pop edx |
ret |
frem1_chk ENDP |
; end frem1_chk |
; |
; double drem1_chk (double numer, double denom) |
; |
public drem1_chk |
drem1_chk PROC NEAR |
push edx |
sub esp, STACK_SIZE |
fld qword ptr [STACK_SIZE+8+esp] |
fstp tbyte ptr [NUMER+esp] |
fld qword ptr [STACK_SIZE+16+esp] |
fstp tbyte ptr [DENOM+esp] |
mov edx, 0 ; dx = 1 if denormal extended divisor |
call fprem1_common |
fxch |
fstp st |
add esp, STACK_SIZE |
pop edx |
ret |
drem1_chk ENDP |
; end drem1_chk |
; |
; long double lrem1_chk(long double number,long double denom) |
; |
public lrem1_chk |
lrem1_chk PROC NEAR |
fld tbyte ptr [20+esp] |
fld tbyte ptr [4+esp] |
call fprem1_chk |
fxch |
fstp st |
ret |
lrem1_chk ENDP |
********************************************************************~ |
; |
; FPREM1: ST = remainder(ST, ST(1)) - IEEE version of rounding |
; |
; Compiler version of the FPREM must preserve the arguments in the floating |
; point stack. |
public __fprem1_chk |
defpe __fprem1_chk |
push edx |
sub esp, STACK_SIZE |
fstp tbyte ptr [NUMER+esp] |
fstp tbyte ptr [DENOM+esp] |
mov edx, 0 |
; prem1_main_routine begin |
mov eax,[DENOM+6+esp] ; exponent and high 16 bits of mantissa |
test eax,07fff0000h ; check for denormal |
jz denormal1 |
call fprem1_common |
add esp, STACK_SIZE |
pop edx |
ret |
denormal1: |
fld tbyte ptr [DENOM+esp] ; load the denominator |
fld tbyte ptr [NUMER+esp] ; load the numerator |
mov eax, [DENOM+esp] ; test for whole mantissa == 0 |
or eax, [DENOM+4+esp] ; test for whole mantissa == 0 |
jz remainder1_hardware_ok_l ; denominator is zero |
fxch |
fstp tbyte ptr[esp + DENOM_SAVE] ; save org denominator |
fld tbyte ptr[esp + DENOM] |
fxch |
or edx, 02h |
; |
; For this we need pc=80. Also, mask exceptions so we don't take any |
; denormal operand exceptions. It is guaranteed that the descaling |
; later on will take underflow, which is what the hardware would have done |
; on a normal fprem. |
; |
fnstcw [PREV_CW+esp] ; save caller's control word |
mov eax, [PREV_CW+esp] |
or eax, 0033fh ; mask exceptions, pc=80 |
mov [PATCH_CW+esp], eax |
fldcw [PATCH_CW+esp] ; mask exceptions & pc=80 |
; The denominator is a denormal. For most numerators, scale both numerator |
; and denominator to get rid of denormals. Then execute the common code |
; with the flag set to indicate that the result must be de-scaled. |
; For large numerators this won't work because the scaling would cause |
; overflow. In this case we know the numerator is large, the denominator |
; is small (denormal), so the exponent difference is also large. This means |
; the rem1_large code will be used and this code depends on the difference |
; in exponents modulo 64. Adding 64 to the denominators exponent |
; doesn't change the modulo 64 difference. So we can scale the denominator |
; by 64, making it not denormal, and this won't effect the result. |
; |
; To start with, figure out if numerator is large |
mov eax, [esp + NUMER + 8] ; load numerator exponent |
and eax, 7fffh ; isolate numerator exponent |
cmp eax, 7fbeh ; compare Nexp to Maxexp-64 |
ja big_numer_rem1_de ; jif big numerator |
; So the numerator is not large scale both numerator and denominator |
or edx, 1 ; edx = 1, if denormal extended divisor |
fmul qword ptr one_shl_64 ; make numerator not denormal |
fstp tbyte ptr[esp + NUMER] |
fmul qword ptr one_shl_64 ; make denominator not denormal |
fstp tbyte ptr[esp + DENOM] |
jmp scaling_done1 |
; The numerator is large. Scale only the denominator, which will not |
; change the result which we know will be partial. Set the scale flag |
; to false. |
big_numer_rem1_de: |
; We must do this with pc=80 to avoid rounding to single/double. |
; In this case we do not mask exceptions so that we will take |
; denormal operand, as would the hardware. |
fnstcw [PREV_CW+esp] ; save caller's control word |
mov eax, [PREV_CW+esp] |
or eax, 00300h ; pc=80 |
mov [PATCH_CW+esp], eax |
fldcw [PATCH_CW+esp] ; pc=80 |
fstp st ; Toss numerator |
fmul qword ptr one_shl_64 ; make denominator not denormal |
fstp tbyte ptr[esp + DENOM] |
; Restore the control word which was fiddled to scale at 80-bit precision. |
; Then call the common code. |
scaling_done1: |
fldcw [esp + PREV_CW] ; restore callers control word |
call fprem1_common |
add esp, STACK_SIZE |
pop edx |
ret |
remainder1_hardware_ok_l: |
fprem ; and finally do a remainder |
CHECKSW |
add esp, STACK_SIZE |
pop edx |
ret |
__fprem1_chk ENDP |
; end fprem1_chk |
ifdef DEBUG |
public fpinit |
fpinit PROC NEAR |
fninit |
ret |
fpinit ENDP |
endif |
CODE32 ENDS |
END |
/programs/develop/open watcom/trunk/clib/fpu/chipt32.asm |
---|
0,0 → 1,167 |
;***************************************************************************** |
;* |
;* 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[] = "@(#)fptan32.asm 1.4 12/20/94 16:51:51"; |
; |
; 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 floating point divide instructions. |
; |
; |
include mdef.inc |
.386 |
.387 |
PATCH_CW EQU 00ch |
PREV_CW EQU 010h |
COSINE EQU 0 ; These two are overlaid because they |
ANGLE EQU 0 ; are not live at the same time. |
STACK_SIZE EQU 014h |
ONESMASK EQU 0e000000h |
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' |
fdiv_risk_table DB 0, 1, 0, 0, 4, 0, 0, 7, 0, 0, 10, 0, 0, 13, 0, 0 |
fdiv_scale DD 03f700000h ; 0.9375 |
one_shl_63 DD 05f000000h |
DATA32 ENDS |
DGROUP GROUP DATA32 |
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE' |
assume cs:_TEXT, ds:DGROUP, es:DGROUP, ss:nothing |
public __fptan_chk |
; |
; PRELIMINARY VERSION for register-register divides. |
; |
defpe __fptan_chk |
push eax |
sub esp, STACK_SIZE |
fstp tbyte ptr [esp+ANGLE] |
mov eax, [esp+ANGLE+8] |
and eax, 07fffh |
jz use_hardware ; denormals, ... |
cmp eax, 07fffh |
je use_hardware ; NaNs, infinities, ... |
mov eax, [esp+ANGLE+4] |
add eax, eax |
jnc use_hardware ; unnormals (explicit 1 missing) |
fld tbyte ptr [esp+ANGLE] |
; |
; Check for proper parameter range ( |<angle>| < 2^63) |
; |
fabs |
fcomp one_shl_63 |
fstsw ax |
sahf |
jae use_hardware |
fld tbyte ptr [esp+ANGLE] |
fsincos |
fstp tbyte ptr [esp+COSINE] |
fld tbyte ptr [esp+COSINE] ; load the denominator (cos(x)) |
mov eax, [esp+COSINE+4] ; get mantissa bits 32-64 |
add eax,eax ; shift the one's bit onto carry |
xor eax, ONESMASK ; invert the bits that must be ones |
test eax, ONESMASK ; and make sure they are all ones |
jz scale_if_needed ; if all are one scale numbers |
fdivp st(1), st ; use of hardware is OK. |
fld1 ; push 1.0 onto FPU stack |
add esp, STACK_SIZE |
pop eax |
ret |
scale_if_needed: |
shr eax, 28 ; keep first 4 bits after point |
cmp fdiv_risk_table[eax], ah ; check for (1,4,7,a,d) |
jnz divide_scaled ; are in potential problem area |
fdivp st(1), st ; use of hardware is OK. |
fld1 ; push 1.0 onto FPU stack |
add esp, STACK_SIZE |
pop eax |
ret |
divide_scaled: |
fwait ; catch preceding exceptions |
fstcw [esp+PREV_CW] ; save caller's control word |
mov eax, [esp+PREV_CW] |
or eax, 033fh ; mask exceptions, pc=80 |
mov [esp+PATCH_CW], eax |
fldcw [esp+PATCH_CW] ; mask exceptions & pc=80 |
fmul fdiv_scale ; scale denominator by 15/16 |
fxch |
fmul fdiv_scale ; scale numerator by 15/16 |
fxch |
; This assures correctly rounded result if pc=64 as well |
fldcw [esp+PREV_CW] ; restore caller's control word |
fdivp st(1), st ; use of hardware is OK. |
fld1 ; push 1.0 onto FPU stack |
add esp, STACK_SIZE |
pop eax |
ret |
use_hardware: |
fld tbyte ptr [esp+ANGLE] |
fptan |
add esp, STACK_SIZE |
pop eax |
ret |
__fptan_chk ENDP |
_TEXT ENDS |
end |
/programs/develop/open watcom/trunk/clib/fpu/clearfpe.h |
---|
0,0 → 1,32 |
/**************************************************************************** |
* |
* 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: prototype for _ClearFPE clib internal function |
* |
****************************************************************************/ |
extern void _ClearFPE( void ); |
/programs/develop/open watcom/trunk/clib/fpu/cntrl87.c |
---|
0,0 → 1,149 |
/**************************************************************************** |
* |
* 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 "variety.h" |
#include <math.h> |
#include <float.h> |
#include "rtdata.h" |
extern void __fstcw(); |
extern void __fldcw(); |
#if defined(__WINDOWS__) && !defined(__WINDOWS_386__) |
extern void __far _fpmath(); |
#pragma aux _fpmath "__fpmath"; |
void __win87em_fldcw(unsigned int); |
#pragma aux __win87em_fldcw = \ |
"push bx" \ |
"mov bx, 4h" \ |
"call far ptr _fpmath" \ |
"pop bx" \ |
parm [ax] |
unsigned int __win87em_fstcw(void); |
#pragma aux __win87em_fstcw = \ |
"push bx" \ |
"mov bx, 5h" \ |
"call far ptr _fpmath" \ |
"pop bx" \ |
value [ax] |
#elif defined( __DOS_086__ ) |
extern unsigned char __dos87real; |
#pragma aux __dos87real "*"; |
extern unsigned short __dos87emucall; |
#pragma aux __dos87emucall "*"; |
void _WCI86NEAR __dos_emu_fldcw( unsigned short * ); |
#pragma aux __dos_emu_fldcw "*" = \ |
"mov ax,3" \ |
"call __dos87emucall" \ |
parm [bx]; |
void _WCI86NEAR __dos_emu_fstcw( unsigned short * ); |
#pragma aux __dos_emu_fstcw "*" = \ |
"mov ax,4" \ |
"call __dos87emucall" \ |
parm [bx]; |
#endif |
#if defined(__386__) |
#pragma aux __fstcw = \ |
"fstcw ss:[edi]" \ |
"fwait" \ |
parm caller [edi]; |
#pragma aux __fldcw = \ |
"fldcw ss:[edi]" \ |
parm caller [edi]; |
#else |
#pragma aux __fstcw = \ |
"xchg ax,bp" \ |
"fstcw [bp]" \ |
"fwait" \ |
"xchg ax,bp" \ |
parm caller [ax]; |
#pragma aux __fldcw = \ |
"xchg ax,bp" \ |
"fldcw [bp]" \ |
"xchg ax,bp" \ |
parm caller [ax]; |
#endif |
_WCRTLINK unsigned _control87( unsigned new, unsigned mask ) |
/**********************************************************/ |
{ |
auto short unsigned int control_word; |
control_word = 0; |
if( _RWD_8087 ) { |
#if defined(__WINDOWS__) && !defined(__WINDOWS_386__) |
__fstcw( &control_word ); |
control_word = __win87em_fstcw(); |
if( mask != 0 ) { |
control_word = (control_word & ~mask) | (new & mask); |
__fldcw( &control_word ); |
__fstcw( &control_word ); /* 17-sep-91 */ |
__win87em_fldcw(control_word); |
} |
#elif defined( __DOS_086__ ) |
if( __dos87real ) { |
__fstcw( &control_word ); |
if( mask != 0 ) { |
control_word = (control_word & ~mask) | (new & mask); |
__fldcw( &control_word ); |
__fstcw( &control_word ); |
} |
} |
if( __dos87emucall ) { |
__dos_emu_fstcw( &control_word ); |
if( mask != 0 ) { |
control_word = (control_word & ~mask) | (new & mask); |
__dos_emu_fldcw( &control_word ); |
__dos_emu_fstcw( &control_word ); |
} |
} |
#else |
__fstcw( &control_word ); |
if( mask != 0 ) { |
control_word = (control_word & ~mask) | (new & mask); |
__fldcw( &control_word ); |
__fstcw( &control_word ); /* 17-sep-91 */ |
} |
#endif |
} |
return( control_word ); |
} |
/programs/develop/open watcom/trunk/clib/fpu/cntrlfp.c |
---|
0,0 → 1,132 |
/**************************************************************************** |
* |
* 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 "variety.h" |
#include <math.h> |
#include <float.h> |
#include "rtdata.h" |
#if defined(__AXP__) |
/* |
* FPCR Trap Disable Flags |
*/ |
#define FPCR_INEXACT 0x40000000 |
#define FPCR_UNDERFLOW 0x20000000 |
#define FPCR_OVERFLOW 0x00080000 |
#define FPCR_ZERODIVIDE 0x00040000 |
#define FPCR_INVALID 0x00020000 |
extern unsigned long _GetFPCR(void); |
extern void _SetFPCR(unsigned long); |
static unsigned int MapToCW(unsigned long fpcr) |
{ |
unsigned int cw; |
/* |
* The rounding bits are identical but in the highword of the fpcr. |
*/ |
cw = (fpcr >> 16) & ~(_MCW_RC); |
if (fpcr & FPCR_INEXACT) |
cw &= ~_EM_INEXACT; |
if (fpcr & FPCR_ZERODIVIDE) |
cw &= ~_EM_ZERODIVIDE; |
if (fpcr & FPCR_OVERFLOW) |
cw &= ~_EM_OVERFLOW; |
if (fpcr & FPCR_UNDERFLOW) |
cw &= ~_EM_UNDERFLOW; |
if (fpcr & FPCR_INVALID) |
cw &= ~_EM_INVALID; |
return cw; |
} /* MapToCW() */ |
static unsigned long MapFromCW(unsigned int cw) |
{ |
unsigned long fpcr = 0L; |
/* |
* The rounding bits are identical but in the highword of the fpcr. |
*/ |
fpcr = (cw & ~_MCW_RC) << 16; |
if (!(cw & _EM_INEXACT)) |
fpcr |= FPCR_INEXACT; |
if (!(cw & _EM_INVALID)) |
fpcr |= FPCR_INVALID; |
if (!(cw & _EM_ZERODIVIDE)) |
fpcr |= FPCR_ZERODIVIDE; |
if (!(cw & _EM_OVERFLOW)) |
fpcr |= FPCR_OVERFLOW; |
if (!(cw & _EM_UNDERFLOW)) |
fpcr |= FPCR_UNDERFLOW; |
return fpcr; |
} /* MapFromCW() */ |
#endif |
_WCRTLINK unsigned _controlfp(unsigned new, unsigned mask) |
{ |
#if defined(_M_IX86) |
return _control87(new, mask); /* JBS 99/09/16 */ |
#elif defined(__AXP__) |
unsigned int cw; |
cw = MapToCW(_GetFPCR()); |
if (mask) |
{ |
cw = (cw & ~mask) | (new & mask); |
_SetFPCR(MapFromCW(cw)); |
} |
return cw; |
#elif defined(__PPC__) |
// No idea yet |
return( 0 ); |
#elif defined(__MIPS__) |
// No idea yet either |
return( 0 ); |
#endif |
} /* _controlfp() */ |
/programs/develop/open watcom/trunk/clib/fpu/fclex387.c |
---|
0,0 → 1,43 |
/**************************************************************************** |
* |
* 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 "rtdata.h" |
#include "variety.h" |
#include "clearfpe.h" |
extern void __ClearFPE(void); |
#pragma aux __ClearFPE = "fnclex" |
void _ClearFPE( void ) |
{ |
__ClearFPE(); |
} /* _ClearFPE() */ |
/programs/develop/open watcom/trunk/clib/fpu/ini87386.asm |
---|
0,0 → 1,68 |
;***************************************************************************** |
;* |
;* 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: routine for checking FPU type |
;* |
;***************************************************************************** |
include mdef.inc |
modstart init8087 |
xdefp __x87id |
__x87id proc |
sub EAX,EAX |
push EAX ; allocate space for status word |
finit ; use default infinity mode |
fstcw word ptr [ESP] ; save control word |
fwait |
pop EAX |
mov AL,0 |
cmp AH,3 |
jnz nox87 |
push EAX ; allocate space for status word |
fld1 ; generate infinity by |
fldz ; dividing 1 by 0 |
fdiv ; ... |
fld st ; form negative infinity |
fchs ; ... |
fcompp ; compare +/- infinity |
fstsw word ptr [ESP] ; equal for 87/287 |
fwait ; wait fstsw to complete |
pop EAX ; get NDP status word |
mov AL,2 ; assume 80287 |
sahf ; store condition bits in flags |
jz not387 ; it's 287 if infinities equal |
mov AL,3 ; indicate 80387 |
not387: finit ; re-initialize the 8087 |
nox87: mov AH,0 |
ret ; return |
__x87id endp |
endmod |
end |
/programs/develop/open watcom/trunk/clib/intel/chipbug.c |
---|
0,0 → 1,58 |
/**************************************************************************** |
* |
* 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: verify Pentium processor divide bug |
* |
****************************************************************************/ |
#include "variety.h" |
#include <rtinit.h> |
#include "rtdata.h" |
extern unsigned _WCNEAR __chipbug; |
enum { |
PROB_P5_DIV = 0x0001 |
}; |
_WCRTLINK void __verify_pentium_fdiv_bug() |
{ |
/* |
Verify we have got the Pentium FDIV problem. |
The volatiles are to scare the optimizer away. |
*/ |
volatile double num = 4195835; |
volatile double denom = 3145727; |
if( _RWD_real87 >= 3 ) { |
if( (num - (num/denom)*denom) > 1.0e-8 ) { |
__chipbug |= PROB_P5_DIV; |
} |
} |
} |
AXI( __verify_pentium_fdiv_bug, INIT_PRIORITY_FPU + 4 ); |
/programs/develop/open watcom/trunk/clib/intel/chipvar.asm |
---|
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! |
;* |
;***************************************************************************** |
include mdef.inc |
xref "C",__verify_pentium_fdiv_bug |
name chipvar |
datasegment |
xdefp ___chipbug |
xdefp __chipbug |
___chipbug label byte |
__chipbug label byte |
dd 0 |
enddata |
end |
/programs/develop/open watcom/trunk/clib/intel/grabfp87.c |
---|
0,0 → 1,59 |
/**************************************************************************** |
* |
* 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 "variety.h" |
//#include <signal.h> |
#include "rtdata.h" |
extern void __Init_FPE_handler(); |
extern void __Fini_FPE_handler(); |
#ifdef __DOS_386__ |
extern int __FPEHandlerStart_; |
extern int __FPEHandlerEnd_; |
extern int __DPMI_hosted(void); |
#endif |
void __GrabFP87( void ) |
{ |
#ifndef __WINDOWS__ |
if( _RWD_FPE_handler_exit != __Fini_FPE_handler ) { |
#ifdef __DOS_386__ |
if( !_IsPharLap() && ( __DPMI_hosted() == 1 )) { |
DPMILockLinearRegion((long)&__FPEHandlerStart_, |
((long)&__FPEHandlerEnd_ - (long)&__FPEHandlerStart_)); |
} |
#endif |
__Init_FPE_handler(); |
_RWD_FPE_handler_exit = __Fini_FPE_handler; |
} |
#endif |
} |
/programs/develop/open watcom/trunk/clib/intel/i64ts386.asm |
---|
0,0 → 1,265 |
;***************************************************************************** |
;* |
;* 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 |
include struct.inc |
modstart i64tos |
; |
; |
; int _CmpBigInt( int sigdigits, int near *bigint ) |
; EAX EDX |
; |
xdefp __CmpBigInt |
xdefp __Rnd2Int |
xdefp __Bin2String |
defpe __CmpBigInt |
push EDI ; save EDI |
push ECX ; save ECX |
call getpow10 ; get address of Power of 10 table |
inc EAX ; ++sigdigits |
lea EDI,[EDI+EAX*8] ; point to Pow10Table[sigdigits+1] |
mov ECX,[EDX] ; get 64-bit integer |
mov EDX,4[EDX] ; ...(high part) |
sub EAX,EAX ; set adjustment to 0 |
_loop ; loop |
cmp EDX,cs:[EDI] ; - check against 10**k |
_if e ; - if high parts equal |
cmp ECX,cs:4[EDI] ; - - compare low part |
_endif ; - endif |
_quif b ; - quit if num < 10**k |
add EDI,8 ; - set pointer to 10**(k+1) |
inc EAX ; - increment adjustment word |
_endloop ; endloop |
sub EDI,8 ; point at 10**(k-1) |
_loop ; loop |
cmp EDX,cs:[EDI] ; - check against 10**k |
_if e ; - if high parts equal |
cmp ECX,cs:4[EDI] ; - - compare low part |
_endif ; - endif |
_quif nb ; - quit if num >= 10**(k-1) |
sub EDI,8 ; - set pointer to 10**(k-2) |
dec EAX ; - increment adjustment word |
_endloop ; endloop |
pop ECX ; restore ECX |
pop EDI ; restore EDI |
ret ; return to caller |
endproc __CmpBigInt |
;[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] |
;[] |
;[] Rnd2int rounds the real pointed to by EAX to a 64 bit integer. |
;[] |
;[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] |
; void _Rnd2Int( double near *realnum, int near *bigint ) |
; EAX EDX |
; |
defpe __Rnd2Int |
push EBX ; save registers |
push ECX ; save ECX |
push EDX ; save EDX |
push EBP ; save EBP |
push ESI ; save ESI |
push EDX ; save address of bigint array |
mov EBP,EAX ; get address of realnum |
mov ECX,[EBP] ; load the number |
mov EBX,4[EBP] ; . . . |
mov EBP,EBX ; save high word |
and EBP,0FFF00000h ; isolate exponent in EBP |
xor EBX,EBP ; isolate mantissa in EDX |
xor EBX,00100000h ; turn on implied '1' bit in mantissa |
shr EBP,20 ; move exponent to bottom part of word |
sub EBP,0433h ; calculate difference from 2**53 |
_if ne ; if not already the right size |
_if a ; - if too big |
_loop ; - - loop |
shl ECX,1 ; - - - shift real left by one |
rcl EBX,1 ; - - - . . . |
dec EBP ; - - - decrement count |
_until e ; - - until count = 0 |
_else ; - else |
sub EAX,EAX ; - - clear remainder |
sub ESI,ESI ; - - clear remainder bit bucket |
_loop ; - - loop |
shr EBX,1 ; - - - shift real right by one |
rcr ECX,1 ; - - - . . . |
rcr EAX,1 ; - - - save remainder |
adc ESI,ESI ; - - - remember if any bits fell off end |
inc EBP ; - - - increment count |
_until e ; - - until e |
_guess rup ; - - do we have to round up? |
cmp EAX,80000000h;- - - compare remainder with .5000000 |
_quif b,rup ; - - - kick out if less than .5 |
_if e ; - - - magical stuff if looks like a .5 |
or ESI,ESI ; - - - any bits dropped off the bottom |
_if e ; - - - if not |
test ECX,1 ; - - - - - is bottom digit even? |
_quif e,rup ; - - - - - kick out if it is |
_endif ; - - - - endif |
_endif ; - - - endif |
add ECX,01 ; - - - round up the number |
adc EBX,00 ; - - - . . . |
_endguess ; - - endguess |
_endif ; - endif |
_endif ; endif |
pop EBP ; get address of bigint array |
mov [EBP],ECX ; store 64-bit integer |
mov 4[EBP],EBX ; . . . |
pop ESI ; restore ESI |
pop EBP ; restore EBP |
pop EDX ; restore EDX |
pop ECX ; restore ECX |
pop EBX ; restore EBX |
ret ; return |
endproc __Rnd2Int |
;[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] |
;[] |
;[] Bin2string converts a binary integer into a string |
;[] |
;[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] |
; void _Bin2String( |
; int near *bigint, /* EAX */ |
; char near *bufptr, /* EDX */ |
; int sigdigits ) /* EBX */ |
; |
defpe __Bin2String |
push EBP ; save EBP |
push EDI ; save EDI |
push ECX ; save ECX |
push EBX ; save EBX |
mov EBP,EAX ; get address of bigint array |
mov ECX,[EBP] ; get 64-bit integer |
mov EAX,4[EBP] ; . . . |
mov EBP,EDX ; get buffer pointer |
add EBP,EBX ; point to end of buffer |
mov byte ptr [EBP],0; put in null character |
; |
; input: |
; EAX:ECX - 64-bit integer |
; EBP - pointer to buffer for digits |
; EBX - digit count |
push EAX ; save high word of quotient |
_loop ; loop |
pop EAX ; - restore high word of quotient |
mov EDI,10000 ; - divisor is 10000 |
sub EDX,EDX ; - zero high word |
or EAX,EAX ; - check high word |
jne div1 ; - do all divides |
or ECX,ECX ; - check low order word |
jne div2 ; - skip first divide |
push EAX ; - save high word of quotient |
jmp short div5 ; - result is 0 |
div1: div EDI ; - divide EAX:ECX by 10000 |
div2: xchg ECX,EAX ; - ... |
div EDI ; - ... |
; quotient is in ECX:EAX |
; remainder is in EDX |
xchg ECX,EAX ; - move quotient to EAX:ECX |
push EAX ; - save high word of quotient |
mov EAX,EDX ; - get remainder |
mov DL,100 ; - get divisor |
div DL ; - split remainder into 2 parts |
mov DL,AH ; - save low order part |
mov AH,0 ; - zero |
aam ; - split top part into 2 digits |
xchg EDX,EAX ; - DH, DL gets top 2 digits, AX gets low part |
mov AH,0 ; - zero |
aam ; - split low part into 2 digits |
div5: add AX,3030h ; - make ASCII digits |
add DX,3030h ; - ... |
sub EBP,4 ; - move back 4 |
mov 3[EBP],AL ; - put low order digit in buffer |
dec EBX ; - decrement digit count |
_quif e ; - quit if done |
mov 2[EBP],AH ; - ... |
dec EBX ; - decrement digit count |
_quif e ; - quit if done |
mov 1[EBP],DL ; - ... |
dec EBX ; - decrement digit count |
_quif e ; - quit if done |
mov [EBP],DH ; - put high order digit in buffer |
dec EBX ; - decrement digit count |
_until e ; until done |
pop EAX ; remove high word of quotient |
pop EBX ; restore EBX |
pop ECX ; restore ECX |
pop EDI ; restore EDI |
pop EBP ; restore EBP |
ret ; return |
endproc __Bin2String |
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> |
;<> <> |
;<> 64-bit integer powers of 10 table <> |
;<> <> |
;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> |
getpow10 proc near ; get address of powers of 10 table |
call pow10end ; call around the table |
pow10table: ; powers of 10 table |
dd 000000000h,000000000h ; 0 |
dd 000000000h,000000001h ; 10**00 |
dd 000000000h,00000000ah ; 10**01 |
dd 000000000h,000000064h ; 10**02 |
dd 000000000h,0000003e8h ; 10**03 |
dd 000000000h,000002710h ; 10**04 |
dd 000000000h,0000186a0h ; 10**05 |
dd 000000000h,0000f4240h ; 10**06 |
dd 000000000h,000989680h ; 10**07 |
dd 000000000h,005f5e100h ; 10**08 |
dd 000000000h,03b9aca00h ; 10**09 |
dd 000000002h,0540be400h ; 10**10 |
dd 000000017h,04876e800h ; 10**11 |
dd 0000000e8h,0d4a51000h ; 10**12 |
dd 000000918h,04e72a000h ; 10**13 |
dd 000005af3h,0107a4000h ; 10**14 |
dd 000038d7eh,0a4c68000h ; 10**15 |
dd 0002386f2h,06fc10000h ; 10**16 |
dd 001634578h,05d8a0000h ; 10**17 |
dd 00de0b6b3h,0a7640000h ; 10**18 |
dd 08ac72304h,089e80000h ; 10**19 |
dd 0ffffffffh,0ffffffffh ; MAX |
pow10end proc near |
pop EDI ; get address of table |
ret ; return |
endproc pow10end |
endproc getpow10 |
endmod |
end |
/programs/develop/open watcom/trunk/clib/intel/save8087.c |
---|
0,0 → 1,40 |
/**************************************************************************** |
* |
* 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 "variety.h" |
#include "87state.h" |
#include "rtdata.h" |
static void _do_nothing( _87state *st ) {} |
void (*_RWD_Save8087)(_87state *) = _do_nothing; |
void (*_RWD_Rest8087)(_87state *) = _do_nothing; |
/programs/develop/open watcom/trunk/clib/intel/segread.c |
---|
0,0 → 1,60 |
/**************************************************************************** |
* |
* 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 "variety.h" |
#include <i86.h> |
extern unsigned short _CS(), _DS(), _ES(), _SS(); |
#pragma aux _CS = 0x8C 0xC8 /* mov ax,cs */ value [ax]; |
#pragma aux _DS = 0x8C 0xD8 /* mov ax,ds */ value [ax]; |
#pragma aux _ES = 0x8C 0xC0 /* mov ax,es */ value [ax]; |
#pragma aux _SS = 0x8C 0xD0 /* mov ax,ss */ value [ax]; |
#if defined(__386__) |
extern unsigned short _FS(), _GS(); |
#pragma aux _FS = 0x8C 0xE0 /* mov ax,fs */ value [ax]; |
#pragma aux _GS = 0x8C 0xE8 /* mov ax,gs */ value [ax]; |
#endif |
_WCRTLINK void segread( struct SREGS *segregs ) |
{ |
__ptr_check( segregs, 0 ); |
segregs->cs = _CS(); |
segregs->ds = _DS(); |
segregs->es = _ES(); |
segregs->ss = _SS(); |
#if defined(__386__) |
segregs->fs = _FS(); |
segregs->gs = _GS(); |
#endif |
} |
/programs/develop/open watcom/trunk/clib/math/abs.c |
---|
0,0 → 1,44 |
/**************************************************************************** |
* |
* 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: Implementation of abs(). |
* |
****************************************************************************/ |
#undef __INLINE_FUNCTIONS__ |
#include "variety.h" |
#include <stdlib.h> |
_WCRTLINK int abs( int i ) |
/************************/ |
{ |
if( i < 0 ) |
i = - i; |
return( i ); |
} |
/programs/develop/open watcom/trunk/clib/math/hugeval.c |
---|
0,0 → 1,34 |
/**************************************************************************** |
* |
* 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 "variety.h" |
_WCRTLINKD unsigned short const _HUGEDATA _HugeValue[] = { 0x0000, 0x0000, 0x0000, 0x7ff0 }; |
/programs/develop/open watcom/trunk/clib/math/hvalptr.c |
---|
0,0 → 1,39 |
/**************************************************************************** |
* |
* 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 "variety.h" |
#include <math.h> |
#include "rtdata.h" |
_WCRTLINK const double (*__get_HugeValue_ptr()) { |
return &_HugeValue; |
} |
/programs/develop/open watcom/trunk/clib/math/imaxabs.c |
---|
0,0 → 1,42 |
/**************************************************************************** |
* |
* 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: Implementation if imaxabs(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include <inttypes.h> |
_WCRTLINK intmax_t imaxabs( intmax_t j ) |
/**************************************/ |
{ |
if( j < 0 ) |
j = - j; |
return( j ); |
} |
/programs/develop/open watcom/trunk/clib/math/imaxdiv.c |
---|
0,0 → 1,44 |
/**************************************************************************** |
* |
* 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: Implementation of imaxdiv(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include <inttypes.h> |
_WCRTLINK imaxdiv_t imaxdiv( intmax_t numer, intmax_t denom ) |
/*************************************************************/ |
{ |
imaxdiv_t result; |
result.quot = numer / denom; |
result.rem = numer % denom; |
return( result ); |
} |
/programs/develop/open watcom/trunk/clib/math/labs.c |
---|
0,0 → 1,43 |
/**************************************************************************** |
* |
* 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: Implementation of labs(). |
* |
****************************************************************************/ |
#undef __INLINE_FUNCTIONS__ |
#include "variety.h" |
#include <stdlib.h> |
_WCRTLINK long int labs( long int i ) |
/***********************************/ |
{ |
if( i < 0 ) |
i = - i; |
return( i ); |
} |
/programs/develop/open watcom/trunk/clib/math/llabs.c |
---|
0,0 → 1,42 |
/**************************************************************************** |
* |
* 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: Implementation of llabs(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include <stdlib.h> |
_WCRTLINK long long int llabs( long long int i ) |
/**********************************************/ |
{ |
if( i < 0 ) |
i = - i; |
return( i ); |
} |
/programs/develop/open watcom/trunk/clib/math/max.c |
---|
0,0 → 1,40 |
/**************************************************************************** |
* |
* 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: Implementation of max(). |
* |
****************************************************************************/ |
#include "variety.h" |
#undef max |
_WCRTLINK int max( int a, int b ) |
/*******************************/ |
{ |
return( ( a > b ) ? a : b ); |
} |
/programs/develop/open watcom/trunk/clib/math/min.c |
---|
0,0 → 1,40 |
/**************************************************************************** |
* |
* 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: Implementation of min(). |
* |
****************************************************************************/ |
#include "variety.h" |
#undef min |
_WCRTLINK int min( int a, int b ) |
/*******************************/ |
{ |
return( ( a < b ) ? a : b ); |
} |
/programs/develop/open watcom/trunk/clib/math/rand.c |
---|
0,0 → 1,68 |
/**************************************************************************** |
* |
* 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: Implementation of rand() and srand(). |
* |
****************************************************************************/ |
#include "variety.h" |
#include <stdlib.h> |
#include "randnext.h" |
#include "rtdata.h" |
static unsigned long *initrandnext( void ) |
{ |
_INITRANDNEXT( RETURN_ARG( unsigned long *, NULL ) ); |
return( (unsigned long *)&_RWD_randnext ); |
} |
_WCRTLINK int rand( void ) |
/************************/ |
{ |
unsigned long *randptr; |
randptr = initrandnext(); |
if( randptr == NULL ) { |
return( 0 ); |
} |
*randptr = *randptr * 1103515245 + 12345; |
return( (int)( (*randptr >> 16) & 0x7FFF ) ); |
} |
_WCRTLINK void srand( unsigned int seed ) |
/***************************************/ |
{ |
unsigned long *randptr; |
randptr = initrandnext(); |
if( randptr != NULL ) { |
*randptr = seed; |
} |
} |
/programs/develop/open watcom/trunk/clib/math/randnext.h |
---|
0,0 → 1,59 |
/**************************************************************************** |
* |
* 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 "variety.h" |
#define _INITRANDNEXT(p) |
#if defined(__OS2__) || defined(__NT__) || defined(__NETWARE__) |
// OS/2, NT and NETWARE versions are identical |
// note that NETWARE is always multi-threaded |
#if defined(__SW_BM) |
#include "thread.h" |
#if 0 |
// who ever allocates the thread_data should initialize __randnext |
if( __THREADDATAPTR->__randnextinit == 0 ) { \ |
__THREADDATAPTR->__randnextinit = 1; \ |
__THREADDATAPTR->__randnext = 1; \ |
} |
#endif |
#define _RANDNEXT (__THREADDATAPTR->__randnext) |
#else |
static unsigned long int next = 1; |
#define _RANDNEXT next |
#endif |
#else |
static unsigned long int next = 1; |
#define _RANDNEXT next |
#endif |
/programs/develop/open watcom/trunk/clib/src/chipt32.asm |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/chipbug.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/toupper.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/ltoa.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/abs.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/chipr32.asm |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/chipa32.asm |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/lltoa.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/chipvar.asm |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/atoi.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/itoa.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/chipd32.asm |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/alphabet.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/tolower.c |
---|
File deleted |
/programs/develop/open watcom/trunk/clib/src/87state.h |
---|
0,0 → 1,45 |
/**************************************************************************** |
* |
* 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: prototype for 8087 save/restore state functions and data |
* |
****************************************************************************/ |
#if defined(_M_IX86) |
typedef struct _87state { /* 80x87 save area */ |
#if defined( __386__ ) |
char data[108]; /* 32-bit save area size */ |
#else |
char data[94]; /* 16-bit save area size */ |
#endif |
} _87state; |
extern void (*__Save8087)(_87state *); |
extern void (*__Rest8087)(_87state *); |
#endif |