Trailing-Edge
-
PDP-10 Archives
-
klad_sources
-
klad.sources/dfdv.mac
There are no other files named dfdv.mac in the archive.
SUBTTL DFDV DOUBLE PRECISION FLOATING DIVIDE
;*FOR KI10 SIMULATION/DIAGNOSTICS 13-OCT-71, J.R.KIRCHOFF
;* 7-DEC-69 /TWE, 12-MAY-70 /JRK
;* DICK GRUEN: 9-SEP-67
;* 7-MAY-66 BEGOT 9-SEP-67 ( MACROX Q ERRORS )
;*THESE ROUTINES FORM THE QUOTIENT OF TWO DOUBLE
;*PRECISION FLOATING POINT NUMBERS. EACH NUMBER HAS AN
;*8-BIT EXPONENT IN THE THE HI ORDER PORTION OF THE HI
;*ORDER WORD AND A MANTISSA COMPOSED OF THE REMAINING 27
;*BITS OF THE HI ORDER WORD AND THE 35 ARITHMETIC BITS OF
;*THE LO ORDER WORD. THE DIVIDEND UPON ENTRY IS IN THE
;*DOUBLE PRECISION AC SPECIFIED BY THE CALL. THE ADDR OF
;*THE DIVISOR IS IN AC Q. THE QUOTIENT IS RETURNED EITHER
;*IN THE AC SPECIFIED BY THE CALL OR DIRECTLY TO MEMORY,
;*DEPENDING UPON THE ENTRY USED. THE DOUBLE PRECISION
;*ACCUMULATOR MAY BE 0,2,4, OR 6. THE AC IS SPECIFIED
;*AS SHOWN BELOW:
;*FDV: MOVEI Q,DIVSOR
;* PUSHJ P,DFD.X ;DIVIDEND IN AC "X"
;*FDVM: MOVEI Q,DIVSOR
;* PUSHJ P,DFDM.X ;DIVIDEND IN AC "X"
;* NOTE THAT THE "X" AFTER THE "." IS A NUMBER, NOT
;* A LETTER.
P==17
Q=16
AC2=10
D=11
X2=12
AC1=13
R=14
X1=15
BITNEG=1B18
DEFINE DFD(A)<
DFDM.'A': SKIPA AC1,Q
DFD.'A': MOVEI AC1,A
IFN A,<
HRLI Q,A
JRST DFDVX
>>
DEFINE GOODY<
DFD 0
>
GOODY
DFDVX: PUSH P,AC1 ;ALL ROUTINES ENTER HERE
MOVE X2,0(Q) ;HI ORDER OF DIVISOR
JUMPL X2,NEG2B ;IF -, PICK UP COMPL
MOVE AC2,X2 ;+, PLACE IN AC2
MOVE AC2+1,1(Q) ;...
NEG2RB:!MOVSS Q ;GET AT DIVIDEND
MOVE AC1,0(Q) ;HI ORDER
XOR X2,AC1 ;SIGN OF X2= SIGN OF QUOTIENT
JUMPL AC1,NEG1B;IF AC1=-, PICK UP COMPL
MOVE AC1+1,1(Q) ;PICK UP +
NEG1RB:!HLL Q, X2 ;SAVE QUOTIENT SIGN
TDNE AC1,[777777777] ;IS DIVIDEND ZERO?
JRST .+2
JRST 2,@[XWD 0,D.ZERO]
TDNN AC2,[777777777] ;OR HAS 11TH COMMANDMENT BEEN VIOLATED?
JRST 2,@[XWD 440240,D.ZERO] ;SET DIVIDE CHECK, RETURN 0
LDB X1,DPAC.1 ;GET EXPS
LDB X2,DPAC.2 ;...
SUBI X1,-201(X2) ;GET EXP DIFFERENCE
ANDI X1,077777 ;MASK RESULTANT EXP TO 15 BITS
TLNE Q,400000 ;MARK QUOTIENT SIGN
TRO X1,BITNEG ;...
HRL Q,X1 ;SAVE PROPOSED EXP
TLZ AC1,777000 ;GRONK EXPS
ASHC AC2,8 ;AND MAKE QUOTIENT TO RIGHT PLACE
ARITH:! DIV AC1,AC2 ;FIRST DIVISION
MUL D,AC1 ;FORM Q1*D
SETCA D, ;TWO'S COMPL OF Q1*D
TDNN D+1,DLOW.0 ;...
AOS D ;...
ADD R,D ;R CONTAINS R-Q1*D
DIV R,AC2 ;SECOND DIVISION
HLRZ X1,Q ;GET EXP
JUMPGE R,D.DORM ;GO NORMALIZE IF POSITIVE
SOJA AC1,D.DORM ;ADJUST BEFORE NORMALIZE IF NEGATIVE
NEG2B:! SETCM AC2,X2 ;TWOS COMPL OF DIVISOR
MOVN AC2+1,1(Q) ;...
TDNN AC2+1,DLOW.0 ;...
AOJA AC2,NEG2RB ;...
JRST NEG2RB ;...
NEG1B:! SETCM AC1,AC1 ;TWOS COMPL OF DIVIDEND
MOVN AC1+1,1(Q) ;...
TDNN AC1+1,DLOW.0 ;...
AOJA AC1,NEG1RB ;...
JRST NEG1RB ;...