Google
 

Trailing-Edge - PDP-10 Archives - CFS_TSU04_19910205_1of1 - update/cblsrc/arith.mac
There are 20 other files named arith.mac in the archive. Click here to see a list.
; UPD ID= 1026 on 4/28/83 at 10:25 PM by NIXON                          
TITLE	ARITH METIC FOR COBOTS
SUBTTL	DOUBLE-PRECISION INTEGER MULTIPLICATION

	SEARCH COPYRT
	SALL

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.

COPYRIGHT (C) 1974, 1983, 1984 BY DIGITAL EQUIPMENT CORPORATION


	SEARCH	LBLPRM
	%%LBLP==:%%LBLP

	HISEG

	.COPYRIGHT		;Put standard copyright statement in REL file

;ENTER WITH FIRST OPERAND (OPERAND A) IN AC SPECIFIED BY AC-FIELD OF
;	ACCUMULATOR 16 (TWO CONSECUTIVE AC'S IF DOUBLE PRECISION).

;SECOND OPERAND (OPERAND B) IS ACCESSED VIA ADDRESS-FIELD OF
;		 AC 16 (WHERE THE UUO IS).
; IF OPERAND B IS DOUBLE-PRECISION:
;	0(16) GETS HIGH-ORDER WORD, 1(16) REFERENCES LOW HALF.
; IF OPERAND B IS SINGLE-PRECISION:
;	0(16) REFERENCES THE SINGLE WORD.
;EXIT WITH DOUBLE-PRECISION (LOW-ORDER TWO WORDS) IN AC'S SPECIFIED BY
;	AC-FIELD OF AC16.

	ENTRY	MUL.12		;MULTIPLY 1 WORD IN AC BY 2 WORDS IN MEMORY.
	ENTRY	MUL.21		;MULTIPLY 2 WORDS IN AC'S BY 1 WORD IN MEMORY.
	ENTRY	MUL.22		;MULTIPLY 2 WORDS IN AC'S BY 2 WORDS IN MEMORY.

SIGN=5			;BIT 0 = 1 IF SIGNS OF A AND B DIFFER, 0 OTHERWISE.
T=6			;INTERMEDIATE PRODUCT (2 AC'S)
TA=10			;TEMPORARY
TB=11			;TEMPORARY
TC=13			;HIGH-ORDER AND
TD=14			;  LOW-ORDER PARTS OF OPERAND B
AC=15			;ADDRESS OF INPUT AND RESULT AC'S
PA=16			;POINTER TO OPERAND B.
PP=17			;PUSH-DOWN POINTER.
MUL.12:	LDB	AC,PACFL.##		;GET AC
	MOVE	T,(AC)			; AND CONTENTS
	ASHC	T,-^D35			;EXTEND SIGN
	DMUL	T,(PA)			;MULTIPLY
	DMOVEM	T+2,(AC)		;STORE RESULT
	POPJ	PP,

MUL.21:	LDB	AC,PACFL.##		;GET AC
	DMOVE	T,(AC)			;AND CONTENTS
	MOVE	T+2,(PA)		;OP
	ASHC	T+2,-^D35		;EXTEND SIGN
	DMUL	T,T+2
	DMOVEM	T+2,(AC)		;RESULT
	POPJ	PP,

MUL.22:	LDB	AC,PACFL.##		;GET AC
	DMOVE	T,(AC)			;GET OP 1
	DMUL	T,(PA)			;MULTIPLY
	DMOVEM	T+2,(AC)
	POPJ	PP,
SUBTTL	SINGLE-PRECISION DIVIDE

ENTRY DIV.11

EXTERNAL OVFLO.	;FLAG TO SHOW DIVIDE OVERFLOW

TA=13	;TEMPORARY (2 AC'S)
RS=15	;RESULT AC ADDRESS
PA=16	;ADDRESS OF DIVISOR
PP=17	;PUSH-DOWN POINTER


;CALLING SEQUENCE:
;	MOVE	16,[Z AC,OPERAND]
;	PUSHJ	17,DIV.11

;ENTER WITH DIVIDEND IN ACCUMULATOR AC.
;EXIT WITH QUOTIENT IN ACCUMULATOR AC, REMAINDER IN AC+2

DIV.11:	MOVE	RS,0(PA)	;IS DIVISOR ZERO?
	TLZ	RS,1B18		;OR--IS IT 2**-35?
	JUMPE	RS,OVRFLO	;YES--TROUBLE (IF JUMP)

	LDB	RS,[POINT 4,PA,12]; GET OPERAND AC
	MOVE	TA,0(RS)	;GET OPERAND

	JOV	.+1		;CLEAR OVERFLOW FLAG
	IDIV	TA,0(PA)	;DO THE DIVIDE

	MOVEM	TA,0(RS)	;STASH QUOTIENT
	MOVEM	TA+1,2(RS)	;STASH REMAINDER

	JOV	OVRFLO		;SET ANY OVERFLOW INDICATION

	POPJ	PP,

;DIVISION OVERFLOW -- SET INDICATOR

OVRFLO:	SETOM	OVFLO.		;SET OVERFLOW CONDITION
	POPJ	PP,
SUBTTL	DOUBLE PRECISION DIVIDES


ENTRY DIV.12	;DIVIDE ONE WORD BY TWO WORDS
ENTRY DIV.21	;DIVIDE TWO WORDS BY ONE WORD
ENTRY DIV.22	;DIVIDE TWO WORDS BY TWO WORDS
ENTRY DIV.41	;DIVIDE FOUR WORDS BY ONE WORD
ENTRY DIV.42	;DIVIDE FOUR WORDS BY TWO WORDS
ENTRY DVI41.	;DIVIDE FOUR WORDS BY ONE WORD, SAVE REMAINDER
ENTRY DVI42.	;DIVIDE FOUR WORDS BY ONE WORD, SAVE REMAINDER


;CALLING SEQUENCE:
;	MOVE	16,[Z AC,OPERAND]
;	PUSHJ	17,DIV.12/DIV/21/DIV.22

;ENTER WITH DIVIDEND IN ACCUMULATORS AC&AC+1 FOR DIV.21&DIV.22,
;	AND ACCUMULATOR AC FOR DIV.12.
;EXIT WITH QUOTIENT IN AC'S AC&AC+1,
; REMAINDER IN AC+2&AC+3 FOR DIV.12, DIV.22,  REMAINDER IN AC+2 FOR DIV.21
FSIGN==1B18	;SIGN FLAG JAMMED INTO PA


H1=13
H2=14
Q=4
QI=16
PA=16
PP=17

RS=15
TA=5
TB=TA+1
TC=TB+1
TD=TC+1
TE=TD+1
DIV.21:	MOVE	H1,(PA)			;GET OPERAND
	ASHC	H1,-^D35		;EXTEND SIGN
	LDB	RS,PACFL.##		;GET AC FIELD
	DMOVE	TC,(RS)			;GET SECOND OPERAND
	MOVE	TA,TC			;PROPAGATE THE SIGN
	ASHC	TA,-^D70
	JOV	.+1			;CLEAR OVERFLOW.
	DDIV	TA,H1			;DIVIDE
	JOV	OVRFLO			;CHECK OVERFLO
	DMOVEM	TA,(RS)			;STORE RESULT
	MOVEM	TD,2(RS)		;AND REMAINDER
	POPJ	PP,

DIV.12:	LDB	RS,PACFL.##			;GET AC
	MOVE	TD,(RS)			;GET OP 1
	MOVE	TA,TD			;PROPAGATE THE SIGN.
	ASHC	TA,-^D70
	MOVE	TC,TA
	JOV	.+1			;CLEAR OVERFLOW.
	DDIV	TA,(PA)
	JOV	OVRFLO
	DMOVEM	TA,(RS)			;STORE QUOTIENT
	DMOVEM	TC,2(RS)		;AND REMAINDER
	POPJ	PP,

DIV.22:	LDB	RS,PACFL.##		;GET AC
	DMOVE	TC,(RS)			;GET OP
	MOVE	TA,TC			;PROPAGATE THE SIGN.
	ASHC	TA,-^D70
	JOV	.+1			;CLEAR OVERFLOW.
	DDIV	TA,(PA)
	JOV	OVRFLO
	DMOVEM	TA,(RS)
	DMOVEM	TC,2(RS)
	POPJ	PP,
;DIVIDES THE FOUR WORD INTEGER IN ACC 0-3
;LEAVING THE QUOTIENT IN ACC 0-3, REMAINDER IN ACC 4&5

DIV.41:	MOVE	H1,(PA)		;GET OPERAND
	ASHC	H1,-^D35	;EXTEND SIGN
	JRST	DIV.4X		;COMMON CODE

DIV.42:	DMOVE	H1,(PA)		;INCASE (PA) = 6
DIV.4X:	DMOVE	4,2		;COPY LOW ORDER 2 WORDS
	DMOVE	2,0		;COPY HIGH ORDER 2 WORDS
	ASHC	0,-^D70		;EXTEND THE SIGN
	JOV	.+1		;CLEAR OVERFLOW.
	DDIV	0,H1		;DIVIDE HIGH ORDER 2 WORDS
	JOV	OVRFLO
	DDIV	2,H1		;AND LOW ORDER
	JUMPN	0,RET.1##	;[606] IF THE HIGH ORDER PART
	JUMPN	1,RET.1		;[606]  IS ZERO
	JUMPGE	2,RET.1		;[606] BUT THE LOW ORDER PART IS NEGATIVE
	SETOB	0,1		;[606] EXTEND THE SIGN
	POPJ	PP,
;ROUTINES CALLED BY:
;	MOVEI	15,<ADDRESS.OF.FOUR-WORD.NUMBER>
;	MOVEI	16,[POWER OF 10]
;	PUSHJ	PP,ROUTINE
;	<RETURN HERE>, WITH 2-WORD REMAINDER SAVED IN 0(15) AND 1(15).

DVI41.:	MOVE	H1,(PA)		;GET OPERAND
	ASHC	H1,-^D35	;EXTEND SIGN
	JRST	DIVI4X

DVI42.:	DMOVE	H1,(PA)		;GET OPERAND

;USE 6 ACS - 4 THRU 11
;AC15 WILL EITHER POINT TO AC0, OR %TEMP

DIVI4X:	DMOVE	10,2(15)	;COPY LOW ORDER 2 WORDS
	DMOVE	6,(15)		;COPY HIGH ORDER 2 WORDS
	ASHC	4,-^D70		;EXTEND THE SIGN
	JOV	.+1		;CLEAR OVERFLOW
	DDIV	4,H1		;DIVIDE HIGH ORDER 2 WORDS
	JOV	OVRFLO
	DDIV	6,H1		;AND LOW ORDER
	DMOVEM	10,(15)		;SAVE REMAINDER
	POPJ	PP,		;RETURN
SUBTTL	QUAD-WORD ROUNDING FUNCTION

	ENTRY	ADD.4R	;[540] ADD ONE WORD IN ACC 4 TO 4 WORDS IN ACCS 0-3

;[540] HERE TO DO ROUNDING TO QUAD-WORD VALUE

ADD.4R:	ASHC	4,-^D35		;[540] EXTEND SIGN
	JFCL	17,.+1		;[540] CLEAR FLAGS
	DADD	2,4		;[540] ADD IN ROUNDING CONSTANT
	JOV	CARRY4		;[540] OVERFLOW OCCURED
	POPJ	PP,		;[540] NO, ALL DONE

CARRY4:	SKIPL	5,4		;[540] IF IT WAS NEGATIVE USE -1
	MOVEI	5,1		;[540] NO, SO ADD 1
	DADD	0,4		;[540] ADJUST HIGH WORD
	POPJ	PP,		;[540] AND RETURN


	END