OTS$POWDJ       - DOUBLE PRECISION ** INTEGER*4 power routine    21-AUG-1978 19:09:57   VAX-11 MACRO X0.3-11               Page   0

TABLE OF CONTENTS   



   (2)     100  HISTORY		; Detailed Current Edit History

   (3)     100  DECLARATIONS

   (4)     100  OTS$POWDJ - double to power longword giving dou

OTS$POWDJ       - DOUBLE PRECISION ** INTEGER*4 power routine    21-AUG-1978 19:09:57   VAX-11 MACRO X0.3-11               Page   1

0-14                                                                                                                             (1)



                                     0000   100 	.TITLE	OTS$POWDJ - DOUBLE PRECISION ** INTEGER*4 power routine

                                     0000   200 	.IDENT	/0-14/		; File OTSPOWDJ.MAR

                                     0000   300 

                                     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: Language support library - user callable

                                     0000  2500 ;++

                                     0000  2600 ; ABSTRACT:

                                     0000  2700 ;

                                     0000  2800 ;	Double base to integer longword power.

                                     0000  2900 ;	Floating overflow can occur.

                                     0000  3000 ;	Undefined exponentation can occur if base is 0 and power is 0 or negative.

                                     0000  3100 ;

                                     0000  3200 ;

                                     0000  3300 ;--

                                     0000  3400 ;

                                     0000  3500 ; VERSION: 01

                                     0000  3600 ;

                                     0000  3700 ; HISTORY:

                                     0000  3800 ; AUTHOR:

                                     0000  3900 ;	Thomas N. Hastings, 5-May-77: Version 01

                                     0000  4000 ;

                                     0000  4100 ; MODIFIED BY: SUSAN HUBBARD AZIBERT

                                     0000  4200 ;

                                     0000  4300 ;

                                     0000  4500 ;

OTS$POWDJ       - DOUBLE PRECISION ** INTEGER*4 power routine    21-AUG-1978 19:09:57   VAX-11 MACRO X0.3-11               Page   2

0-14            HISTORY  ; Detailed Current Edit History                                                                         (2)



                                     0000   100 	.SBTTL	HISTORY		; Detailed Current Edit History

                                     0000   200 

                                     0000   300 

                                     0000   400 ; Edit History for Version 01 of OTS$POWDJ

                                     0000   500 ; version 5 - changed module name to FORPOWDJ

                                     0000   600 ; version 6 - added error handler and changed formal ref from 8(AP) to 12(AP)

                                     0000   700 ; version 8 - changed error handler name from MTH$ERROR to MTH$$ERROR

                                     0000   800 ; version 9 - removed W^ from MTH$$ERROR, saved code with MOVZBL.

                                     0000   900 ; version 10 - changed references to MTH$$ERROR to MTH$$SIGNAL - JMT

                                     0000  1000 ; 0-14	- Change FOR$FLAG_JACKET to MTH$FLAG_JACKET.  TNH 17-July-78

OTS$POWDJ       - DOUBLE PRECISION ** INTEGER*4 power routine    21-AUG-1978 19:09:57   VAX-11 MACRO X0.3-11               Page   3

0-14            DECLARATIONS                                                                                                     (3)



                                     0000   100 	.SBTTL	DECLARATIONS

                                     0000   200 

                                     0000   300 ;

                                     0000   400 ; INCLUDE FILES:

                                     0000   500 ;

                                     0000   600 

                                     0000   700 ;	oerr.mar			; OTS error codes

                                     0000   800 ;

                                     0000   900 ; EXTERNAL SYMBOLS:

                                     0000  1000 ;

                                     0000  1100 

                                     0000  1200 	.GLOBL MTH$$SIGNAL		; Math error routine

                                     0000  1300 ;

                                     0000  1400 ; MACROS:

                                     0000  1500 ;

                                     0000  1600 

                                     0000  1700 ;

                                     0000  1800 ; EQUATED SYMBOLS:

                                     0000  1900 ;

                           00000004  0000  2000 	base = 4			; base input formal - by-value

                           0000000C  0000  2100 	exp = 12			; exponent intpu formal - by-value

                                     0000  2200 					; Note: double floating by-value violates

                                     0000  2300 					; calling standard, but ok since this

                                     0000  2400 					; routine is a code support routine (OTS$)

                                     0000  2500 

                                     0000  2600 ;

                                     0000  2700 ; OWN STORAGE:

                                     0000  2800 ;

                                     0000  2900 

                                     0000  3000 ;

                                     0000  3100 ; PSECT DECLARATIONS:

                                     0000  3200 ;

                                     0000  3300 

                                 00000000  3400 	.PSECT	OTS$CODE PIC,SHR,LONG,EXE,NOWRT

                                     0000  3500 					; program section for OTS$ code

                                     0000  3600 

