MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   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$ALOG  - Standard Single Precision Floating 

   (5)     100  MTH$ALOG10  - Standard Single Precision Floatin

   (6)     100  MTH$ALOGLOG10_R5  - Special LOG/LOG10 routines

MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   VAX-11 MACRO X0.3-11               Page   1

01-6                                                                                                                             (1)



                                     0000   100 	.TITLE	MTH$ALOG 	; Floating Point Natural and Common

                                     0000   200 				; Logarithm Functions (ALOG,ALOG10)

                                     0000   300 	.IDENT /01-6/		; File: MTHALOG.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$ALOG and MTH$ALOG10 are functions which return the floating point

                                     0000  2900 ; natural  or common logarithm of their single precision floating point

                                     0000  3000 ; argument. The call is standard call-by-reference.

                                     0000  3100 ; MTH$ALOG_R5  and  MTH$ALOG10_R5   are  special routines which are the

                                     0000  3200 ; same as MTH$ALOG and MTH$ALOG10 except a faster non-standard JSB call

                                     0000  3300 ; is used with the argument in R0 and no registers are saved.

                                     0000  3400 ;

                                     0000  3500 ;--

                                     0000  3600 ;

                                     0000  3700 ; VERSION: 01

                                     0000  3800 ;

                                     0000  3900 ; HISTORY:

                                     0000  4000 ; AUTHOR:

                                     0000  4100 ;	Peter Yuo, 15-Oct-76: Version 01

                                     0000  4200 ;

                                     0000  4300 ; MODIFIED BY:

                                     0000  4400 ;

                                     0000  4500 ; 01-1	Peter Yuo, 22-May-77

                                     0000  4600 ;

                                     0000  4700 ;

MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   VAX-11 MACRO X0.3-11               Page   2

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



                                     0000   100 	.SBTTL	HISTORY	; Detailed Current Edit History

                                     0000   200 

                                     0000   300 

                                     0000   400 ; ALGORITHMIC DIFFERENCE FROM FP-11C ROUTINE:

                                     0000   500 ;	1. Uses POLYD so greater accuracy.

                                     0000   600 ;

                                     0000   700 ; Edit History for Version 01 of MTH$ALOGLOG10 

                                     0000   800 ;

                                     0000   900 ; 01-1	Code saving after code review March 1977

                                     0000  1000 ; 01-2  Finished error handling 10 June 1977

                                     0000  1100 ; 0-3	MTH$$ERROR changed to MTH$$SIGNAL.

                                     0000  1200 ;	MTH$_... changed to MTH__....

                                     0000  1300 ;	Changed error handling mechanism. Put error result in R0 before 

                                     0000  1400 ;	calling MTH$$SIGNAL in order to allow user modify error result.

                                     0000  1500 ; 01-6	Move .ENTRY mask definition.  TNH 14-Aug-78

MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   VAX-11 MACRO X0.3-11               Page   3

01-6            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   800 ; EQUATED SYMBOLS:

                                     0000   900 

                           0000403C  0000   950 	ACMASK = ^M<IV, R2, R3, R4, R5>	; register entry mask and int ovf enable

                           00004080  0000  1000 	SF_1		= ^F1.0		; short floating literal 1.0

                           5BD93FDE  0000  1100 	LF_LOG10_E	= ^X5BD93FDE	; LOG10(e)

                           00003F80  0000  1200 	LF_1_OVER_4	= ^X3F80	; 1/4

                           72183CB1  0000  1300 	LF_LOG_2_OV_128 = ^X72183CB1	; LOG(2)

                           04F34035  0000  1400 	LF_SQRT_2_OV_2	= ^X04F34035	; SQRT(2)/2

                           7218BFB1  0000  1500 	LF_MI_LG_2_OV_2	= ^X7218BFB1	; -LOG(2)/2

                                     0000  1600 

                                     0000  1700 ;

                                     0000  1800 ; MACROS:	none

                                     0000  1900 ;

                                     0000  2000 ; PSECT DECLARATIONS:

                                     0000  2100 

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

                                     0000  2300 					; program section for math routines

                                     0000  2400 ;

                                     0000  2500 ; OWN STORAGE:	none

                                     0000  2600 ;

                                     0000  2700 ; CONSTANTS:

                                     0000  2800 

                                     0000  2900 LOGTAB:					; table of ordered coefficients 

                                     0000  3000 					; for use in POLY

                           19553F9A  0000  3100 	.LONG	^X19553F9A		; C3 = 0.300974506

                           A01E3FCC  0004  3200 	.LONG	^XA01E3FCC		; C2 = +0.399659100

                           AADA402A  0008  3300 	.LONG	^XAADA402A		; C1 = 0.666669471

                           00004100  000C  3400 	.LONG	^X00004100		; C0 = 1.99999999

                           00000004  0010  3500 LOGLEN = .-LOGTAB/4			; no. of floating point entries

MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   VAX-11 MACRO X0.3-11               Page   4

01-6            MTH$ALOG  - Standard Single Precision Floating                                                                   (4)



                                     0010   100 	.SBTTL	MTH$ALOG  - Standard Single Precision Floating LOG

                                     0010   200 

                                     0010   300 

                                     0010   400 ;++

                                     0010   500 ; FUNCTIONAL DESCRIPTION:

                                     0010   600 ;

                                     0010   700 ; LOG  - single precision floating point function

                                     0010   800 ;

                                     0010   900 ; LOG(X) is computed using the following approximation technique:

                                     0010  1000 ;

                                     0010  1100 ;	If X <= 0, error.

                                     0010  1200 ;

                                     0010  1300 ;	Let X = Y * (2**A), where 1/2 <= Y < 1

                                     0010  1400 ;	then LOG(X) = A * LOG(2) + LOG(Y)

                                     0010  1500 ;

                                     0010  1600 ;	If |X-1| <= 0.25, let W = (X-1) / (X+1)

                                     0010  1700 ;	LOG(X) = W * SUM(Ci * W ** (2*i))

                                     0010  1800 ;

                                     0010  1900 ;	Otherwise, let W = (Y-SQRT(2)/2)/(Y+SQRT(2)/2)

                                     0010  2000 ;	LOG(X) = A * LOG(2) - 1/2 * LOG(2) + W * SUM(Ci * W **(2*i)

                                     0010  2100 ;

                                     0010  2200 ;	The coefficients are drawn from Hart #2662.

                                     0010  2300 ;	The polynomial approximation used is of degree 4.

                                     0010  2400 ;

                                     0010  2500 ;	The relative error is less than or equal to 10**-9.9.

                                     0010  2600 ;

                                     0010  2700 ; CALLING SEQUENCE:

                                     0010  2800 ;

                                     0010  2900 ;	logarithm.wf.v = MTH$ALOG(x.rf.r)

                                     0010  3000 ;

                                     0010  3100 ; INPUT PARAMETERS:

                                     0010  3200 

                           00000004  0010  3300 	LONG = 4			; define longword multiplier

                           00000004  0010  3400 	x = 1 * LONG			; Contents of x is the argument

                                     0010  3500 

                                     0010  3600 ; IMPLICIT INPUTS:	none

                                     0010  3700 ;

                                     0010  3800 ; OUTPUT PARAMETERS:

                                     0010  3900 ;

                                     0010  4000 ;	VALUE:	floating logarithm of the argument

                                     0010  4100 ;

                                     0010  4200 ; IMPLICIT OUTPUTS:	none

                                     0010  4300 ;

                                     0010  4400 ; COMPLETION CODES:	none

                                     0010  4500 ;

                                     0010  4600 ; SIDE EFFECTS:

                                     0010  4700 ;

                                     0010  4800 ; Signals: MTH$_LOGZERNEG if |X| =< 0.0 with reserved operand in R0 (copied to

                                     0010  4900 ; the signal mechanism vector CHF$L_MCH_R0/R1 by LIB$SIGNAL).

                                     0010  5000 ; Associated message is: "LOGARITHM OF ZERO OR NEGATIVE VALUE". Result is reserved

                                     0010  5100 ; operand -0.0 unless a user supplied (or any) error handler changes CHF$L_MCH_R0/R1

                                     0010  5200 ;

                                     0010  5300 ; NOTE: This procedure disables floating point underflow and integer

                                     0010  5400 ; overflow, causes no floating overflow or other arithmetic traps, and

                                     0010  5500 ; preserves enables across the call.

                                     0010  5600 ;

                                     0010  5700 ;---

MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   VAX-11 MACRO X0.3-11               Page   5

01-6            MTH$ALOG  - Standard Single Precision Floating                                                                   (4)



                                     0010  5800 

                                     0010  5900 

                               403C' 0010  6000 	.ENTRY	MTH$ALOG, ACMASK	; standard call-by-reference entry

                                     0012  6100 					; disable DV (and FU), enable IV

                                     0012  6200 	MTH$FLAG_JACKET			; flag that this is a jacket procedure in

                                     0012      

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

                                     0017       					; set handler address to jacket

                                     0017       					; handler

                                     0017       

                                     0017  6300 					; case of an error in special JSB routine

            50         04 BC     50  0017  6400 	MOVF	@x(AP), R0		; R0 = arg 

                          1E     10  001B  6500 	BSBB	MTH$ALOG_R5 		; call special LOG rountine

                                 04  001D  6600 	RET				; return - result in R0

                                     001E  6700 

MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   VAX-11 MACRO X0.3-11               Page   6

01-6            MTH$ALOG10  - Standard Single Precision Floatin                                                                  (5)



                                     001E   100 	.SBTTL	MTH$ALOG10  - Standard Single Precision Floating Common Logarithm

                                     001E   200 

                                     001E   300 ;++

                                     001E   400 ; FUNCTIONAL DESCRIPTION:

                                     001E   500 ;

                                     001E   600 ; LOG10  - single precision floating point function

                                     001E   700 ;

                                     001E   800 ; LOG10(X) is computed as LOG10(E) * LOG(X).

                                     001E   900 ;

                                     001E  1000 ; See description of MTH$ALOG 

                                     001E  1100 ;

                                     001E  1200 ; CALLING SEQUENCE:

                                     001E  1300 ;

                                     001E  1400 ;	logarithm_base_10.wf.v = MTH$ALOG10(x.rf.r)

                                     001E  1500 ;

                                     001E  1600 ; INPUT PARAMETERS:

                                     001E  1700 

                           00000004  001E  1800 	LONG = 4			; define longword multiplier

                           00000004  001E  1900 	x = 1 * LONG			; Contents of x is the argument 

                                     001E  2000 

                                     001E  2100 ;

                                     001E  2200 ; SIDE EFFECTS:	See description of MTH$ALOG

                                     001E  2300 ;

                                     001E  2400 ;--

                                     001E  2500 

                                     001E  2600 

                               403C' 001E  2700 	.ENTRY	MTH$ALOG10, ACMASK	; standard call-by-reference entry

                                     0020  2800 					; disable DV (and FU), enable IV

                                     0020  2900 	MTH$FLAG_JACKET			; flag that this is a jacket procedure in

                                     0020      

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

                                     0025       					; set handler address to jacket

                                     0025       					; handler

                                     0025       

                                     0025  3000 					; case of an error in special JSB routine

            50         04 BC     50  0025  3100 	MOVF	@x(AP), R0		; R0 = arg 

                          01     10  0029  3200 	BSBB	MTH$ALOG10_R5 		; call special LOG10 routine

                                 04  002B  3300 	RET				; return - result in R0

                                     002C  3400 

MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   VAX-11 MACRO X0.3-11               Page   7

01-6            MTH$ALOGLOG10_R5  - Special LOG/LOG10 routines                                                                   (6)



                                     002C   100 	.SBTTL	MTH$ALOGLOG10_R5  - Special LOG/LOG10 routines

                                     002C   200 

                                     002C   300 ; Special LOG/LOG10 - used by the standard, and directly.

                                     002C   400 ;

                                     002C   500 ; CALLING SEQUENCE:

                                     002C   600 ;	save anything needed in R0:R5

                                     002C   700 ;	MOVF	..., R0			; input in R0

                                     002C   800 ;	JSB	MTH$ALOG10_R5 /MTH$ALOG_R5 

                                     002C   900 ;	return with result in R0

                                     002C  1000 ; Note: This routine is written to avoid causing any integer overflows, floating

                                     002C  1100 ; overflows, or floating underflows or divide by 0 conditions, whether enabled or

                                     002C  1200 ; not.

                                     002C  1300 ;

                                     002C  1400 ; REGISTERS USED:

                                     002C  1500 ;	R0 - Floating argument then result

                                     002C  1600 ;	R1 - scratch

                                     002C  1700 ;	R0:R3 - POLYF

                                     002C  1800 ;	R4 - W during POLYF

                                     002C  1900 ;	R5 - exponent * LN(2)

                                     002C  2000 ;-

                                     002C  2100 

                                     002C  2400 

                                     002C  2500 MTH$ALOG10_R5::				; special LOG10 routine

            52            50     50  002C  2600 	MOVF	R0,R2			; test sign of X and save in R2

                          74     15  002F  2700 	BLEQ	ERROR			; branch if X not positive

                                     0031  2800 					; user PC on top of stack

                                     0031  2900 					; Note: ERROR routine depends on user

                                     0031  3000 					; PC being on top of stack, so direct

                                     0031  3100 					; subroutine call to MTH$ALOG_R5 is not

                                     0031  3200 					; used.

                          0D     10  0031  3300 1$:	BSBB	ALOG_COMMON_R5 		; call common LOG/LOG10 routine

            50   5BD93FDE 8F     44  0033  3400 	MULF	#LF_LOG10_E, R0		; R0 = LOG10(e) * LOG(X)

                                 05  003A  3500 	RSB				; return

                                     003B  3600 

                                     003B  3700 MTH$ALOG_R5::				; Special routine for LOG

            52            50     50  003B  3800 	MOVF	R0, R2			; test sign of X and save in R2

                          65     15  003E  3900 	BLEQ	ERROR			; jump if X is not positive

                                     0040  4000 					; user PC on top of stack

                                     0040  4100 ALOG_COMMON_R5:				; common part of ALOG/ALOG10 routne

            50            08     43  0040  4200 	SUBF3	S^#SF_1, R0, R4		; R4 = X-1.0

                          54         0043       

            54       8000 8F     AB  0044  4300 	BICW3	#^X8000, R4, R1		; R1 = |X-1|

                          51         0049       

       3F80 8F            51     B1  004A  4400 	CMPW	R1, #LF_1_OVER_4	; compare |X-1| with 0.25

                          13     18  004F  4500 	BGEQ	GEQ_THAN_0.25		; branch if |X-1| >= 0.25

                                     0051  4600 ;

                                     0051  4700 ; |X - 1| =< 0.25

                                     0051  4800 ;

            50            08     40  0051  4900 	ADDF	S^#SF_1, R0		; R0 = X + 1

            54            50     46  0054  5000 	DIVF	R0, R4			; R4 = W = (X-1)/(X+1)

            54            54     45  0057  5100 	MULF3	R4, R4, R0		; R0 = Y = W**2

                          50         005A       

            03            50     55  005B  5200 	POLYF	R0, #LOGLEN-1, LOGTAB	; R0 = SUM(Ci*W**(i*2))

                       A0 AF         005E       

            50            54     44  0060  5300 	MULF	R4, R0			; R0 = W * SUM(Ci*W**(i*2))

                                 05  0063  5400 	RSB				; return

                                     0064  5500 ;

MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   VAX-11 MACRO X0.3-11               Page   8

01-6            MTH$ALOGLOG10_R5  - Special LOG/LOG10 routines                                                                   (6)



                                     0064  5600 ; |X - 1| > 0.25

                                     0064  5700 ;

                                     0064  5800 GEQ_THAN_0.25:

            50       7F80 8F     AA  0064  5900 	BICW	#^X7F80, R0		; clear R0 exp

            50       4000 8F     A8  0069  6000 	BISW	#^X4000, R0		; make R0 [1/2, 1]

            52            50     A2  006E  6100 	SUBW	R0, R2			; remove bias and mantissa from r2<15:0>,

            55            52     4D  0071  6200 	CVTWF	R2,R5			; leaving signed exponent in <14:7>

            55   72183CB1 8F     44  0074  6300 	MULF	#LF_LOG_2_OV_128, R5	; compensate for shifted exp and

                                     007B  6400 					; mult by ln 2

            50   04F34035 8F     43  007B  6500 	SUBF3	#LF_SQRT_2_OV_2, R0, R4

                          54         0082       

                                     0083  6600 					; R4 = Z - SQRT(2)/2

            50   04F34035 8F     40  0083  6700 	ADDF	#LF_SQRT_2_OV_2, R0	; R0 = Z + SQRT(2)/2

            54            50     46  008A  6800 	DIVF	R0, R4			; R4 = W = (Z - SQRT(2)/2)

                                     008D  6900 					;         /(Z + SQRT(2)/2)

            54            54     45  008D  7000 	MULF3	R4, R4, R0		; R0 = Y = W ** 2

                          50         0090       

            03            50     55  0091  7100 	POLYF	R0, #LOGLEN-1, LOGTAB	; R0 = SUM(Ci*W**(i*2)) i = 0:3

                     FF69 CF         0094       

            50            54     44  0097  7200 	MULF	R4, R0			; R0 = W * SUM(Ci*W**(i*2)) i=0:3

            50   7218BFB1 8F     40  009A  7300 	ADDF	#LF_MI_LG_2_OV_2, R0

                                     00A1  7400 					; R0 = W * SUM(Ci*W**(i*2)) -

                                     00A1  7500 					;      (1/2)*LN(2)

            50            55     40  00A1  7600 	ADDF	R5, R0			; R0 = W * SUM(Ci*W**(i*2)) -

                                     00A4  7700 					; (1/2)LN(2) + exponent_for_X * LN(2)

                                 05  00A4  7800 	RSB				; return

                                     00A5  7900 

                                     00A5  8000 ;

                                     00A5  8100 ; X =< 0.0, signal error

                                     00A5  8200 ;

                          6E     DD  00A5  8300 ERROR:	PUSHL	(SP)			; return PC from JSB routine

            7E         53 8F     9A  00A7  8400 	MOVZBL	#MTH__LOGZERNEG, -(SP)	; condition value

            01            0F     78  00AB  8500 	ASHL	#15, #1, R0		; R0 = result = reserved operand -0.0

                          50         00AE       

                                     00AF  8600 					; goes to signal mechanism vector

                                     00AF  8700 					; (CHF$L_MCH_R0/R1) so error handler

                                     00AF  8800 					; can modify the result.

       0000'CF            02     FB  00AF  8900 	CALLS	#2, W^MTH$$SIGNAL	; signal error and use real user's PC

                                     00B4  9000 					; independent of CALL vs JSB

                                 05  00B4  9100 	RSB				; return - R0 restored from CHF$L_MCH_R0/R1

                                     00B5  9200 

                                     00B5  9300 

                                     00B5  9400 	.END

MTH$ALOG        ; Floating Point Natural and Common              21-AUG-1978 19:01:33   VAX-11 MACRO X0.3-11               Page   9

SYMBOL TABLE                                                                                                                     (6)



ACMASK         = 0000403C            

ALOG_COMMON_R5   00000040 R     02   

ERROR            000000A5 R     02   

FOR$K_ERR_PREFX= 00000018            

GEQ_THAN_0.25    00000064 R     02   

LF_1_OVER_4    = 00003F80            

LF_LOG10_E     = 5BD93FDE            

LF_LOG_2_OV_128= 72183CB1            

LF_MI_LG_2_OV_2= 7218BFB1            

LF_SQRT_2_OV_2 = 04F34035            

LOGLEN         = 00000004            

LOGTAB           00000000 R     02   

LONG           = 00000004            

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

MTH$$SIGNAL      ********   X   02   

MTH$ALOG         00000010 RG    02   

MTH$ALOG10       0000001E RG    02   

MTH$ALOG10_R5    0000002C RG    02   

MTH$ALOG_R5      0000003B RG    02   

MTH$K_ERR_PREFX= 00000016            

MTH__FLOOVEMAT = 00000058            

MTH__FLOUNDMAT = 00000059            

MTH__INVARG    = 00000051            

MTH__LOGZERNEG = 00000053            

MTH__SINSIGLOS = 00000057            

MTH__SQUROONEG = 00000054            

MTH__UNDEXP    = 00000052            

MTH__WRONUMARG = 00000050            

SF_1           = 00004080            

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         000000B5      02       PIC   USR   CON   REL   LCL   SHR   EXE   RD  NOWRT LONG  





THERE WERE NO ERRORS OR WARNINGS.

27666. BYTES LEFT IN FREE MEMORY POOL.

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

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

