OTS$POWII       - INTEGER*2 ** INTEGER*2 power routine           21-AUG-1978 19:10:04   VAX-11 MACRO X0.3-11               Page   0

TABLE OF CONTENTS   



   (2)      92  HISTORY		; Detailed Current Edit History

   (3)     101  DECLARATIONS

   (4)     135  OTS$POWII - Word to power word giving word resu

OTS$POWII       - INTEGER*2 ** INTEGER*2 power routine           21-AUG-1978 19:10:04   VAX-11 MACRO X0.3-11               Page   1

0-10                                                                                                                             (1)



                                     0000     1 	.TITLE	OTS$POWII - INTEGER*2 ** INTEGER*2 power routine

                                     0000     2 	.IDENT	/0-10/		; File OTSPOWII.MAR

                                     0000     3 

                                     0000     4 ;

                                     0000     5 ; Copyright (C) 1977

                                     0000     6 ; Digital Equipment Corporation, Maynard, Massachusetts 01754

                                     0000     7 ;

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

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

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

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

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

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

                                     0000    14 ; remain in DEC.

                                     0000    15 ;

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

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

                                     0000    18 ; Corporation.

                                     0000    19 ;

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

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

                                     0000    22 ;

                                     0000    23 ;

                                     0000    24 ; FACILITY: Language support library - user callable

                                     0000    25 ;++

                                     0000    26 ; ABSTRACT:

                                     0000    27 ;

                                     0000    28 ;	Integer word base to integer word power.

                                     0000    29 ;	Integer overflow can occur if the result exceeds a word.

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

                                     0000    31 ;

                                     0000    32 ;

                                     0000    33 ;--

                                     0000    34 ;

                                     0000    35 ; VERSION: 0

                                     0000    36 ;

                                     0000    37 ; HISTORY:

                                     0000    38 ; AUTHOR:

                                     0000    39 ;	Thomas N. Hastings, 5-May-77: Version 0

                                     0000    40 ;

                                     0000    41 ; MODIFIED BY: SUSAN HUBBARD AZIBERT

                                     0000    42 ;

                                     0000    43 ;

                                     0000    44 ;

OTS$POWII       - INTEGER*2 ** INTEGER*2 power routine           21-AUG-1978 19:10:04   VAX-11 MACRO X0.3-11               Page   2

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



                                     0000    46 	.SBTTL	HISTORY		; Detailed Current Edit History

                                     0000    47 

                                     0000    48 

                                     0000    49 ; Edit History for Version 0 of OTS$POWII

                                     0000    50 ; version 04 - changed module name to forpowII

                                     0000    51 ; version 05 - changed error handler from MTH$ERROR to MTH$$ERROR

                                     0000    52 ; version 07 - changed error handler to MTH$$SIGNAL

                                     0000    53 ; 0-10	- fixed bug in case instruction.  JMT 28-Feb-78

OTS$POWII       - INTEGER*2 ** INTEGER*2 power routine           21-AUG-1978 19:10:04   VAX-11 MACRO X0.3-11               Page   3

0-10            DECLARATIONS                                                                                                     (3)



                                     0000    55 	.SBTTL	DECLARATIONS

                                     0000    56 

                                     0000    57 ;

                                     0000    58 ; INCLUDE FILES:

                                     0000    59 ;

                                     0000    60 

                                     0000    61 ;	oerr.mar			; OTS error codes

                                     0000    62 ;

                                     0000    63 ; EXTERNAL SYMBOLS:

                                     0000    64 ;

                                     0000    65 

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

                                     0000    67 ;

                                     0000    68 ; MACROS:

                                     0000    69 ;

                                     0000    70 

                                     0000    71 ;

                                     0000    72 ; EQUATED SYMBOLS:

                                     0000    73 ;

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

                           00000008  0000    75 	exp = 8				; exponent intpu formal - by-value

                                     0000    76 

                                     0000    77 ;

                                     0000    78 ; OWN STORAGE:

                                     0000    79 ;

                                     0000    80 

                                     0000    81 ;

                                     0000    82 ; PSECT DECLARATIONS:

                                     0000    83 ;

                                     0000    84 

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

                                     0000    86 					; program section for OTS$ code

                                     0000    87 

OTS$POWII       - INTEGER*2 ** INTEGER*2 power routine           21-AUG-1978 19:10:04   VAX-11 MACRO X0.3-11               Page   4

