OTS$POWCJ       - COMPLEX ** INTEGER*4 power routine             21-AUG-1978 19:09:43   VAX-11 MACRO X0.3-11               Page   0

TABLE OF CONTENTS   



   (2)     100  HISTORY		; Detailed Current Edit History

   (3)     100  DECLARATIONS

   (4)     100  OTS$POWCJ - COMPLEX to INTEGER*4 power giving C

OTS$POWCJ       - COMPLEX ** INTEGER*4 power routine             21-AUG-1978 19:09:43   VAX-11 MACRO X0.3-11               Page   1

0-06                                                                                                                             (1)



                                     0000   100 	.TITLE	OTS$POWCJ - COMPLEX ** INTEGER*4 power routine

                                     0000   200 	.IDENT	/0-06/		; File OTSPOWCJ.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 ;	COMPLEX base to COMPLEX power.

                                     0000  2900 ;

                                     0000  3000 ;	Floating overflow can occur.

                                     0000  3100 ;	Undefined exponentiation can occur if

                                     0000  3200 ;	base = 0 and exp <= 0.

                                     0000  3300 ;

                                     0000  3400 ;

                                     0000  3500 ;--

                                     0000  3600 ;

                                     0000  3700 ; VERSION: 0

                                     0000  3800 ;

                                     0000  3900 ; HISTORY:

                                     0000  4000 ; AUTHOR:

                                     0000  4100 ;	Jonathan M. Taylor, 29-jun-77: Version 0

                                     0000  4200 ;

                                     0000  4300 ; Edit history for version 0

                                     0000  4400 ;

OTS$POWCJ       - COMPLEX ** INTEGER*4 power routine             21-AUG-1978 19:09:43   VAX-11 MACRO X0.3-11               Page   2

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



                                     0000   100 	.SBTTL	HISTORY		; Detailed Current Edit History

                                     0000   200 

                                     0000   300 

                                     0000   400 ; Edit History for Version 0 of OTS$POWCJ

                                     0000   500 ; 0-2 change MTH$$ERROR to MTH$$SIGNAL JMT 5-OCT-77

                                     0000   600 ; 0-6	- Change FOR$FLAG_JACKET to MTH$FLAG_JACKET.  TNH 17-July-78

OTS$POWCJ       - COMPLEX ** INTEGER*4 power routine             21-AUG-1978 19:09:43   VAX-11 MACRO X0.3-11               Page   3

0-06            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 	.GLOBL	OTS$DIVC		; COMPLEX division routine

                                     0000  1400 ;

                                     0000  1500 ; MACROS:

                                     0000  1600 ;

                                     0000  1700 

                                     0000  1800 ;

                                     0000  1900 ; EQUATED SYMBOLS:

                                     0000  2000 ;

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

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

                                     0000  2300 

                                     0000  2400 ;

                                     0000  2500 ; OWN STORAGE:

                                     0000  2600 ;

                                     0000  2700 

                                     0000  2800 ;

                                     0000  2900 ; PSECT DECLARATIONS:

                                     0000  3000 ;

                                     0000  3100 

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

                                     0000  3300 					; program section for OTS$ code

                                     0000  3400 

OTS$POWCJ       - COMPLEX ** INTEGER*4 power routine             21-AUG-1978 19:09:43   VAX-11 MACRO X0.3-11               Page   4

