Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-02 - 43,50242/poolog.mac
There are no other files named poolog.mac in the archive.
00010	        TITLE   POOLOG - POOMAS LOGARITHM OF 11/27/70.
00020	        SUBTTL  LIFTED FROM FORTRAN
00030	;
00040	;    MODIFIED TO BLISS CALLING SEQUENCES AND STACK.
00050	;    ASSUMES BLISS RUN-TIME REGISTERS TO BE 0,1,2,3.
00060	;
00070		;TITLE	ALOG  V.022
00080		;SUBTTL  18-DECEMBER-1969	/KK
00090
00100	;FROM V.020.
00110	;FLOATING POINT SINGLE PRECISION LOGARITHM FUNCTION
00120	;LOG(ABSF(X)) IS CALCULATED BY THE SUBROUTINE, AND AN
00130	;ARGUMENT OF ZERO IS RETURNED AS MINUS INFINITY.
00140
00150	;ALOG IS THE ENTRY POINT FOR LOGE(X), AND
00160	;ALOG10 IS THE ENTRY POINT FOR LOG10(X).
00170	;FOR LOGE(X), THE ALGORITHM IS:
00180	;	LOGE(X) = (I + LOG2(F))*LOGE(2)
00190	;	WHERE X = (F/2)*2^(I+1), AND LOG2(F) IS GIVEN BY
00200	;	LOG2(F) = C1*Z + C3*Z^3 + C5*Z^5 - 1/2
00210	;	AND Z = (F-SQRT(2))/(F+SQRT(2))
00220	;FOR LOG10(X), THE ALGORITHM IS:
00230	;	LOG10(X) = LOGE(X)*LOG10(E)
00240
00250	;THE CALLING SEQUENCE FOR THE ROUTINE IS AS FOLLOWS:
00260	;       PUSH    0,<ARGUMENT>
00270	;       PUSHJ   0,POOLOG OR PLOG10
00280	;THE ANSWER IS RETURNED IN ACCUMULATOR 3, THE VALUE REGISTER.
00290
00300		A=	15
00310		B=	16
00320	        SREG=0
00330	        FREG=2
00340	        VREG=3
00350
00360		ENTRY   POOLOG,PLOG10
00370	        EXTERN  BLIPPE;     BLIPPERROR ROUTINE.
00380
00390	        PAGE
00400	PLOG10: PUSH    SREG,FREG;     ENTRY TO THE BASE 10 ROUTINE.
00410	        HRRZ    FREG,SREG;     SET UP NEW FREG.
00420		PUSH    SREG,-2(FREG);    TRANSMIT ARGUMENT.
00430	        PUSHJ   SREG,POOLOG;       CALC. NATURAL LOG AND
00440	        SUB     SREG,[1000001];
00450		FMPR	VREG,LOG10A	;MULTIPLY IT BY LOG10(E).
00460	        POP     SREG,FREG;
00470	        POPJ    SREG,0;         RETURN TO CALLER.
00480
00490	LOG10A:	177674557305
00500	
00510	POOLOG: PUSH    SREG,FREG;
00520	        HRRZ    FREG,SREG;      STANDARD PROLOG.
00530	        PUSH    SREG,A;
00540	        PUSH    SREG,B;         SAVE WORKING REGISTERS.
00550	        ADD     SREG,[2000002]; SPACE IN STACK FOR LOCALS.
00560	        SETZM   ,3(FREG);       ZERO OUT LOCALS.
00570	        SETZM   ,4(FREG);
00580		MOVE	A,-2(FREG);       GET ARGUMENT
00590		JUMPLE	A, LZERO	;CHECK FOR NONPOS. ARGUMENT
00600		CAMN	A, ONE		;CHECK FOR 1.0 ARGUMENT
00610		JRST	ZERANS		;IT IS 1.0 RETURN ZERO ANS.
00620		ASHC	A, -33		;SEPARATE FRACTION FROM EXPONENT
00630		ADDI	A, 211000	;FLOAT THE EXPONENT AND MULT. BY 2
00640		MOVSM	A, 3(FREG)   ;NUMBER NOW IN CORRECT FL. FORMAT
00650		MOVSI	A, 567377	;SET UP -401.0 IN A
00660		FADM	A, 3(FREG)   ;SUBTRACT 401 FROM EXP.*2
00670		ASH	B, -10		;SHIFT FRACTION FOR FLOATING
00680		TLC	B, 200000	;FLOAT THE FRACTION PART
00690		FAD	B, L1		;B = B-SQRT(2.0)/2.0
00700		MOVE	A, B		;PUT RESULTS IN A
00710		FAD	A, L2		;A = A+SQRT(2.0)
00720		FDV	B, A		;B = B/A
00730		MOVEM	B, 4(FREG)   ;STORE NEW VARIABLE IN LZ
00740		FMP	B, B		;CALCULATE Z^2
00750		MOVE	A, L3		;PICK UP FIRST CONSTANT
00760		FMP	A, B		;MULTIPLY BY Z^2
00770		FAD	A, L4		;ADD IN NEXT CONSTANT
00780		FMP	A, B		;MULTIPLY BY Z^2
00790		FAD	A, L5		;ADD IN NEXT CONSTANT
00800		FMP	A, 4(FREG)   ;MULTIPLY BY Z
00810		FAD	A, 3(FREG)   ;ADD IN EXPONENT TO FORM LOG2(X)
00820	        FMP     A,L7;       MULTIPLY TO FORM LOGE(X).
00830	        MOVE    VREG,A;     VALUE TO VALUE REGISTER.
00840	EXIT:   SUB     SREG,[2000002];    REMOVE LOCALS.
00850	        POP     SREG,B;    RESTORE WORKING REGISTERS.
00860	        POP     SREG,A;
00870	        POP     SREG,FREG;    AND F-REGISTER.
00880	        POPJ    SREG,0;
00890	LZERO:  PUSH    SREG,ERRMSG;  CALL BLIPPERROR FOR ERRORMESSAGE.
00900	        PUSHJ   SREG,BLIPPE;
00910	        SUB     SREG,[1000001];
00920	        MOVE    VREG,MIFI;    VALUE IS MINUS INFINITY.
00930	        JRST    0,EXIT;
00940	ZERANS:	MOVEI	VREG, 0		;MAKE ANSWER ZERO
00950		JRST    EXIT	;EXIT
00960
00970	;CONSTANTS
00980
00990	ONE:	201400000000
01000	L1:	577225754146		;-0.707106781187
01010	L2:	201552023632		;1.414213562374
01020	L3:	200462532521		;0.5989786496
01030	L4:	200754213604		;0.9614706323
01040	L5:	202561251002		;2.8853912903
01050	L7:	200542710300		;0.69314718056
01060	MIFI:	400000000001		;LARGEST NEGATIVE FLOATING NUMBER
01070	ERRMSG: 20;                     ERROR MESSAGE TO BLIPPERROR.
01080
01090	LS:	0
01100	LZ:	0
01110
01120		END
01130