home *** CD-ROM | disk | FTP | other *** search
- Copyright (C) 1992 MetaWare Incorporated; All Rights Reserved.
-
- High C/C++ Version 3.0
- Globally Optimizing Compiler
- for Extended DOS 80386/486 and Windows 3.0
- April 1992
-
- +-------------------------+
- | Weitek ABACUS Support |
- +-------------------------+
-
-
- Table of Contents
- -----------------
-
- 1. Compiling
- 2. Calling Convention
- 3. 386|DOS-Extender
- 4. stdio.h
- 5. Libraries
- 6. Library Name Space
- 7. Math Errors
-
-
- 1. Compiling
- -------------
-
- To generate Weitek code, compile your program with driver command-line option
- -f4167, -f3167 or -f1167. This will:
-
- * Turn on toggle 4167, 3167, or 1167, respectively.
-
- * Link with library HCWP.LIB.
-
- * Define the macro __1167 to be 1 (this macro is used for conditional
- preprocessing in stdio.h).
-
- * -f4167 also turns on additional 486 floating-point optimizations.
-
- Read Programmer's Guide chapter "Floating-Point Support" for additional
- information.
-
- Driver command-line options:
-
- -f4167 Enables Weitek 4167 floating-point-coprocessor instruction
- generation and also enables 486-specific optimizations.
- Links with the Weitek library hcwp and defines __1167.
-
- -f3167, Enable Wietek 3167/1167 floating-point-coprocessor instruction
- -f1167 generation, link with the Weitek library hcwp, and define __1167.
-
-
-
- 2. Calling Convention
- ----------------------
-
- Specify calling-convention attribute _NO_1167 to allow allocation of variables
- to ABACUS scratch registers rather than to nonvolatile registers. _NO_1167
- informs the compiler that a function (and any function that it calls) does not
- modify the ABACUS register set.
-
- If a math function such as sin() calls no other functions, the compiler
- allocates variables to ABACUS scratch registers rather than to nonvolatile
- registers if possible, thereby avoiding the save/restore at entry to/exit from
- sin(). However, if sin() calls another function P(), the worst is assumed:
- that P() modifies the ABACUS scratch registers; and therefore variables are
- not so allocated. The result is that sin() has to save and restore the
- nonvolatile registers.
-
- However, if you use _NO_1167 to indicate that P() does not affect the ABACUS
- registers, the compiler can use ABACUS scratch registers. Or, if P() is an
- error handler that never returns, the effect on sin() is the same: it can
- assume the scratch registers are saved across the call to P().
-
- You can use this if a function calls a library error routine that reports or
- records an error, and either does not use the ABACUS or never returns. For
- instance, sqrt() and asin() both call fprintf(). Informing the compiler that
- fprintf() does not touch the ABACUS improves execution speed. For example,
- modifying stdio.h to surround the declaration of fprintf() with the following
- lines achieves this effect:
-
- pragma Calling_convention(_DEFAULT_CALLING_CONVENTION | _NO_1167);
- ...
- pragma Calling_convention();
-
- See the Programmer's Guide for more information about calling conventions.
-
-
- 3. 386|DOS-Extender
- --------------------
-
- To use the compiler with Phar Lap's 386|DOS-Extender, be sure you have a
- version of 386|DOS-Extender that detects Weitek coprocessors. The MetaWare
- Run-Time Libraries automatically initialize the chip. Phar Lap has
- implemented this since Version 1.1u (Fall 1987).
-
-
- 4. stdio.h
- -----------
-
- Header file stdio.h contains code conditioned on #ifdef __1167. If you use
- driver command-line option -f4167, -f3167, or -f1167, __1167 is automatically
- defined. If you do not use these options, you must provide a definition for
- __1167. A modified version of stdio.h called wstdio.h is included for this
- purpose in the Weitek subdirectory. This header file contains:
-
- #define __1167 1
-
- and then:
-
- #include <stdio.h>
-
- You can use wstdio.h, or just define __1167 and then include stdio.h.
-
-
- 5. Libraries
- -------------
-
- The High C run-time math libraries for transcendentals are included in your
- distribution. If you use header file math.h, you should include these
- libraries in your link before the standard High C libraries. The libraries
- are provided for Phar Lap's environment.
-
- These transcendentals were supplied to MetaWare by Weitek under license. AS
- OF THIS WRITING, printf() and scanf() have not been modified to use the 1167;
- they are awaiting further work.
-
-
- 6. Library Name Space
- ---------------------
-
- Weitek uses names in the transcendental library that are not in the ANSI C
- Standard. Do not use these names if you want to avoid the transcendental
- routines. The following names are in the transcendental library:
-
- _cabs asin fmod rcosh rsqrt_tb2
- _ccos atan log rcot rsqrt
- _cexp atan2 log10 rem rtan
- _clog carg_err pow rexp rtanh
- _csin ceil racos rfmod sin
- _csqrt cos rarg1_err rlog sinh
- _hypot cosh rarg1p_err rlog10 sqrt_tb
- _mwWTKCPR cot rarg2_err rrem sqrt_tb1
- acos cotan_ rarg2p_err rsin sqrt_tb2
- arg1_err dcotan_ rasin rsincosh_tb sqrt_tb3
- arg1p_err exp ratan rsinh sqrt
- arg2_err exp_tb ratan2 rsqrt_tb tan
- arg2p_err floor rcos rsqrt_tb1 tanh
- math_err_control
-
- The following functions should not be called directly; these are library
- functions that return a floating-point type:
-
- atof
- difftime
- strtod
-
- There is a way around this. In general, if you would ordinarily use a non-
- Weitek-supported library function F() as follows:
-
- extern double F();
- ...
- double answer = F();
-
- instead, write:
-
- extern void F_();
- ...
- double answer;
- F_(&answer);
-
- where you compile separately, with the 4167/3167/1167 toggles Off, the
- following code:
-
- extern double F();
- void F_(double *result) { *result = F(); }
-
-
- 7. Math Errors
- --------------
-
- You can trap math errors in the Weitek library by modifying MATHERR.C.
- MATHERR.C in the ETC\SRC subdirectory contains a different specification of
- the exception data structure from \INC\MATH.H, and the two specifications are
- not compatible. MATHERR.C is distributed by Weitek with the Weitek library.
- If you are using the Weitek library, you may have to substitute Weitek's
- definition of exceptions for the one contained in MATH.H.