0-06            OTS$POWCJ - COMPLEX to INTEGER*4 power giving C                                                                  (4)



                                     0000   100 	.SBTTL	OTS$POWCJ - COMPLEX to INTEGER*4 power giving COMPLEX result

                                     0000   200 

                                     0000   300 ;++

                                     0000   400 ; FUNCTIONAL DESCRIPTION:

                                     0000   500 ;

                                     0000   600 ;	COMPLEX result = COMPLEX base ** INTEGER*4 exponent

                                     0000   700 ;	The COMPLEX 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.wfc.v = OTS$POWCJ (base.rfc.v,  exponent.rl.v)

                                     0000  3300 ;

                                     0000  3400 ; INPUT PARAMETERS:

                                     0000  3500 ;	The base input parameter is standard FORTRAN COMPLEX.

                                     0000  3600 ;	The exponent input parameter is a signed longword integer.

                                     0000  3700 ;	Both input parameters are CALL BY VALUE.

                                     0000  3800 ;

                                     0000  3900 ; IMPLICIT INPUTS:

                                     0000  4000 ;	NONE

                                     0000  4100 ;

                                     0000  4200 ; OUTPUT PARAMETERS:

                                     0000  4300 ;	NONE

                                     0000  4400 ;

                                     0000  4500 ; IMPLICIT OUTPUTS:

                                     0000  4600 ;	NONE

                                     0000  4700 ;

                                     0000  4800 ; FUNCTION VALUE:

                                     0000  4900 ;

                                     0000  5000 ;	COMPLEX base ** INTEGER*4 exponent

                                     0000  5100 ;

                                     0000  5200 ; SIDE EFFECTS:

                                     0000  5300 ;

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

                                     0000  5500 ;	floating overflow.

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

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

OTS$POWCJ       - COMPLEX ** INTEGER*4 power routine             21-AUG-1978 19:09:43   VAX-11 MACRO X0.3-11               Page   5

0-06            OTS$POWCJ - COMPLEX to INTEGER*4 power giving C                                                                  (4)



                                     0000  5800 ;

                                     0000  5900 ;--

OTS$POWCJ       - COMPLEX ** INTEGER*4 power routine             21-AUG-1978 19:09:43   VAX-11 MACRO X0.3-11               Page   6

0-06            OTS$POWCJ - COMPLEX to INTEGER*4 power giving C                                                                  (5)



                               007C' 0000   100 	.ENTRY	OTS$POWCJ, ^M<R2,R3,R4,R5,R6>

                                     0002   200 					; disable integer overflow

            52         04 AC     7D  0002   400 	MOVQ	base(AP), R2		; R2/R3 gets COMPLEX base

            54         0C AC     D0  0006   500 	MOVL	exp(AP), R4		; R4 = longword exponent

                          03     18  000A   600 	BGEQ	1$			; R4 = | exponent |

            54            54     CE  000C   700 	MNEGL	R4, R4

            54            00     E5  000F   800 1$:	BBCC	#0, R4, EVEN		; branch if even and clear low bit

                          0C         0012       

            50            52     7D  0013   900 	MOVQ	R2, R0			; R0/R1 = initial result

            54         FF 8F     9C  0016  1000 	ROTL	#-1, R4, R4		; R4 = unsigned_exponent / 2

                          54         001A       

                          58     13  001B  1100 	BEQL	DONE			; done if exponent was 1

                          27     11  001D  1200 	BRB	SQUAR1			; else use rest of exponent

                                     001F  1300 

                                     001F  1400 EVEN:

            50            08     70  001F  1500 	MOVD	#1, R0			; R0/R1 = initial result

            54         FF 8F     9C  0022  1600 	ROTL	#-1, R4, R4		; R4 = unsigned_exponent / 2

                          54         0026       

                          1D     12  0027  1700 	BNEQ	SQUAR1			; branch if exponent not 0

                          52     53  0029  1800 	TSTF	R2			; exponent was 0, text RP(base)

                          48     12  002B  1900 	BNEQ	DONE			; done if non-0, answer is 1.0

                          53     53  002D  2000 	TSTF	R3			; IP(base) better not be zero

                          44     12  002F  2100 	BNEQ	DONE			; it isn't return 1.0

                                     0031  2200 

                                     0031  2300 UNDEFINED:

            01            0F     79  0031  2400 	ASHQ	#15, #1, R0		; return R0 = reserved operand

                          50         0034       

            7E         52 8F     9A  0035  2500 	MOVZBL	#MTH__UNDEXP, -(SP)	; FORTRAN error number

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

                                     0040  2700 					; and SIGNAL MTH$_UNDEXP

                                 04  0040  2800 	RET

                                     0041  2900 

                                     0041  3000 SQUAR:

            54         FF 8F     78  0041  3100 	ASHL	#-1, R4, R4		; R4 = |reduced exponent| / 2

                          54         0045       

                                     0046  3200 ;

                                     0046  3300 ; R2/R3 = square current base

                                     0046  3400 ;

                                     0046  3500 SQUAR1:

            53            52     45  0046  3600 	MULF3	R2, R3, R5		; R5 = tmp = RP(base)*IP(base)

                          55         0049       

            52            52     44  004A  3700 	MULF	R2, R2			; R2 = RP(base)**2

            53            53     44  004D  3800 	MULF	R3, R3			; R3 = IP(base)**2

            52            53     42  0050  3900 	SUBF	R3, R2			; R2 = RP(base)**2 - IP(base)**2

            55            55     41  0053  4000 	ADDF3	R5, R5, R3		; R3 = 2*RP(base)*IP(base)

                          53         0056       

            E7            54     E9  0057  4100 	BLBC	R4, SQUAR		; branch if next exponent bit is 0

                                     005A  4200 ;

                                     005A  4300 ; R0/R1 = partial result * current power of base

                                     005A  4400 ;

            53            50     45  005A  4500 	MULF3	R0, R3, R5		; R5 = tmp = RP(part) * IP(base)

                          55         005D       

            50            52     44  005E  4600 	MULF	R2, R0			; R0 = RP(part) * RP(base)

            53            51     45  0061  4700 	MULF3	R1, R3, R6		; R6 = tmp = IP(part) * IP(base)

                          56         0064       

            50            56     42  0065  4800 	SUBF	R6, R0			; R0=RP(part)*RP(base)-IP(part)*IP(base)

            51            52     44  0068  4900 	MULF	R2, R1			; R1 = IP(part) * RP(base)