OTS$POWDJ       - DOUBLE PRECISION ** INTEGER*4 power routine    21-AUG-1978 19:09:57   VAX-11 MACRO X0.3-11               Page   4

0-14            OTS$POWDJ - double to power longword giving dou                                                                  (4)



                                     0000   100 	.SBTTL	OTS$POWDJ - double to power longword giving double result

                                     0000   200 

                                     0000   300 ;++

                                     0000   400 ; FUNCTIONAL DESCRIPTION:

                                     0000   500 ;

                                     0000   600 ;	Double result = double base ** signed longword exponent

                                     0000   700 ;	The double result is given by:

                                     0000   800 ;

                                     0000   900 ;	base	exponent	result

                                     0000  1000 ;

                                     0000  1100 ;	any	> 0		product (base * 2**i) where i is each

                                     0000  1200 ;				non-zero bit position in exponent

                                     0000  1300 ;

                                     0000  1400 ;	> 0	= 0		1.0

                                     0000  1500 ;	= 0	= 0		Undefined exponentation

                                     0000  1600 ;	< 0	= 0		1.0

                                     0000  1700 ;

                                     0000  1800 ;	> 0	< 0		1.0 / product (base * 2**i)

                                     0000  1900 ;				where i is each non-zero bit position

                                     0000  2000 ;				in |exponent|

                                     0000  2100 ;	= 0	< 0		Undefined exponentation

                                     0000  2200 ;	< 0	< 0		1.0 / product (base * 2**i)

                                     0000  2300 ;				where i is each non-zero bit position

                                     0000  2400 ;				in |exponent|

                                     0000  2500 ;

                                     0000  2600 ;	Floating overflow can occur.

                                     0000  2700 ;	Undefined exponentiation occurs if base is 0 and 

                                     0000  2800 ;	exponent is 0 or negative.

                                     0000  2900 ;

                                     0000  3000 ; CALLING SEQUENCE:

                                     0000  3100 ;

                                     0000  3200 ;	Power.wd.v = OTS$POWDJ (base.rd.v, exponent.rl.v)

                                     0000  3300 ;

                                     0000  3400 ; INPUT PARAMETERS:

                                     0000  3500 ;	NONE

                                     0000  3600 ;

                                     0000  3700 ; IMPLICIT INPUTS:

                                     0000  3800 ;	NONE

                                     0000  3900 ;

                                     0000  4000 ; OUTPUT PARAMETERS:

                                     0000  4100 ;	NONE

                                     0000  4200 ;

                                     0000  4300 ; IMPLICIT OUTPUTS:

                                     0000  4400 ;	NONE

                                     0000  4500 ;

                                     0000  4600 ; FUNCTION VALUE:

                                     0000  4700 ;

                                     0000  4800 ;	Double base **  signed longword exponent

                                     0000  4900 ;

                                     0000  5000 ; SIDE EFFECTS:

                                     0000  5100 ;

                                     0000  5200 ;	SIGNALs SS$_ARITH with floating overflow hardware code if

                                     0000  5300 ;	floating overflow.

                                     0000  5400 ;	SIGNALs MTH$_UNDEXP (82 = ' UNDEFINED EXPONENTATION') if

                                     0000  5500 ;	base is 0 and exponent is 0 or negative.

                                     0000  5600 ;

                                     0000  5700 ;--

OTS$POWDJ       - DOUBLE PRECISION ** INTEGER*4 power routine    21-AUG-1978 19:09:57   VAX-11 MACRO X0.3-11               Page   5

