OTS$POWRJ       - REAL ** INTEGER*4 power routine                21-AUG-1978 19:10:18   VAX-11 MACRO X0.3-11               Page   0

TABLE OF CONTENTS   



   (2)      92  HISTORY		; Detailed Current Edit History

   (3)     103  DECLARATIONS

   (4)     137  OTS$POWRJ - floating to power longword giving f

OTS$POWRJ       - REAL ** INTEGER*4 power routine                21-AUG-1978 19:10:18   VAX-11 MACRO X0.3-11               Page   1

0-10                                                                                                                             (1)



                                     0000     1 	.TITLE	OTS$POWRJ - REAL ** INTEGER*4 power routine

                                     0000     2 	.IDENT	/0-10/		; File OTSPOWRJ.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 ;	Floating base to integer longword power.

                                     0000    29 ;	Floating overflow can occur.

                                     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$POWRJ       - REAL ** INTEGER*4 power routine                21-AUG-1978 19:10:18   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$POWRJ

                                     0000    50 ; version 05 - changed module name to forpowRJ

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

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

                                     0000    53 ;		removed infinite loop with largest negative integer exponent.

                                     0000    54 

                                     0000    55 ; version 09 - changed MTH$$ERROR to MTH$$SIGNAL - JMT

OTS$POWRJ       - REAL ** INTEGER*4 power routine                21-AUG-1978 19:10:18   VAX-11 MACRO X0.3-11               Page   3

0-10            DECLARATIONS                                                                                                     (3)



                                     0000    57 	.SBTTL	DECLARATIONS

                                     0000    58 

                                     0000    59 ;

                                     0000    60 ; INCLUDE FILES:

                                     0000    61 ;

                                     0000    62 

                                     0000    63 ;	oerr.mar			; OTS error codes

                                     0000    64 ;

                                     0000    65 ; EXTERNAL SYMBOLS:

                                     0000    66 ;

                                     0000    67 

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

                                     0000    69 ;

                                     0000    70 ; MACROS:

                                     0000    71 ;

                                     0000    72 

                                     0000    73 ;

                                     0000    74 ; EQUATED SYMBOLS:

                                     0000    75 ;

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

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

                                     0000    78 

                                     0000    79 ;

                                     0000    80 ; OWN STORAGE:

                                     0000    81 ;

                                     0000    82 

                                     0000    83 ;

                                     0000    84 ; PSECT DECLARATIONS:

                                     0000    85 ;

                                     0000    86 

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

                                     0000    88 					; program section for OTS$ code

                                     0000    89 

OTS$POWRJ       - REAL ** INTEGER*4 power routine                21-AUG-1978 19:10:18   VAX-11 MACRO X0.3-11               Page   4

0-10            OTS$POWRJ - floating to power longword giving f                                                                  (4)



                                     0000    91 	.SBTTL	OTS$POWRJ - floating to power longword giving floating result

                                     0000    92 

                                     0000    93 ;++

                                     0000    94 ; FUNCTIONAL DESCRIPTION:

                                     0000    95 ;

                                     0000    96 ;	Floating result = floating base ** signed longword exponent

                                     0000    97 ;	The floating result is given by:

                                     0000    98 ;

                                     0000    99 ;	base	exponent	result

                                     0000   100 ;

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

                                     0000   102 ;				non-zero bit position in exponent

                                     0000   103 ;

                                     0000   104 ;	> 0	= 0		1.0

                                     0000   105 ;	= 0	= 0		Undefined exponentation

                                     0000   106 ;	< 0	= 0		1.0

                                     0000   107 ;

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

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

                                     0000   110 ;				in |exponent|

                                     0000   111 ;	= 0	< 0		Undefined exponentation

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

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

                                     0000   114 ;				in |exponent|

                                     0000   115 ;

                                     0000   116 ;	Floating overflow can occur.

                                     0000   117 ;	Undefined exponentiation occurs if base is 0 and 

                                     0000   118 ;	exponent is 0 or negative.

                                     0000   119 ;

                                     0000   120 ; CALLING SEQUENCE:

                                     0000   121 ;

                                     0000   122 ;	Power.wf.v = OTS$POWRJ (base.rf.v,  exponent.rl.v)

                                     0000   123 ;

                                     0000   124 ; INPUT PARAMETERS:

                                     0000   125 ;	NONE

                                     0000   126 ;

                                     0000   127 ; IMPLICIT INPUTS:

                                     0000   128 ;	NONE

                                     0000   129 ;

                                     0000   130 ; OUTPUT PARAMETERS:

                                     0000   131 ;	NONE

                                     0000   132 ;

                                     0000   133 ; IMPLICIT OUTPUTS:

                                     0000   134 ;	NONE

                                     0000   135 ;

                                     0000   136 ; FUNCTION VALUE:

                                     0000   137 ;

                                     0000   138 ;	Floating base ** exponent

                                     0000   139 ;

                                     0000   140 ; SIDE EFFECTS:

                                     0000   141 ;

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

                                     0000   143 ;	floating overflow.

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

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

                                     0000   146 ;

                                     0000   147 ;--