OTS$POWCJ       - COMPLEX ** INTEGER*4 power routine             21-AUG-1978 19:09:43   VAX-11 MACRO X0.3-11               Page   7

0-06            OTS$POWCJ - COMPLEX to INTEGER*4 power giving C                                                                  (5)



            51            55     40  006B  5000 	ADDF	R5, R1			; R1=IP(part)*RP(base)+RP(part)*IP(base)

            54         FF 8F     78  006E  5100 	ASHL	#-1, R4, R4		; R4 = |reduced exponent| / 2

                          54         0072       

                          D1     12  0073  5200 	BNEQ	SQUAR1			; loop if more exponent bits left

                                     0075  5300 DONE:

                       0C AC     D5  0075  5400 	TSTL	exp(AP)			; test exponent sign

                          15     18  0078  5500 	BGEQ	POWCJ			; done if positive

                          50     53  007A  5600 	TSTF	R0			; test RP(result)

                          04     12  007C  5700 	BNEQ	RECIP			; if non-0, OK to take reciprical

                          51     53  007E  5800 	TSTF	R1			; RP(result) was 0, test IP(result)

                          AF     13  0080  5900 	BEQL	UNDEFINED		; undefined (0.0+0.0i) ** -n

                                     0082  6000 RECIP:

            7E            50     70  0082  6100 	MOVD	R0, -(SP)		; second arg pair is divisor

            7E            08     70  0085  6200 	MOVD	#1, -(SP)		; first arg pair is dividend

   00000000'EF            02     FB  0088  6300 	CALLS	#2, OTS$DIVC		; R0/R1 = reciprical

                                     008F  6400 POWCJ:

                                 04  008F  6500 	RET				; result in R0/R1

                                     0090  6600 

                                     0090  6700 	.END

OTS$POWCJ       - COMPLEX ** INTEGER*4 power routine             21-AUG-1978 19:09:43   VAX-11 MACRO X0.3-11               Page   8

SYMBOL TABLE                                                                                                                     (5)



BASE           = 00000004            

DONE             00000075 R     02   

EVEN             0000001F R     02   

EXP            = 0000000C            

FOR$K_ERR_PREFX= 00000018            

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$DIVC         ********  GX   01   

OTS$POWCJ        00000000 RG    02   

POWCJ            0000008F R     02   

RECIP            00000082 R     02   

SQUAR            00000041 R     02   

SQUAR1           00000046 R     02   

UNDEFINED        00000031 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         00000090      02       PIC   USR   CON   REL   LCL   SHR   EXE   RD  NOWRT LONG  





THERE WERE NO ERRORS OR WARNINGS.

27866. BYTES LEFT IN FREE MEMORY POOL.

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

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

