Trailing-Edge
-
PDP-10 Archives
-
AP-D480B-SB_1978
-
dpsim.mac
There is 1 other file named dpsim.mac in the archive. Click here to see a list.
TITLE DPSIM - DOUBLE PRECISION FLOATING POINT SIMULATION
SUBTTL DOUBLE PRECISION FLOATING ADD/SUBTRACT
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
; OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;COPYRIGHT (C) 1976,1977 BY DIGITAL EQUIPMENT CORPORATION
INTERN DPSIMV
DPSIMV=2,,1 ;VERSION DATE: 18-SEP-1973
;FOR KI10 SIMULATION/DIAGNOSTICS 13-OCT-71, J.R.KIRCHOFF
; 7-DEC-69 /TWE , 14-JULY-70 /JRK
; DICK GRUEN: 9-SEP-67
; 7-MAY-66 BEGOT 9-SEP-67 (MACROX Q ERRORS)
;THESE ROUTINES ADD OR SUBTRACT TWO DOUBLE PRECISION
;NUMBERS. EACH NUMBER IS COMPOSED OF 8 BITS OF EXPONENT
;IN THE HI ORDER WORD WITH THE REMAINING 27 HI ORDER BITS
;AND THE 33 FIRST ARIMETIC BITS OF THE LO ORDER AS THE
;MANTISSA. THE LAST 2 LO ORDER BITS ARE UNUSED. THE
;ANSWER IS RETURNED IN AC X, WHERE "X" IS THE DOUBLE PRECISION
;AC USED AND MAY BE 0. THE ROUTINE IS CALLED BY:
;FAD: MOVEI Q,ARG2
; PUSHJ P,DFAX ;ARG1 IN AC X
; OR
;FADM: MOVEI Q,ARG2
; PUSHJ P,DFAMX ;ARG1 IN AC X
; OR
;FSB: MOVEI Q,ARG2
; PUSHJ P,DFSX ;ARG1 IN AC X
; OR
;FSBM: MOVEI Q,ARG2
; PUSHJ P,DFSMX ;ARG1 IN AC X
; NOTE THAT THE "X" IS A NUMBER
; AND NOT A LETTER
HISEG
P==17
Q==16
AC2==10
X2==11
XDIFF==12
AC1==13
X1==15
BIT1==200000
BIT2==100000
BITCRY==1000
BITNEG==1B18
BITEST==3400
SGNAC1==1
SGNAC2==2
DEFINE FSM(A)<
INTERN DFS'A'
INTERN DFSM'A'
DFSM'A': SKIPA AC1,Q
DFS'A': MOVEI AC1,A
IFN A,<
HRLI Q,A
JRST GETNEG
>>
DEFINE FAM(A)<
INTERN DFAM'A'
INTERN DFA'A'
DFAM'A': SKIPA AC1,Q
DFA'A': MOVEI AC1,A
IFN A,<
HRLI Q,A
JRST DXFAD ;JUNE 27, 1972 (CHANGED FROM "DFADX")
>>
DEFINE DSUB<
FSM 0
>
DEFINE DADD<
FAM 0
>
DEFINE MAKNEG(A)<
SETCM A,A
MOVNS A+1
TDNN A+1,DLOW.0
AOS A
>
;
;
;GENERATE ENTRIES TO BE USED FOR AC 4 (SRM - JUNE 27,1972)
;
FSM 4
FAM 4
;
DSUB
GETNEG: PUSH P,AC1 ;ALL SUBTRACTS ENTER HERE
MOVN AC1+1,1(Q) ;PICKUP NEGATIVE OF MEM ARG
SETCM AC1,0(Q)
TDNN AC1+1,DLOW.0
AOJA AC1,DFSBX
JRST DFSBX
DADD
DXFAD: PUSH P,AC1 ;ALL ADDS ENTER HERE
MOVE AC1,0(Q) ;GET MEMORY ARGUMENT
MOVE AC1+1,1(Q) ;...
DFSBX: MOVSS Q ;SWAP ARGUMENT POINTERS
SKIPN AC2,0(Q) ;GET HI ORDER OF AC ARG
JRST OVTM1 ;IF 0, AC1 HAS THE SUM
JUMPN AC1,GA ;IF AC1 NON ZERO, PERFORM ADD
MOVE AC1,AC2 ;AC1=0 MEANS AC ARG IS ANSWER
MOVE AC1+1,1(Q) ;RETURN IT TO EITHER AC OR MEM
JRST OVTM1 ;...
GA:! LDB X1,DPAC.1 ;ARG1 EXP AND SIGN
LDB X2,DPAC.2 ;ARG2 EXP AND SIGN
SKIPG AC1 ;MAKE EXPS +
ANDCAI X1,777 ;...
SKIPG AC2 ;...
ANDCAI X2,777 ;...
MOVE XDIFF,X2 ;GET EXP DIFFERENCE
SUB XDIFF,X1 ;...
SKIPLE XDIFF ;SAVE HIGHER EXP
AOS X1,X2 ;SAVED IN X1
MOVE AC2+1,1(Q) ;GET LO ORDER OF AC ARG
TLZ Q,SGNAC1+SGNAC2 ;MARK SIGNS BEFORE SHIFT
JUMPGE AC1,AC1PL ;SKIP HAIR IF AC1 +
TLO Q,SGNAC1 ;MARK SIGN = -
MAKNEG AC1
AC1PL:! JUMPGE AC2,AC2PL ;SKIP HAIR IF AC2 = +
TLO Q,SGNAC2 ;MARK SIGN = -
MAKNEG AC2
AC2PL:! TLZ AC1,777000 ;REMOVE EXPS
TLZ AC2,777000 ;...
JUMPLE XDIFF,SHFT2 ;SHIFT ARG2
MOVNS XDIFF ;SHIFF ARG1 RIGHT
ASHC AC1,(XDIFF) ;UNORMALIZE ARG1
CADD:! TLNN Q,SGNAC1 ;WAS AC1 =-?
JRST AC1WPL ;NO, SKIP RECOMPL
TLNE Q,SGNAC2 ;IF BOTH WERE NEG,...
JRST BOTHN ;DON'T RECOMPL EITHER
MAKNEG AC1
AC1WPL:!TLNN Q,SGNAC2 ;WAS AC2=-?
JRST AC2WPL ;NO, SKIP RECOMPL
MAKNEG AC2
AC2WPL:!TLZ AC1,477000 ;SET TESTABLE BITS
TLZ AC2,477000 ;TURN OTHERS OFF
JCRY1 .+1 ;TURN OFF OVFLO FLAG
ADD AC1+1,AC2+1 ;LO ORDER ADD
JCRY1 [AOJA AC1,TADD] ;ADD IN HI ORDER CARRY
TADD:! ADD AC1,AC2 ;HI ORDER ADD
TLNE AC1,BIT2 ;IS CARRY BIT TRUE
TLC AC1,BITCRY ;NO, COMPL. IT
TLZN AC1,BIT1 ;IS SUM -
JRST NORMA ;NO ON FIRST GLANCE
TLZE AC1,BIT2 ;...
TLNE AC1,BITCRY ;...
PUSHJ P,NEG1 ;SUM=-,GO MAKE IT +
MLON
D.DORM: ;ENTRY FOR DFDV
NORMA:! TRO X1,200000 ;PROTECT AGAINST BORROWS FROM BITNEG
TLNN AC1,1000 ;SKIP UNNORM IF NOT NEEDED
SOSA X1 ;BUT TELL THE EXPONENT ABOUT IT
ASHC AC1,-1 ;THERE WAS SOMETHING THERE
D.MORM: TRO X1,200000 ;PROTECT AGAINST BORROWS FROM BITNEG
TLZ AC1,777000 ;NO STRAY BITS
JUMPN AC1,LOOPA+1 ;CHECK FOR ZERO
TDNN AC1+1,DLOW.0 ;...
JRST 2,@[XWD 0,RET0] ;RETURN ZERO ANSWER
SKIPA ;ENTER NORMALIZE ROUTINE
LOOPA:! ASHC AC1,1 ;1 BIT NORMALIZE
TLNN AC1,400 ;IS NORMALIZE DONE?
SOJA X1,LOOPA ;IF NOT, SUB1 FROM EXP
TRNE X1,BITEST ;DID FP OV/UNDER FLO OCCUR?
JRST [TRNN X1,040000 ;UNDERFLOW?
JRST OVTM2 ;NO, OVERFLOW
JRST UFLOW] ;YES
TRZE X1,BITNEG ;SHOULD ANS BE -
PUSHJ P,NEG2 ;GO MAKE IT SO
DPB X1,DPAC.1 ;STORE EXP AND SIGN
OVTM1:! JRST 2,@[OVTA] ;CLEAR AR FLAGS
OVTM2:! TRZ X1,400
TRZE X1,BITNEG ;SHOULD ANS BE -
PUSHJ P,NEG2 ;GO MAKE IT SO
DPB X1,DPAC.1 ;STORE EXPONENT AND SIGN
JRST 2,@[XWD 440200,OVTA]
D.ZERO: ;ENTRY FOR ZERO ANSWER
RET0:! SETZB AC1,AC1+1 ;RETURN ANS=0
OVTA:! POP P,Q ;RESTORE AC Q
MOVEM AC1,0(Q) ;STORE HI ORDER ANS
TLZ AC1+1,400000 ;SET LO SIGN = +
MOVEM AC1+1,1(Q) ;STORE LO ORDER ANS
POPJ P, ;TRA 1,4
UFLOW:! TRZ X1,400
TRZE X1,BITNEG
PUSHJ P,NEG2
DPB X1,DPAC.1
JRST 2,@[XWD 440300,OVTA]
DPAC.1: POINT 9,AC1,8
DPAC.2: POINT 9,AC2,8
DLOW.0: OCT 377777777777
D.NORM: PUSH P, Q ;SAVE AC Q
JRST D.MORM ;ENTER COMMON ROUTINE
SHFT2:! ASHC AC2,0(XDIFF) ;UNNORMALIZE ARG2
AOJA X1,CADD ;INDICATE UNNORMALIZATION
NEG2:! ANDCAI X1,777 ;MAKE EXP -
NEG1:! TRO X1,BITNEG ;SET MARKER FOR -
MOVNS AC1+1 ;TWOS COMPL
SETCMM AC1 ;...
TDNN AC1+1,DLOW.0 ;...
AOS AC1 ;...
POPJ P, ;RETURN
BOTHN:! TRO X1,BITNEG ;SINCE BOTH WERE NEG, ANS ...
JRST AC2WPL ;MUST BE NEG
SUBTTL DFMP DOUBLE PRECISION FLOATING MULTIPLY
;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 MULTIPLY TWO DOUBLE PRECISION FLOATING
;NUMBERS. EACH NUMBER HAS AN 8-BIT EXPONENT AND A
;MANTISSA COMPOSED OF THE REMAINING 27 HI ORDER BITS AND
;33 OF THE 35 LO ORDER ARITMETIC BITS. THE ANSWER IS RE-
;TURNED EITHER IN AC X OR IN MEMORY DEPENDING UPON THE
;ENTRY USED. THE "X" IS THE DOUBLE PRECISION AC USED AND
;MAY BE 0,2,4, OR 6. X IS ALSO SPECIFIED BY THE ENTRY
;USED. THE ROUTINE IS CALLED BY:
;FMP: MOVEI Q,ARG2
; PUSHJ P,DFM.X ;ARG1 IN AC X
; OR
;FMPM: MOVEI Q,ARG2
; PUSHJ P,DFMM.X ;ARG1 IN AC X
; NOTE THAT THE "X" AFTER THE "." IS A NUMBER, NOT
; A LETTER.
P==17
Q==16
AC2==10
T3==12
AC1==13
T4==15
BITNEG==1B18
DEFINE DM(A)<
INTERN DFMM'A'
INTERN DFM'A'
DFMM'A': SKIPA AC1,Q
DFM'A': MOVEI AC1,A
IFN A,<
HRLI Q,A
JRST DFMPX
>>
DEFINE GOODY(A)<
DM 0
>
GOODY
;
;GENERATE ENTRIES TO BE USED FOR AC 4 (SRM - JUNE 28,1972)
;
;
DM 4
DFMPX: PUSH P,AC1 ;ALL ROUTINES ENTER HERE
SKIPN T3,0(Q) ;HI ORDER OF ARG2
JRST 2,@[XWD 0,D.ZERO] ;ZERO PRODUCT
JUMPL T3,NEG2A ;IF -, PICK UP COMPL
MOVE AC2,T3 ;+, PLACE IN AC2
MOVE AC2+1,1(Q) ;...
NEG2RT:!MOVSS Q ;GET ARG1
SKIPN AC1,0(Q) ;LOOK AT ARG1
JRST 2,@[XWD 0,D.ZERO] ;ZERO PRODUCT
XOR T3,AC1 ;GET ANSWER SIGN
HLL Q,T3 ;SALT IT AWAY
JUMPL AC1,NEG1A ;IF -, PICK UP ARG1 COMPL
MOVE AC1+1,1(Q) ;PICK UP +
NEG1RT:!LDB T4,DPAC.1 ;GET EXPS
LDB T3,DPAC.2 ;...
ADDI T4,-200(T3) ;GET PREDICTED EXP (EXCESS 200)
ANDI T4,077777 ;MASK EXPONENT TO 15 BITS
TLNE Q,400000 ;IF RESULT SHOULD BE NEG, ...
TRO T4,BITNEG ;SET INDICATOR
HRL Q,T4 ;SALT AWAY PROPOSED EXP
TLZ AC1,777000 ;REMOVE EXPS
TLZ AC2,777000 ;...
ASHC AC1,5 ;MAKE SEMI-PRODUCTS MORE SIGNIFICANT
ASHC AC2,5 ;...
MUL AC1+1,AC2 ;FORM LO ORDER SEMI-PRODS
MUL AC2+1,AC1 ;...
MOVE T3,AC1+1 ;PROTECT FROM CREEPING SIGNIFICANCE
MUL AC1,AC2 ;HI ORDER SEMI-PROD
JCRY1 .+1 ;CLEAR FLAG
ADD AC1+1,T3 ;FIRST LO SEMI-PROD
JCRY1 [AOJA AC1,A1RT] ;ADD IN CARRY
A1RT:! ADD AC1+1,AC2+1 ;SECOND LO SEMI-PROD
JCRY1 [AOJA AC1,A2RT] ;ADD IN CARRY
A2RT:! TRNE AC1+1,2 ;PATCH FOR MORE PRECISION
ADDI AC1+1,2
ASHC AC1,-2
HLRZ T4,Q ;RECLAIM EXP
JRST D.MORM ;GO NORMALIZE AND RETURN
NEG2A:! SETCM AC2,T3 ;TW0S COMPL ARG2
MOVN AC2+1,1(Q) ;...
TDNN AC2+1,DLOW.0 ;...
AOJA AC2,NEG2RT ;...
JRST NEG2RT ;...
NEG1A:! SETCM AC1,AC1 ;TWOS COMPL ARG2
MOVN AC1+1,1(Q) ;...
TDNN AC1+1,DLOW.0 ;...
AOJA AC1,NEG1RT ;...
JRST NEG1RT ;...
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)<
INTERN DFDM'A'
INTERN DFD'A'
DFDM'A': SKIPA AC1,Q
DFD'A': MOVEI AC1,A
IFN A,<
HRLI Q,A
JRST DFDVX
>>
DEFINE GOODY<
DFD 0
>
GOODY
;
;
;GENERATE ENTRIES TO BE USED FOR AC 4 (SRM - JUNE 28, 1972)
;
DFD 4
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 ;...
END