MTH$TANH        ; Floating Point Hyperbolic Tangent routine      21-AUG-1978 19:09:16   VAX-11 MACRO X0.3-11               Page   0

TABLE OF CONTENTS   



   (2)     100  HISTORY	; Detailed Current Edit History

   (3)     100  DECLARATIONS	; Declarative Part of Module

   (4)     100  MTH$TANH  - Standard Single Precision Floating 

MTH$TANH        ; Floating Point Hyperbolic Tangent routine      21-AUG-1978 19:09:16   VAX-11 MACRO X0.3-11               Page   1

01-5                                                                                                                             (1)



                                     0000   100 	.TITLE	MTH$TANH 	; Floating Point Hyperbolic Tangent routine

                                     0000   200 				; (TANH)

                                     0000   300 	.IDENT /01-5/		; File: MTHTANH.MAR

                                     0000   400 ;

                                     0000   500 ; Copyright (C) 1977

                                     0000   600 ; Digital Equipment Corporation, Maynard, Massachusetts 01754

                                     0000   700 ;

                                     0000   800 ; This  software  is furnished under a license for use only on a single

                                     0000   900 ; computer  system  and  may  be  copied only with the inclusion of the

                                     0000  1000 ; above copyright notice.  This software, or  any other copies thereof,

                                     0000  1100 ; may not  be  provided or otherwise made available to any other person

                                     0000  1200 ; except  for  use on such system and to one who agree to these license 

                                     0000  1300 ; terms.  Title  to  and  ownership of the software shall  at all times 

                                     0000  1400 ; remain in DEC.

                                     0000  1500 ;

                                     0000  1600 ; The information  in  the software is subject to change without notice

                                     0000  1700 ; and should  not  be  construed  as  a commitment by Digital Equipment 

                                     0000  1800 ; Corporation.

                                     0000  1900 ;

                                     0000  2000 ; DEC assumes  no  responsibility  for  the use  or  reliability of its

                                     0000  2100 ; software on equipment which is not supplied by DEC.

                                     0000  2200 ;

                                     0000  2300 ;

                                     0000  2400 ; FACILITY: MATH LIBRARY

                                     0000  2500 ;++

                                     0000  2600 ; ABSTRACT:

                                     0000  2700 ;

                                     0000  2800 ; MTH$TANH is a function  which  returns the floating point hyperbolic tangent

                                     0000  2900 ; of its single precision floating point argument. The call is standard

                                     0000  3000 ; call-by-reference.

                                     0000  3100 ;

                                     0000  3200 ;--

                                     0000  3300 ;

                                     0000  3400 ; VERSION: 01

                                     0000  3500 ;

                                     0000  3600 ; HISTORY:

                                     0000  3700 ; AUTHOR:

                                     0000  3800 ;	Peter Yuo, 29-Jun-77: Version 01

                                     0000  3900 ;

                                     0000  4000 ; MODIFIED BY:

                                     0000  4100 ;

                                     0000  4200 ;

                                     0000  4300 ;

MTH$TANH        ; Floating Point Hyperbolic Tangent routine      21-AUG-1978 19:09:16   VAX-11 MACRO X0.3-11               Page   2

01-5            HISTORY ; Detailed Current Edit History                                                                          (2)



                                     0000   100 	.SBTTL	HISTORY	; Detailed Current Edit History

                                     0000   200 

                                     0000   300 

                                     0000   400 ; ALGORITHMIC DIFFERENCES FROM FP-11/C ROUTINE:	none

                                     0000   500 ;

                                     0000   600 ; Edit History for Version 01 of MTH$TANH 

                                     0000   700 ;

                                     0000   800 ; 0-4	- Call MTH$COSH, MTH$SINH directly instead of using POLY.  TNH 13-June-78

                                     0000   900 ; 0-5	- Declare externals, word offsets.  TNH 13-June-78

MTH$TANH        ; Floating Point Hyperbolic Tangent routine      21-AUG-1978 19:09:16   VAX-11 MACRO X0.3-11               Page   3