0-14            OTS$POWDJ - double to power longword giving dou                                                                  (4)



                                     0000  5800 

                                     0000  5900 

                                     0000  6000 

                               401C' 0000  6100 	.ENTRY OTS$POWDJ, ^M<IV, R2, R3,  R4>	; enable integer overflow

                                     0002  6200 	MTH$FLAG_JACKET			; establish math error handler

                                     0002      

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

                                     0007       					; set handler address to jacket

                                     0007       					; handler

                                     0007       

                                     0007  6300 					; in case of an error

            50            08     70  0007  6400 	MOVD	#1, R0			; R0/R1 = initial result

            52         04 AC     70  000A  6500 	MOVD	base(AP), R2		; R2/R3 = base

            54         0C AC     D0  000E  6600 	MOVL	exp(AP), R4		; R4 = exponent

                          09     14  0012  6700 	BGTR	EXPGTR			; branch if exponent > 0

                                     0014  6800 

                          52     73  0014  6900 	TSTD	R2			; test base

                          27     13  0016  7000 	BEQL	UNDEFINED		; undefined 0**0 or 0**(-n)

            54            54     CE  0018  7100 	MNEGL	R4, R4			; R4 = |exponent|

                          21     13  001B  7200 	BEQL	POWDJX			; if exponent is 0, return R0 = 1.0

                                     001D  7300 

                                     001D  7400 ;+

                                     001D  7500 ; Exponent is > 0 or (exponent is =< 0 and base is not = 0 -- use |exponent|)

                                     001D  7600 ;-

                                     001D  7700 

            0B            54     E8  001D  7800 EXPGTR:	BLBS	R4, PARTIAL		; branch if |exponent| is odd

            54         FF 8F     78  0020  7900 SQUAR:	ASHL	#-1, R4, R4		; R4 = |exponent|/2

                          54         0024       

            52            52     64  0025  8000 SQUAR1:	MULD	R2, R2			; R2/R3 = current power of base

                                     0028  8100 					; floating overflow will trap and

                                     0028  8200 					; SIGNAL SS$_ARITH

            F5            54     E9  0028  8300 	BLBC	R4, SQUAR		; branch if next bit in |exponent| is 0

                                     002B  8400 

                                     002B  8500 ;+

                                     002B  8600 ; Here when bit i of |exponent| is a 1.

                                     002B  8700 ; Partial result = partial result *  (base * 2**i)

                                     002B  8800 ;-

                                     002B  8900 

                                     002B  9000 PARTIAL:

            50            52     64  002B  9100 	MULD	R2, R0			; R0/R1 = new partial result

            54         FF 8F     78  002E  9200 	ASHL	#-1, R4, R4		; R4 = |exponent|/2

                          54         0032       

                          F0     12  0033  9300 	BNEQ	SQUAR1			; loopback if more exponent bits are 1

                                     0035  9400 

                       0C AC     D5  0035  9500 	TSTL	exp(AP)			; test sign of exponent

                          04     14  0038  9600 	BGTR	POWDJX			; if exponent > 0, return R0

            08            50     67  003A  9700 	DIVD3	R0, #1, R0		; R0/R1 = 1.0/result

                          50         003D       

                                 04  003E  9800 POWDJX:	RET				; return, result in R0

                                     003F  9900 

                                     003F 10000 ;+

                                     003F 10100 ; Undefined exponentation error - 0**0 or 0**(-n)

                                     003F 10200 ;-

                                     003F 10300 

                                     003F 10400 UNDEFINED:

            01            0F     79  003F 10500 	ASHQ	#15, #1, R0		; R0/R1 = reserved floating operand

                          50         0042       

OTS$POWDJ       - DOUBLE PRECISION ** INTEGER*4 power routine    21-AUG-1978 19:09:57   VAX-11 MACRO X0.3-11               Page   6

0-14            OTS$POWDJ - double to power longword giving dou                                                                  (4)



            7E         52 8F     9A  0043 10600 	MOVZBL	#MTH__UNDEXP, -(SP)	; FORTRAN error #

   00000000'EF            01     FB  0047 10700 	CALLS	#1, MTH$$SIGNAL		; convert to 32-bit condition code

                                     004E 10800 					; and SIGNAL MTH$_UNDEXP

                                     004E 10900 					; Note: 2nd arg not needed since no JSB OTS$POWDJ

                                     004E 11000 					; is possible.

                                 04  004E 11100 	RET				; return

                                     004F 11200 

                                     004F 11300 	.END

OTS$POWDJ       - DOUBLE PRECISION ** INTEGER*4 power routine    21-AUG-1978 19:09:57   VAX-11 MACRO X0.3-11               Page   7

SYMBOL TABLE                                                                                                                     (4)



BASE           = 00000004            

EXP            = 0000000C            

EXPGTR           0000001D R     02   

FOR$K_ERR_PREFX= 00000018            

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

MTH$$SIGNAL      ********  GX   01   

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            

OTS$POWDJ        00000000 RG    02   

PARTIAL          0000002B R     02   

POWDJX           0000003E R     02   

SQUAR            00000020 R     02   

SQUAR1           00000025 R     02   

UNDEFINED        0000003F R     02   





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  

OTS$CODE         0000004F      02       PIC   USR   CON   REL   LCL   SHR   EXE   RD  NOWRT LONG  





THERE WERE NO ERRORS OR WARNINGS.

27882. BYTES LEFT IN FREE MEMORY POOL.

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

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

