Google
 

Trailing-Edge - PDP-10 Archives - bb-h138e-bm_tops20_v6_1_distr - 6-1-sources/arith.mac
There are 20 other files named arith.mac in the archive. Click here to see a list.
	TITLE ARITH - MULTIPLE PRECISION ARITHMETIC FOR EDT


; IDENT 1-001

;AUTHOR : GRAHAM BEECH	CREATION DATE : 28-JAN-1983

;****************************************************************************
;*									    *
;*  COPYRIGHT (C) 1978, 1985                                                *
;*  BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.			    *
;*  ALL RIGHTS RESERVED.                                                    *
;* 									    *
;*  THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED  *
;*  ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH  LICENSE AND WITH THE  *
;*  INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR  ANY  OTHER  *
;*  COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY  *
;*  OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY  *
;*  TRANSFERRED.							    *
;* 									    *
;*  THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE  WITHOUT  NOTICE  *
;*  AND  SHOULD  NOT  BE  CONSTRUED  AS  A COMMITMENT BY DIGITAL EQUIPMENT  *
;*  CORPORATION.							    *
;* 									    *
;*  DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR  RELIABILITY  OF  ITS  *
;*  SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.		    *
;*									    *
;****************************************************************************

;
;FACILITY:	EDT VERSION 3
;

;FUNCTIONAL DESCRIPTION:
;
; 	THIS MODULE CONTAINS 54-BIT ARITHMETIC ROUTINES TO HANDLE THE LINE
; 	NUMBERS USED BY EDT VERSION 3.
;
;MODIFIED BY:
;
; 1-001	ORIGINAL.  GB 28-Jan-1983
;--
; ALL ROUTINES ARE CALLED BY THE SAME INTERFACE,  TWO SOURCE PARAMETERS
; AND A DESTINATION PARAMETER, EACH OF WHICH IS THE ADDRESS OF A 54-BIT
; UNSIGNED INTEGER.
;

	SALL
	TWOSEG
	RELOC	400000

;
; TABLE OF CONTENTS:
;

	INTERN	A54%AD,A54%SU,A54%MU,MOVELI

;
; INCLUDE FILES:
;
	SEARCH	MACSYM
	SEARCH	MONSYM

; DEFINITIONS

	T1=1
	T2=2
	T3=3
	T4=4
	P=17
; A54%AD - MULTIPLE PRECISION ADDITION
;
; ADD TWO 54-BIT NUMBERS USING 2-WORD ARITHMETIC, AND RETURN THE CARRY-BIT
;
; FORMAL PARAMTERS
;
;	P1	POINTER TO SOURCE1
;	P2	POINTER TO SOURCE2
;	P3	POINTER TO DESTINATION (RESULT)
;-
A54%AD::
	DMOVE	T1,@-2(P)		;GET SOURCE1 INTO T1,T2
	HRRZS	T2			;54 BITS ONLY
	EXCH	T1,T2			;SWAP ROUND FOR ARITHMETIC
	DMOVE	T3,@-3(P)		;GET SOURCE2 INTO T3,T4
	HRRZS	T4			;ZERO UNUSED BITS
	EXCH	T3,T4			;SWAP ROUND FOR ARITHMETIC
	DADD	T1,T3			;ADD THEM
	MOVE	T3,-1(P)		;GET DESTINATION ADDRESS
	MOVEM	T2,(T3)			;STORE RESULT
	HRRM	T1,1(T3)		;...
	TLNN	T1,-1			;LOOK FOR OVERFLOW
	TDZA	T1,T1			;NO OVERFLOW.
	MOVEI	T1,1			;RETURN OVERFLOW
	RET
; A54%SU - MULTIPLE PRECISION SUBTRACTION
;
; SUBTRACT TWO 54-BIT NUMBERS USING 2-WORD ARITHMETIC
;
; FORMAL PARAMTERS
;
;	P1	POINTER TO SOURCE1
;	P2	POINTER TO SOURCE2
;	P3	POINTER TO DESTINATION (RESULT)
;-
A54%SU::
	DMOVE	T1,@-2(P)		;GET SOURCE1 INTO T1,T2
	HRRZS	T2			;54 BITS ONLY
	EXCH	T1,T2			;SWAP ROUND FOR ARITHMETIC
	DMOVE	T3,@-3(P)		;GET SOURCE2 INTO T3,T4
	HRRZS	T4			;ZERO UNUSED BITS
	EXCH	T3,T4			;SWAP ROUND FOR ARITHMETIC
	DSUB	T1,T3			;SUBTRACT SOURCE2 FROM SOURCE1
	MOVE	T3,-1(P)		;GET DESTINATION ADDRESS
	MOVEM	T2,(T3)			;STORE RESULT
	HRRM	T1,1(T3)		;...
;
; EDT DOES NOT ALLOW  RESULT TO GO NEGATIVE SO JUST RETURN
;
	RET
; A54%MU - MULTIPLE PRECISION MULTIPLICATION
;
; MULTIPLY TWO 54-BIT NUMBERS USING 2-WORD ARITHMETIC.
;
; FORMAL PARAMTERS
;
;	P1	POINTER TO SOURCE1
;	P2	POINTER TO SOURCE2
;	P3	POINTER TO DESTINATION (RESULT)
;-
A54%MU::
	DMOVE	T1,@-2(P)		;GET SOURCE1 INTO T1,T2
	HRRZS	T2			;54 BITS ONLY
	EXCH	T1,T2			;SWAP ROUND FOR ARITHMETIC
	DMOVE	T3,@-3(P)		;GET SOURCE2 INTO T3,T4
	HRRZS	T4			;ZERO UNUSED BITS
	EXCH	T3,T4			;SWAP ROUND FOR ARITHMETIC
	DMUL	T1,T3			;ADD THEM
	MOVE	T1,-1(P)		;GET DESTINATION ADDRESS
	MOVEM	T4,(T1)			;STORE RESULT
	HRRM	T3,1(T1)		;...
;
; NO CHECK FOR OVERFLOW EDT SHOULD NOT LET IT HAPPEN ??!
;
	RET
;
; MOVELINE - COPY A 54 BIT LINE NUMBER
;
; FORMAL PARAMETERS:
;
;	SOURCE - LINE NO. TO COPY
;	DESTINATION - WHERE TO COPY IT TO
;
MOVELI::
	DMOVE	T1,@-2(P)		;GET LINE # TO COPY
	MOVE	T3,-1(P)		;WHERE TO PUT IT
	MOVEM	T1,(T3)			;STORE LO & MD
	HRRM	T2,1(T3)		;STORE HI
	RET

	END