01-5            DECLARATIONS ; Declarative Part of Module                                                                        (3)



                                     0000   100 	.SBTTL	DECLARATIONS	; Declarative Part of Module

                                     0000   200 

                                     0000   300 ;

                                     0000   400 ; INCLUDE FILES:	OTSPARAMS.MAR

                                     0000   500 ;

                                     0000   600 ; EXTERNAL SYMBOLS:	MTH$JACKET_HDLR

                                     0000   700 ;

                                     0000   750 	.DSABL	GBL			; Force all symbols to need .EXTERN

                                     0000   760 	.EXTRN	MTH$EXP_R4		; EXP

                                     0000   770 	.EXTRN	MTH$COSH		; COSH

                                     0000   780 	.EXTRN	MTH$SINH		; SINH

                                     0000   800 ; EQUATED SYMBOLS:

                                     0000   900 

                           00003F80  0000  1000 	LF_0.25	= 0@16 + ^X3F80		; 0.25

                           00003980  0000  1100 	LF_2_POWER_M14	= 0@16 + ^X3980	; 2**-14

                           00004080  0000  1200 	SF_1.0	= ^F1.0			; 1.0

                           00004280  0000  1300 	SF_16.0	= ^F16.0			; 16.0

                           00000004  0000  1400 	value	= 4			; value.rf.r

                                     0000  1500 

                                     0000  1600 ;

                                     0000  1700 ; MACROS:	none

                                     0000  1800 ;

                                     0000  1900 ; PSECT DECLARATIONS:

                                     0000  2000 

                                 00000000  2100 	.PSECT	MTH$CODE	PIC,SHR,LONG,EXE,NOWRT

                                     0000  2200 					; program section for math routines

                                     0000  2300 ;

                                     0000  2400 ; OWN STORAGE:	none

                                     0000  2500 ;

                                     0000  2600 ;

                                     0000  2700 ; CONSTANTS:

                                     0000  2800 ;

                                     0000  3000 ;	NONE

MTH$TANH        ; Floating Point Hyperbolic Tangent routine      21-AUG-1978 19:09:16   VAX-11 MACRO X0.3-11               Page   4

01-5            MTH$TANH  - Standard Single Precision Floating                                                                   (4)



                                     0000   100 	.SBTTL	MTH$TANH  - Standard Single Precision Floating TANH

                                     0000   200 

                                     0000   300 

                                     0000   400 ;++

                                     0000   500 ; FUNCTIONAL DESCRIPTION:

                                     0000   600 ;

                                     0000   700 ; TANH  - single precision floating point function

                                     0000   800 ;

                                     0000   900 ; TANH(X) is computed as:

                                     0000  1000 ;

                                     0000  1100 ;	If |X| =< 2**-14, then TANH(X) = X.

                                     0000  1200 ;	If 2**-14 < |X| =< 0.25, then TANH(X) = SINH(X)/COSH(X).

                                     0000  1300 ;	If 0.25 < |X| < 16.0, then TANH(X) = (EXP(2*X) - 1) / (EXP(2*X) + 1)

                                     0000  1400 ;	If 16.0 =< |X|, then TANH(X) = sign(X) * 1

                                     0000  1500 ;

                                     0000  1600 ; CALLING SEQUENCE:

                                     0000  1700 ;

                                     0000  1800 ;	TANH.wf.v = MTH$TANH(x.rf.r)

                                     0000  1900 ;

                                     0000  2000 ; INPUT PARAMETERS:

                                     0000  2100 

                           00000004  0000  2200 	LONG = 4			; define longword multiplier

                           00000004  0000  2300 	x = 1 * LONG			; Contents of x is the argument

                                     0000  2400 

                                     0000  2500 ; IMPLICIT INPUTS:	none

                                     0000  2600 ;

                                     0000  2700 ; OUTPUT PARAMETERS:

                                     0000  2800 ;

                                     0000  2900 ;	VALUE:	floating hyperbolic tangent of the argument

                                     0000  3000 ;

                                     0000  3100 ; IMPLICIT OUTPUTS:	none

                                     0000  3200 ;

                                     0000  3300 ; COMPLETION CODES:	none

                                     0000  3400 ;

                                     0000  3500 ; SIDE EFFECTS:	none

                                     0000  3600 ;

                                     0000  3700 ; NOTE: This procedure disables floating point underflow, enables integer

                                     0000  3800 ; overflow.

                                     0000  3900 ;

                                     0000  4000 ;---

                                     0000  4100 

                                     0000  4200 

                               401C' 0000  4300 	.ENTRY	MTH$TANH, ^M<IV, R2, R3, R4>

                                     0002  4400 					; standard call-by-reference entry

                                     0002  4500 					; disable DV (and FU), enable IV

                                     0002  4600 	MTH$FLAG_JACKET			; flag that this is a jacket procedure in

                                     0002      

            6D       0000'CF     3E  0002       	MOVAW	W^MTH$$JACKET_HND, (FP)

                                     0007       					; set handler address to jacket

                                     0007       					; handler

                                     0007       

                                     0007  4700 					; case of an error in routine

                                     0007  4800 					; If an error, convert signal to user PC

                                     0007  4900 					; and resignal

            50         04 BC     50  0007  5000 	MOVF	@value(AP), R0		; R0 = |X| = @value(AP)

            50       8000 8F     AA  000B  5100 	BICW	#^X8000, R0		; R0 = |X|

   00003980 8F            50     51  0010  5200 	CMPF	R0, #LF_2_POWER_M14	; compare |X| with 2**-14

