Trailing-Edge
-
PDP-10 Archives
-
scratch
-
10,7/unsmon/kaser.mac
There are 7 other files named kaser.mac in the archive. Click here to see a list.
TITLE KASER - KL10 MODULE TO SUPPORT KA10 LONG FLOATING POINT SIMULATION - V016
SUBTTL J.M. FLEMMING/JMF TS 10 SEP 85
SEARCH F,S
$RELOC
$HIGH
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
; OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
.CPYRT<1973,1986>
;COPYRIGHT (C) 1973,1974,1975,1976,1977,1978,1979,1980,1982,1984,1986
;BY DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
;ALL RIGHTS RESERVED.
;DATE LOAD EDIT #
;---- ---- ------
;
;
;
XP VKASER,016
; PUT VERSION NUMBER IN GLOB LISTING AND LOADER STORAGE MAP
ENTRY KASER ;LOAD KASER IF LIBRARY SEARCH
KASER::
SUBTTL COMCON - INTERFACE TO SET UUO/COMMAND
;HERE TO SET/CLEAR/READ WHETHER KA10 LONG FLOATING POINT SIMULATION IS IN AFFECT
SETFPS::CAIG T2,1 ;SET OR CLEAR?
JRST SETFP1 ;YES, GO SET OR CLEAR THE BIT
MOVSI T2,(JS.FPS) ;READ, GET SIMULATION ON BIT
TDNN T2,JBTST2##(J) ;SIMULATION ENABLED?
TDZA T1,T1 ;NO
MOVEI T1,1 ;YES
JRST STOTC1## ;TELL THE PROGRAM WHETHER FP SIMULATION IS ON OR OFF
;HERE FROM THE SET COMMAND TO SET/CLEAR FLOATING POINT SIMULATION
SETFPC::MOVE T1,[-1,,[SIXBIT /POINT/]] ;IF USER TYPED FLOATING POINT,
PUSHJ P,TXTARG## ; SKIP THE "POINT"
JFCL ;DON'T REQUIRE IT
PUSHJ P,CTEXT1## ;READ NEXT ARG
JUMPE T2,SETFP2 ;EOL MEANS ON
MOVE T1,[-1,,[SIXBIT /NO/]] ;ON OR OFF?
PUSHJ P,FNDNAM## ;SEE IF THE USER IS TURNING SIMULATION OFF
SETFP2: TROA T2,1 ;USER WANTS SIMULATION
SETZ T2, ;USER DOESN'T
SETFP1: MOVSI T1,(JS.FPS) ;KA10 LONG FLOATING POINT SIMULATION BIT
ANDCAM T1,JBTST2##(J) ;SET OR CLEAR THE BIT
TRNE T2,1
IORM T1,JBTST2##(J)
JRST CPOPJ1## ;OK RETURN
SUBTTL ERRCON - INTERFACE TO ILLEGAL (UNIMPLEMENTED) INSTRUCTIONS
;DISPATCH TO KA10 LONG FLOATING POINT SIMULATION ROUTINE, UFA(130),
;DFN(131), FADL(141), FSBL(151), FMPL(161), FDVL(171).
KALFPS::LDB T1,[POINT 9,M,8] ;GET MUUO OPCODE
CAIGE T1,132 ;UFA OR DFN?
TRZA T1,110 ;YES, TRANSLATE TO 20,21
LSH T1,-3 ;NO, FADL, ETC. TRANSLATE TO 14-17
IFN FTRSP,<
AOS .CPFAD##-14(T1) ;COUNT THE NUMBER OF SIMULATIONS OF
; THIS INSTRUCTION
>
PUSHJ P,@FLONGD-14(T1) ;DISPATCH TO SIMULATION ROUTINE
PJRST USRXIT## ;EXIT TO THE USER
FLONGD: SFADL
SFSBL
SFMPL
SFDVL
SUFA
SDFN
;SIMULATION ROUTINES FOR LONG-MODE FLOATING POINT ARITHMETIC
; (KA10-STYLE DOUBLE PRECISION)
SDFN: PUSHJ P,SAVE3##
PUSHJ P,GTARGS
LSHC T2,11 ;EXPONENT TO T2 (ISN'T CHANGED)
SETCM T1,T1 ;ONE'S COMPLEMENT THE HIGH WORD
MOVN T3,T3 ;TWO'S COMPLEMENT THE LOW WORD.
SKIPN T3 ;SKIP UNLESS LOW WORD IS ZERO
ADDI T1,1 ;TWO'S COMPLEMENT THE HIGH WORD
LSHC T2,-11 ;RESTORE OLD BITS 0-8
EXCTXU <MOVEM T1,0(P1)> ;HIGH PART TO AC
MOVE T1,T3 ;LOW PART
PJRST PUTWDU## ;LOW PART TO E
;SUBROUTINE FOR ARGUMENT FETCH AND PREPARATION (EXTRACT EXPONENT, SIGN EXTEND)
GTARGS: LDB P1,PUUOAC## ;GET AC FIELD OF INSTR
PUSHJ P,GETWDU## ;GET (E)
MOVE T3,T1 ;TO T3
EXCTUX <MOVE T1,(P1)>;GET AC ARG
SETZB T2,T4 ;CLEAR LOW PARTS
POPJ P,
SFLGET: PUSHJ P,GETWDU## ;FETCH C(E)
MOVE T2,T1 ;TO T2
LDB P1,PUUOAC## ;GET AC FIELD OF INSTR
EXCTUX <MOVE P3,(P1)> ;FETCH C(AC)
SFLGT2: LDB P2,[POINT 9,P3,8] ;EXPONENT AND SIGN OF C(AC)
LDB T1,[POINT 9,T2,8] ;EXPONENT AND SIGN OF C(E)
TRNE P2,400
XORI P2,777 ;ONES COMPLEMENT OF NEGATIVE EXPONENT
TRNE T1,400
XORI T1,777
SKIPL P3 ;SKIP IF C(AC) ARE NEGATIVE
TLZA P3,777000 ;POSITIVE. EXTEND SIGN BIT
TLO P3,777000 ;NEGATIVE. EXTEND SIGN
SKIPL T2 ;SKIP IF C(E) ARE NEGATIVE
TLZA T2,777000 ;POSITIVE. EXTEND SIGN BIT
TLO T2,777000 ;NEGATIVE. EXTEND SIGN
POPJ P,
;SUBROUTINE FOR ADD/SUBTRACT TYPE OPERATIONS. DENORMALIZE SMALLER ARGUMENT
SFAT3A: CAML P2,T1 ;DECIDE WHICH EXPONENT IS LARGER
JRST SFAT3B ;AND DO PRENORMALIZE (DENORMALIZE)
EXCH P2,T1 ;INTERCHANGE OPERANDS
EXCH P3,T2 ;SMALLER OPERAND INTO T1/T2/T3=0
SFAT3B: SUB T1,P2 ;T1=SHIFT FACTOR (0 OR NEGATIVE)
MOVEI T3,0 ;FOR PEOPLE WHO WANT DOUBLE LENGTH
CAMGE T1,[-100] ;ARE WE GOING TO LOSE ALL SIGNIFIGANCE?
TDZA T2,T2 ;YES. T2=0 SKIP THE SHIFT
ASHC T2,(T1)
TRZ T3,177 ;KA10 MAKES A 54 BIT RESULT
ADD T2,P3 ;DOUBLE LENGTH RESULT TO T2/T3
SKIPL T2 ;POSITIVE OR NEGATIVE RESULT
SKIPA P3,[TLNN T2,1000]
MOVE P3,[TLNE T2,1000]
XCT P3 ;SKIP IF ADD OVERFLOWED
JRST SFAT3C ;NO OVERFLOW
ASHC T2,-1 ;ADD PRODUCED AN HIGH ORDER BIT.
ADDI P2,1 ;SHIFT RESULT DOWN AND BUMP EXPONENT
SFAT3C: TLZ T3,400000 ;CLEAR SIGN BIT IN LOW WORD (SET BY ASHC)
POPJ P,
SUFA: PUSHJ P,SAVE3##
PUSHJ P,SFLGET ;FETCH AND SETUP ARGUMENTS
PUSHJ P,SFAT3A ;PRENORMALIZE AND DO THE ADD.
CAIG P2,377 ;DID EXPONENT OVERFLOW?
JRST SUFA1 ;NO.
MOVSI P3,440200 ;SET AROV, FOV, AND TRAP1
IORM P3,.JDAT+JOBPD1## ;STORE WHERE THEY'LL BE RESTORED.
SUFA1: SKIPN T2 ;SKIP IF RESULT NON ZERO.
JUMPE T3,STORA1 ;HIGH PART IS 0. RETURN 0 IF LOW PART IS 0
DPB P2,[POINT 8,T2,8] ;STORE EXPONENT
SKIPGE T2 ;SKIP IF RESULT IS POSITIVE
TLC T2,377000 ;ONES COMPLEMENT TO EXPONENT
MOVE T3,T2 ;COPY RESULT TO T3 FOR STORA1
JRST STORA1
SFADL: PUSHJ P,SAVE3##
PUSHJ P,SFLGET ;FETCH AND PREPARE ARGUMENTS
JRST SFADL0
SFSBL: PUSHJ P,SAVE3##
PUSHJ P,SFLGET ;FETCH AND PREPARE ARGUMENTS
MOVN T2,T2 ;NEGATE C(E)
SFADL0: PUSHJ P,SFAT3A ;PRENORMALIZE AND DO ADD
;POSTNORMALIZE. P2= EXPONENT, T2--T3 ARE FRACTION
SFLNRM: SKIPN T2 ;P2=EXPONENT. T2--T3 ARE FRACTION
JUMPE T3,SFLSTR ;JUMP IF RESULT IS ZERO. STORE RESULT
SKIPL T2 ;POSTNORMALIZE BY SHIFTING LEFT
SKIPA T1,[TLNE T2,400];SKIP IF POSITIVE NUMBER IS UNNORMALIZED
MOVE T1,[TLNN T2,400];SKIP IF NEGATIVE NUMBER IS UNNORMALIZED
TDNE T2,[777,,-1] ;SKIP IF NO SIGNIFICANCE
JRST SFLNR2
ASHC T2,-1 ;GET THAT BIT BACK
ADDI P2,1
SFLNR2: XCT T1 ;SKIP IF UNNORMALIZED
JRST SFLNR3 ;NORMALIZE COMPLETE
ASHC T2,1 ;SHIFT TO NORMALIZE
SOJA P2,SFLNR2 ;DECREMENT EXPONENT. LOOP UNTIL DONE
;HERE WE KNOW THAT THE RESULT IS DEFINITELY NON-ZERO. BUT THE ABOVE
; LOOP WILL GO TOO FAR IF THE NUMBER IS NEGATIVE AND HAS JUST ONE
; SIGNIFICANT BIT. THIS CODE DOWN TO SFLNR9 PUTS IT BACK.
SFLNR3: TDNE T2,[777,,-1] ;DID WE ASHC THE SIGNIFICANT BIT TOO FAR?
JRST SFLNR9 ;NO, WE'RE OK.
JOV SFLNR7 ;DID WE LOSE A BIT IN THE EXPONENT?
ASHC T2,-1 ;SHIFT BACK (CASE OF NEGATIVE EXPONENT)
JRST SFLNR8
SFLNR7: ASHC T2,-1 ;SHIFT BACK (CASE OF POSITIVE EXPONENT)
TLZ T2,200000 ; (REQUIRES ZEROING THIS BIT)
SFLNR8: AOS P2 ;FIX THE EXPONENT AS STORED IN P2
SFLNR9: TLZ T3,400000 ;CLEAR SIGN BIT OF LOW WORD
LSH T3,-10 ;LEAVE ROOM IN LOW WORD FOR EXPONENT
CAIGE P2,400 ;SKIP IF OVERFLOW
JUMPGE P2,SFLNR6 ;JUMP UNLESS UNDERFLOW
MOVSI T1,440200 ;AROV, FOV, TRAP 1
CAIL P2,433 ;DOES EXPONENT EXCEED 128+27?
JRST SFLNR4 ;YES. STORE ZERO IN LOW WORD
JUMPG P2,SFLNR5
TRNE P2,200 ;SOMETIMES THE KA10 FORGETS AN UNDERFLOW
TLO T1,100 ;SET FLOATING UNDERFLOW TOO.
SFLNR4: MOVEI T3,0 ;AND CLEAR LOW WORD.
SFLNR5: IORM T1,.JDAT+JOBPD1## ;STORE FLAGS FOR USER.
SFLNR6: HRREI P3,-33(P2) ;COMPUTE EXPONENT OF LOW PART
SKIPGE P3
MOVEI T3,0 ;ZERO LOW PART, IF EXPONENT TOO SMALL
ANDI P2,377 ;TRUNCATE EXPONENT
SKIPE T3 ;SKIP IF LOW FRACTION IS ZERO
DPB P3,[POINT 9,T3,8] ;STORE LOW EXPONENT. CLEAR SIGN BIT.
ROT P2,-11 ;SHIFT EXPONENT TO RIGHT PLACE
XOR T2,P2 ;ONES COMPLEMENT OF EXP, IF NEGATIVE
SFLSTR: EXCTUX <MOVEM T2,(P1)> ;STORE DOUBLEWORD RESULT IN C(AC)
STORA1: ADDI P1,1 ;AND IN C(AC+1 MOD 20)
ANDI P1,17
EXCTXU <MOVEM T3,(P1)>
POPJ P,
SFMPL: PUSHJ P,SAVE3##
PUSHJ P,SFLGET ;FETCH AND PREPARE ARGUMENTS
MUL T2,P3 ;DOUBLE WORD PRODUCT TO T2/T3
ADD P2,T1 ;P2=EXPONENT OF RESULT
SUBI P2,200 ;ACCOUNT FOR EXCESS 200 IN EXPONENTS
ASHC T2,10 ;RESULT OF MULTIPLY IS TOO FAR RIGHT BY 8
;PLACES (NOT 9 SINCE BIT 0 OF T3 IS SIGN)
TLZ T3,400000 ;FLUSH SIGNBIT
JRST SFLNRM ;DO POSTNORMALIZE
SFDVL: PUSHJ P,SAVE3##
LDB P1,PUUOAC## ;GET AC FIELD OF INSTR
EXCTUX <MOVE T2,(P1)> ;FETCH C(AC)
MOVEI T3,1(P1)
ANDI T3,17
EXCTUX <MOVE T3,(T3)> ;FETCH C(AC+1)
SKIPN T2 ;IF DIVIDING ZERO
JUMPE T3,SFLSTR ; WITHOUT FURTHER ADO, STORE ZERO
PUSHJ P,GETWDU## ;FETCH C(E).
MOVE P3,T1 ;TO P3
LSH T3,10 ;FLUSH EXPONENT FROM LOW WORD
TLZ T3,400000 ;FLUSH SIGNBIT FROM LOW WORD
PUSHJ P,SFLGT2 ;SETUP EXPONENTS, ETC
MOVEI T4,0 ;ASSUME BOTH ARGUMENTS ARE POSITIVE
JUMPGE T2,SFDVL2 ;JUMP IF DIVIDEND IS POSITIVE
SETCA T2, ;DIVIDEND IS NEGATIVE. TAKE TWOS COMPLEMENT
MOVN T3,T3 ;OF THE DOUBLE WORD (THIS SHOULD BE DMOVN
SKIPN T3 ;EXCEPT, WE HAVE TO RUN THIS ON THE KA10 TO
ADDI T2,1 ;VERIFY IT).
MOVSI T4,600000 ;QUOTIENT AND REMAINDER ARE NEGATIVE
SFDVL2: JUMPGE P3,SFDVL3 ;JUMP IF DIVISOR IS POSITIVE
MOVN P3,P3
TLC T4,400000 ;COMPLEMENT SIGN OF QUOTIENT
SFDVL3: CAMGE T2,P3 ;IS QUOTIENT GREATER THAN 1.0?
JRST SFDVL4 ;NO.
ASHC T2,-1 ;YES. TRY A 1 BIT SHIFT
CAML T2,P3 ;DID THAT FIX IT?
JRST SFDVLX ;NO. WE HAVE A NO-DIVIDE CONDITION
ADDI T1,1 ;ADJUST EXPONENT OF DIVIDEND
SFDVL4: TLNN P3,1000 ;ONLY CRETINS DIVIDE BY "SETZ"
JRST SFDVL6
LSH P3,-1 ;BUT TO KEEP THEM HAPPY...
ADDI P2,1
SFDVL6: SUBM T1,P2 ;P2=EXPONENT OF QUOTIENT
ADDI P2,200 ;MAKE EXPONENT INTO EXCESS 200.
LSH P3,10 ;SCALE DIVISOR TO ALLOW ONLY 27 DIVIDE STEPS
DIV T2,P3 ;T2=QUOTIENT, T3=REMAINDER
JUMPE T2,SFDVL9 ;IF QUOTIENT IS ZERO, DON'T NORMALIZE
TLNN T2,1000 ;SAME REMARK ABOUT CRETINS
JRST SFDVL8
ASHC T2,-1 ;KA, KI, AND THE KL DON'T AGREE ON WHAT
ADDI P2,1 ; THE ANSWER SHOULD BE BUT THIS GIVES KI RESULTS
SFDVL8: TLNE T2,400 ;NOW, NORMALIZE THE QUOTIENT
JRST SFDVL9
LSH T2,1 ;BEFORE COMPUTING OVERFLOW CONDITION
SOJA P2,SFDVL8
SFDVL9: CAIGE P2,400 ;OVERFLOW?
JUMPGE P2,SFDVL7 ;NO. JUMP UNLESS UNDERFLOW
MOVSI P3,440200 ;AROV, FOV, TRAP 1
JUMPGE P2,SFDVL5
TRNE P2,200 ;SOMETIMES THE KA10 FORGETS FXU
TLO P3,100 ;FXU
SFDVL5: IORM P3,.JDAT+JOBPD1##
ANDI P2,377
SFDVL7: SKIPE T2 ;AVOID STORING EXPONENT IN A ZERO FRACTION
DPB P2,[POINT 9,T2,8] ;STUFF EXPONENT
TLNE T4,400000 ;SHOULD QUOTIENT BE NEGATIVE?
MOVN T2,T2 ;YES.
SUBI T1,33 ;CALCULATE EXPONENT OF REMAINDER
SKIPGE T1 ;IF UNDERFLOW, SET REMAINDER TO ZERO
MOVEI T3,0
JUMPE T3,SFLSTR ;IF ZERO REMAINDER, STORE ZERO
LSH T3,-10 ;MAKE ROOM FOR EXPONENT
DPB T1,[POINT 8,T3,8] ;STUFF EXPONENT
TLNE T4,200000 ;SHOULD WE NEGATE REMAINDER?
MOVN T3,T3
JRST SFLSTR ;STORE AC, AC+1
SFDVLX: MOVSI T3,440240 ;AROV, FOV, NO DIVIDE, TRAP1
IORM T3,.JDAT+JOBPD1##
POPJ P,
END