0-10            OTS$POWII - Word to power word giving word resu                                                                  (4)



                                     0000    89 	.SBTTL	OTS$POWII - Word to power word giving word result

                                     0000    90 

                                     0000    91 ;++

                                     0000    92 ; FUNCTIONAL DESCRIPTION:

                                     0000    93 ;

                                     0000    94 ;	Signed word result = signed word base ** signed word exponent

                                     0000    95 ;	The signed word result is given by:

                                     0000    96 ;

                                     0000    97 ;	base	exponent	result

                                     0000    98 ;

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

                                     0000   100 ;				non-zero bit position in exponent

                                     0000   101 ;

                                     0000   102 ;	> 0	= 0		1

                                     0000   103 ;	= 0	= 0		Undefined exponentation

                                     0000   104 ;	< 0	= 0		1

                                     0000   105 ;

                                     0000   106 ;	> 1	< 0		0

                                     0000   107 ;	= 1	< 0	 	1

                                     0000   108 ;	= 0	< 0		Undefined exponentation

                                     0000   109 ;	= -1	< 0 and even	1

                                     0000   110 ;	= -1	< 0 and odd	-1

                                     0000   111 ;	< -1	< 0		1

                                     0000   112 ;

                                     0000   113 ;	Integer overflow can occur.

                                     0000   114 ;	Undefined exponentiation occurs if base is 0 and 

                                     0000   115 ;	exponent is 0 or negative.

                                     0000   116 ;

                                     0000   117 ; CALLING SEQUENCE:

                                     0000   118 ;

                                     0000   119 ;	Power.ww.v = OTS$POWII (base.rw.v,  exponent.rw.v)

                                     0000   120 ;

                                     0000   121 ; INPUT PARAMETERS:

                                     0000   122 ;	NONE

                                     0000   123 ;

                                     0000   124 ; IMPLICIT INPUTS:

                                     0000   125 ;	NONE

                                     0000   126 ;

                                     0000   127 ; OUTPUT PARAMETERS:

                                     0000   128 ;	NONE

                                     0000   129 ;

                                     0000   130 ; IMPLICIT OUTPUTS:

                                     0000   131 ;	NONE

                                     0000   132 ;

                                     0000   133 ; FUNCTION VALUE:

                                     0000   134 ;

                                     0000   135 ;	Word integer base ** exponent

                                     0000   136 ;

                                     0000   137 ; SIDE EFFECTS:

                                     0000   138 ;

                                     0000   139 ;	SIGNALs SS$_ARITH with integer overflow hardware code if

                                     0000   140 ;	integer overflow.

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

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

                                     0000   143 ;

                                     0000   144 ;--

                                     0000   145 

OTS$POWII       - INTEGER*2 ** INTEGER*2 power routine           21-AUG-1978 19:10:04   VAX-11 MACRO X0.3-11               Page   5

0-10            OTS$POWII - Word to power word giving word resu                                                                  (4)



                                     0000   146 

                                     0000   147 

                               4004' 0000   148 	.ENTRY OTS$POWII, ^M<IV, R2>	; enable integer overflow

            50            01     D0  0002   149 	MOVL	#1, R0			; R0 = initial result

            52         08 AC     32  0005   150 	CVTWL	exp(AP), R2		; R2 = exponent

                          1D     15  0009   151 	BLEQ	EXPLEQ			; branch if exponent =< 0

                                     000B   152 

                                     000B   153 ;+

                                     000B   154 ; Exponent > 0.

                                     000B   155 ; Scan each exponent bit from right, squaring base each time thru loop.

                                     000B   156 ; For each 1-bit in exponent, multiply current base into partial result.

                                     000B   157 ;-

                                     000B   158 

            51         04 AC     B0  000B   159 	MOVW	base(AP), R1		; R1 = base

            0B            52     E8  000F   160 	BLBS	R2, PARTIAL		; branch if exponent is odd

            52         FF 8F     78  0012   161 SQUAR:	ASHL	#-1, R2, R2		; R2 = exponent/2

                          52         0016       

            51            51     A4  0017   162 SQUAR1:	MULW	R1, R1			; R1 = current power of base

                                     001A   163 					; integer overflow will trap

                                     001A   164 					; and SIGNAL SS$_ARITH

            F5            52     E9  001A   165 	BLBC	R2, SQUAR		; loop if next bit in exponent is 0

                                     001D   166 PARTIAL:				; next bit in exponent is a 1

            50            51     A4  001D   167 	MULW	R1, R0			; R0 = new partial result

                                     0020   168 					; integer overflow will trap

                                     0020   169 					; and SIGNAL SS$_ARITH

            52         FF 8F     78  0020   170 	ASHL	#-1, R2, R2		; R2 = exponent/2

                          52         0024       

                          F0     12  0025   171 	BNEQ	SQUAR1			; loop if more exponent bits are 1

                                 04  0027   172 	RET				; return, R0<15:0> = base ** exp

                                     0028   173 					; R0<31:16> = 0

                                     0028   174 

                                     0028   175 ;+

                                     0028   176 ; Exponent is =< 0.

                                     0028   177 ;-

                                     0028   178 

                          08     19  0028   179 EXPLEQ:	BLSS	EXPLSS			; branch if exponent < 0

                                     002A   180 

                                     002A   181 ;+

                                     002A   182 ; Exponent is = 0.

                                     002A   183 ; Undefined exponentation if base = 0 too, else return 1

                                     002A   184 ;-

                                     002A   185 

            51         04 AC     B0  002A   186 	MOVW	base(AP), R1		; R1 = base

                          19     13  002E   187 	BEQL	UNDEFINED		; undefined if base = 0 too

                          16     11  0030   188 	BRB	POWIIX			; return with result = 1

                                     0032   189 					; since base ** 0 = 1

                                     0032   190 

                                     0032   191 ;+

                                     0032   192 ; exponent =< 0.

                                     0032   193 ; Result is given by the following table:

                                     0032   194 ;

                                     0032   195 ;	Base	Result

                                     0032   196 ;	<-1	0

                                     0032   197 ;	-1	1 or -1 depending on exponent being even or odd

                                     0032   198 ;	0	Undefined exponentation

                                     0032   199 ;	1	1

                                     0032   200 ;	>1	0