MTH$TANH        ; Floating Point Hyperbolic Tangent routine      21-AUG-1978 19:09:16   VAX-11 MACRO X0.3-11               Page   5

01-5            MTH$TANH  - Standard Single Precision Floating                                                                   (4)



                          40     15  0017  5300 	BLEQ	OUT_X			; branch if |X| =< 2**-14

                                     0019  5400 

                                     0019  5500 ;

                                     0019  5600 ; 2**-14 < |X|

                                     0019  5700 ;

                                     0019  5800 

            28            50     51  0019  5900 	CMPF	R0, S^#SF_16.0		; compare |X| with 16.0

                          2F     18  001C  6000 	BGEQ	GEQ_TO_16.0		; branch if |X| >= 16.0

                                     001E  6100 

                                     001E  6200 ;

                                     001E  6300 ; 2**-14 < |X| < 16.0

                                     001E  6400 ;

                                     001E  6500 

   00003F80 8F            50     51  001E  6600 	CMPF	R0, #LF_0.25		; compare |X| with 0.25

                          15     15  0025  6700 	BLEQ	LEQ_TO_0.25		; branch if |X| =< 0.25

                                     0027  6800 

                                     0027  6900 ;

                                     0027  7000 ; 0.25 < |X| < 16.0

                                     0027  7100 ;

                                     0027  7200 

         04 BC         04 BC     41  0027  7300 	ADDF3	@value(AP), @value(AP), R0

                          50         002C       

                                     002D  7400 					; R0 = 2*X

                     0000'CF     16  002D  7500 	JSB	W^MTH$EXP_R4		; R0 = EXP(2*X)

            50            08     41  0031  7600 	ADDF3	S^#SF_1.0, R0, R1	; R1 = EXP(2*X) + 1

                          51         0034       

            50            08     42  0035  7700 	SUBF	S^#SF_1.0, R0		; R0 = EXP(2*X) - 1

            50            51     46  0038  7800 	DIVF	R1, R0			; R0 = (EXP(2*X) - 1) / (EXP(2*X) + 1)

                                 04  003B  7900 	RET				; return with result in R0

                                     003C  8000 

                                     003C  8100 ;

                                     003C  8200 ; 2**-14 < |X| =< 0.25

                                     003C  8300 ;

                                     003C  8400 

                                     003C  8500 LEQ_TO_0.25:

       0000'CF            6C     FA  003C  8600 	CALLG	(AP), W^MTH$COSH		; R0 = COSH(X)

            52            50     50  0041  8800 	MOVF	R0, R2			; R2 = COSH(X)

       0000'CF            6C     FA  0044  8900 	CALLG	(AP), W^MTH$SINH		; R0 = SINH(X)

            50            52     46  0049  9100 	DIVF	R2, R0			; R0 = SINH(X) / COSH(X)

                                 04  004C  9200 	RET				; return with result in R0

                                     004D  9300 

                                     004D  9400 ;

                                     004D  9500 ; |X| >= 16.0

                                     004D  9600 ;

                                     004D  9700 

                                     004D  9800 GEQ_TO_16.0:

            50            08     50  004D  9900 	MOVF	S^#SF_1.0, R0		; R0 = 1.0

                       04 BC     53  0050 10000 	TSTF	@value(AP)		; test the sign of X

                          03     18  0053 10100 	BGEQ	10$			; branch if X >= 0

            50            50     52  0055 10200 	MNEGF	R0, R0			; R0 = -1

                                 04  0058 10300 10$:	RET				; return with result in R0

                                     0059 10400 

                                     0059 10500 ;

                                     0059 10600 ; |X| =< 2**-14

                                     0059 10700 ;

                                     0059 10800 

            50         04 BC     50  0059 10900 OUT_X:	MOVF	@value(AP), R0		; R0 = TANH(X) = X