OTS$POWRJ       - REAL ** INTEGER*4 power routine                21-AUG-1978 19:10:18   VAX-11 MACRO X0.3-11               Page   5

0-10            OTS$POWRJ - floating to power longword giving f                                                                  (4)



                                     0000   148 

                                     0000   149 

                                     0000   150 

                               0004' 0000   151 	.ENTRY OTS$POWRJ, ^M<R2>	; disable integer overflow

                                     0002   152 					; occurs on largest negative integer exp

            50            08     50  0002   153 	MOVF	#1, R0			; R0 = initial result

            51         04 AC     50  0005   154 	MOVF	base(AP), R1		; R1 = base

            52         08 AC     D0  0009   155 	MOVL	exp(AP), R2		; R2 = exponent

                                     000D   156 					; Note: integer overflow can occur

                                     000D   157 					; on largest neagtive integer exponent.

                                     000D   158 					; However, R2 is correct unsigned 32-bit value.

                                     000D   159 					; Use ROTL -1 rather than ASHL -1 below.

                          09     14  000D   160 	BGTR	EXPGTR			; branch if exponent > 0

                                     000F   161 

                          51     53  000F   162 	TSTF	R1			; test base

                          28     13  0011   163 	BEQL	UNDEFINED		; undefined 0**0 or 0**(-n)

            52            52     CE  0013   164 	MNEGL	R2, R2			; R2 = |exponent|

                          22     13  0016   165 	BEQL	POWRJX			; if exponent is 0, return R0 = 1.0

                                     0018   166 

                                     0018   167 ;+

                                     0018   168 ; Exponent is > 0 or (exponent is =< 0 and base is not = 0 -- use |exponent|)

                                     0018   169 ;-

                                     0018   170 

            52            00     E4  0018   171 EXPGTR:	BBSC	#0, R2, PARTIAL		; branch if |exponent| is odd

                          0B         001B       

                                     001C   172 					; and clear low order bit

            52         FF 8F     9C  001C   173 SQUAR:	ROTL	#-1, R2, R2		; R2 = |32-bit unsigned exponent|/2

                          52         0020       

            51            51     44  0021   174 SQUAR1:	MULF	R1, R1			; R1 = current power of base

                                     0024   175 					; floating overflow will trap and

                                     0024   176 					; SIGNAL SS$_ARITH

            F5            52     E9  0024   177 	BLBC	R2, SQUAR		; branch if next bit in |exponent| is 0

                                     0027   178 

                                     0027   179 ;+

                                     0027   180 ; Here when bit i of |exponent| is a 1.

                                     0027   181 ; Partial result = partial result *  (base * 2**i)

                                     0027   182 ;-

                                     0027   183 

                                     0027   184 PARTIAL:

            50            51     44  0027   185 	MULF	R1, R0			; R0 = new partial result

            52         FF 8F     78  002A   186 	ASHL	#-1, R2, R2		; R2 = |exponent|/2

                          52         002E       

                          F0     12  002F   187 	BNEQ	SQUAR1			; loopback if more exponent bits are 1

                                     0031   188 

                       08 AC     D5  0031   189 	TSTL	exp(AP)			; test sign of exponent

                          04     14  0034   190 	BGTR	POWRJX			; if exponent > 0, return R0

            08            50     47  0036   191 	DIVF3	R0, #1, R0		; R0 = 1.0/result

                          50         0039       

                                 04  003A   192 POWRJX:	RET				; return, result in R0

                                     003B   193 

                                     003B   194 ;+

                                     003B   195 ; Undefined exponentation error - 0**0 or 0**(-n)

                                     003B   196 ;-

                                     003B   197 

                                     003B   198 UNDEFINED:

            01            0F     78  003B   199 	ASHL	#15, #1, R0		; R0 = reserved floating operand

                          50         003E       

OTS$POWRJ       - REAL ** INTEGER*4 power routine                21-AUG-1978 19:10:18   VAX-11 MACRO X0.3-11               Page   6

0-10            OTS$POWRJ - floating to power longword giving f                                                                  (4)



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

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

                                     004A   202 					; and SIGNAL MTH$_UNDEXP

                                     004A   203 					; Note: 2nd arg not needed since

                                     004A   204 					; no JSB OTS$POWRJ

                                 04  004A   205 	RET				; return

                                     004B   206 

                                     004B   207 	.END

OTS$POWRJ       - REAL ** INTEGER*4 power routine                21-AUG-1978 19:10:18   VAX-11 MACRO X0.3-11               Page   7

SYMBOL TABLE                                                                                                                     (4)



BASE           = 00000004            

EXP            = 00000008            

EXPGTR           00000018 R     02   

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$POWRJ        00000000 RG    02   

PARTIAL          00000027 R     02   

POWRJX           0000003A R     02   

SQUAR            0000001C R     02   

SQUAR1           00000021 R     02   

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





THERE WERE NO ERRORS OR WARNINGS.

27908. BYTES LEFT IN FREE MEMORY POOL.

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

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