OTS$POWII       - INTEGER*2 ** INTEGER*2 power routine           21-AUG-1978 19:10:04   VAX-11 MACRO X0.3-11               Page   6

0-10            OTS$POWII - Word to power word giving word resu                                                                  (4)



                                     0032   201 ;-

                                     0032   202 

                                     0032   203 EXPLSS:

       FFFF 8F         04 AC     AF  0032   204 	CASEW	base(AP), #-1, #2	; Case on value of base

                          02         0038       

                               0009' 0039   205 10$:	.WORD	MINUS1-10$		; [-1]: return R0 = -1 or 1 depending

                                     003B   206 					; on exponent being odd or even

                               0010' 003B   207 	.WORD	UNDEFINED-10$		; [0]: Undefined exponentation

                               000F' 003D   208 	.WORD	POWIIX-10$		; [+1]: return R0 = 1

                          50     D4  003F   209 	CLRL	R0			; [< -1 or > +1]: return R0 = 0

                                 04  0041   210 	RET

                                     0042   211 

                                     0042   212 MINUS1:

            03            52     E9  0042   213 	BLBC	R2, POWIIX		; if exponent is even, return R0 = 1

            50            01     CE  0045   214 	MNEGL	#1, R0			; else return R0 = -1

                                 04  0048   215 POWIIX:	RET				; return

                                     0049   216 

                                     0049   217 ;+

                                     0049   218 ; Undefined exponentation error - 0**0 or 0**(-n)

                                     0049   219 ;-

                                     0049   220 

                                     0049   221 UNDEFINED:

                          50     D4  0049   222 	CLRL	R0			; return result = 0 if error

            7E         52 8F     9A  004B   223 	MOVZBL	#MTH__UNDEXP, -(SP)	; FORTRAN error #

       0000'CF            01     FB  004F   224 	CALLS	#1, W^MTH$$SIGNAL	; convert to 32-bit condition code

                                     0054   225 					; and SIGNAL FOR$_UNDEXP

                                 04  0054   226 	RET

                                     0055   227 

                                     0055   228 	.END

OTS$POWII       - INTEGER*2 ** INTEGER*2 power routine           21-AUG-1978 19:10:04   VAX-11 MACRO X0.3-11               Page   7

SYMBOL TABLE                                                                                                                     (4)



BASE           = 00000004            

EXP            = 00000008            

EXPLEQ           00000028 R     02   

EXPLSS           00000032 R     02   

FOR$K_ERR_PREFX= 00000018            

MINUS1           00000042 R     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$POWII        00000000 RG    02   

PARTIAL          0000001D R     02   

POWIIX           00000048 R     02   

SQUAR            00000012 R     02   

SQUAR1           00000017 R     02   

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





THERE WERE NO ERRORS OR WARNINGS.

27862. BYTES LEFT IN FREE MEMORY POOL.

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

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