MTH$TANH        ; Floating Point Hyperbolic Tangent routine      21-AUG-1978 19:09:16   VAX-11 MACRO X0.3-11               Page   6

01-5            MTH$TANH  - Standard Single Precision Floating                                                                   (4)



                                 04  005D 11000 	RET				; return with result in R0

                                     005E 11100 

                                     005E 11200 

                                     005E 11300 

                                     005E 11400 	.END

MTH$TANH        ; Floating Point Hyperbolic Tangent routine      21-AUG-1978 19:09:16   VAX-11 MACRO X0.3-11               Page   7

SYMBOL TABLE                                                                                                                     (4)



FOR$K_ERR_PREFX= 00000018            

GEQ_TO_16.0      0000004D R     02   

LEQ_TO_0.25      0000003C R     02   

LF_0.25        = 00003F80            

LF_2_POWER_M14 = 00003980            

LONG           = 00000004            

MTH$$JACKET_HND  ********   X   02   

MTH$COSH         ********   X   01   

MTH$EXP_R4       ********   X   01   

MTH$K_ERR_PREFX= 00000016            

MTH$SINH         ********   X   01   

MTH$TANH         00000000 RG    02   

MTH__FLOOVEMAT = 00000058            

MTH__FLOUNDMAT = 00000059            

MTH__INVARG    = 00000051            

MTH__LOGZERNEG = 00000053            

MTH__SINSIGLOS = 00000057            

MTH__SQUROONEG = 00000054            

MTH__UNDEXP    = 00000052            

MTH__WRONUMARG = 00000050            

OUT_X            00000059 R     02   

SF_1.0         = 00004080            

SF_16.0        = 00004280            

VALUE          = 00000004            

X              = 00000004            





PROGRAM SECTION SYNOPSIS



.  ABS  .        00000000      00     NOPIC   USR   CON   ABS   LCL NOSHR NOEXE NORD  NOWRT BYTE  

. BLANK .        00000000      01     NOPIC   USR   CON   REL   LCL NOSHR   EXE   RD    WRT BYTE  

MTH$CODE         0000005E      02       PIC   USR   CON   REL   LCL   SHR   EXE   RD  NOWRT LONG  





THERE WERE NO ERRORS OR WARNINGS.

27790. BYTES LEFT IN FREE MEMORY POOL.

OBJ$:MTHTANH,LIS$:MTHTANH/-SP=LIB$:S/ML,SRC$:P,MTHTANH

0 MLB DIR RDS - 0 GETS TO DEFINE 0 MACROS. 2 INTER. FILE WRITES. 

