Google
 

Trailing-Edge - PDP-10 Archives - BB-M081Z-SM - monitor-sources/mflin.mac
There are 48 other files named mflin.mac in the archive. Click here to see a list.
; UPD ID= 8552, RIP:<7.MONITOR>MFLIN.MAC.3,  11-Feb-88 11:03:02 by GSCOTT
;TCO 7.1218 - Update copyright date.
; UPD ID= 2121, SNARK:<6.1.MONITOR>MFLIN.MAC.8,   5-Jun-85 09:56:57 by MCCOLLUM
;TCO 6.1.1406  - Update copyright notice.
; UPD ID= 4814, SNARK:<6.MONITOR>MFLIN.MAC.7,  17-Sep-84 10:13:48 by PURRETTA
;Update copyright notice
; UPD ID= 1843, SNARK:<6.MONITOR>MFLIN.MAC.6,  20-Feb-83 22:18:02 by MURPHY
;TCO 6.1514 - No error code in AC if ERJMP/ERCAL.
; UPD ID= 1554, SNARK:<6.MONITOR>MFLIN.MAC.5,  21-Dec-82 11:13:11 by MAYO
;Edit 2613 - Fix returning wrong values from overflowed exponent.
; UPD ID= 1552, SNARK:<6.MONITOR>MFLIN.MAC.4,  21-Dec-82 11:03:56 by MAYO
;Edit 2611 - fix FLIN/DFIN reporting undeflow as overflow.
; UPD ID= 104, SNARK:<5.MONITOR>MFLIN.MAC.3,  17-Aug-81 11:20:49 by ZIMA
;TCO 5.1458 - Change title for Autopatch consistency.
; UPD ID= 788, SNARK:<5.MONITOR>MFLIN.MAC.2,  23-Jul-80 16:54:15 by R.ACE
; Do the rest of TCO 4.1.1068... accept "d" too
; UPD ID= 205, SNARK:<4.1.MONITOR>MFLIN.MAC.8,  16-Jan-80 16:07:36 by SCHMITT
; TCO 4.1.1068 - ALLOW LOWER CASE E BE VALID FOR EXPONENT DESIGNATOR
;<4.MONITOR>MFLIN.MAC.7, 28-Oct-79 21:34:39, EDIT BY MURPHY
;MAKE 0 BE REALLY 0
;<4.MONITOR>MFLIN.MAC.6, 27-Sep-79 12:31:43, EDIT BY MURPHY
;<4.MONITOR>MFLIN.MAC.5, 26-Sep-79 23:12:24, EDIT BY MURPHY
;ELIMINATE USE OF FUNNY FORMAT EXTENDED RANGE DOUBLE PRECISION
;FLOATING POINT NUMBERS - USE DOUBLE PRECISION MACHINE INSTRUCTIONS
;FOR ARITHMETIC
;<4.MONITOR>MFLIN.MAC.4, 13-Sep-79 06:47:20, EDIT BY R.ACE
;TAKE OUT EXTERN'S TO GET CHECKSUMS RIGHT ON .REL FILES
;<4.MONITOR>MFLIN.MAC.3,  1-Jun-79 17:13:50, Edit by LCAMPBELL
; Suppress some symbols which are annoying in DDT
;<4.MONITOR>MFLIN.MAC.2,  3-Apr-79 14:02:45, EDIT BY ZIMA
;TCO 4.2225 - Make FLIN and DFIN recognize ERJMP/ERCAL on errors.
;<4.MONITOR>MFLIN.MAC.1,  4-Mar-79 18:29:43, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4

;	COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1976, 1988.
;	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 THAT IS NOT SUPPLIED BY DIGITAL.
	SEARCH PROLOG,MONSYM,MACSYM
	TTITLE MFLIN
	SALL
	SWAPCD

;SINGLE AND DOUBLE PRECISION FLOATING INPUT ROUTINES

	INTERN .FLIN,.DFIN

CH==3				;CHARACTER UNDER TEST
D==4
DIG==5
F==6
T==10				;T+1 ALSO USED
AC==12				;AC+1 ALSO USED

;FLAGS IN LEFT HALF OF AC F

FLDIG==1			;ON - DIGIT SEEN
FLPER==2			;ON - PERIOD SEEN
FLIGN==4			;ON - IGNORE SUBSEQUENT DIGITS
FLMSGN==10			;ON - MANTISSA IS NEGATIVE
FLXSGN==20			;ON - EXPONENT IS NEGATIVE
FLSGN==40			;ON - PLUS OR MINUS SEEN

;EXPONENT INDICATOR IN B35 OF F IS USED AS INDEX, MUST BE ONLY BIT IN RH
;JSYS ENTRY POINTS

.DFIN:	MCENT
	CALL DIRT.
	 JRST DFINX
	UMOVEM 2,2
	UMOVEM 3,3
	SMRETN

DFINX:	CALL TSTERJ		;ERJMP/ERCAL PRESENT?
	 UMOVEM D,4		;NO, RETURN ERROR CODE TO USER AC4
	UMOVEM 2,2		; WITH "RESULTS"
	UMOVEM 3,3
	MOVE 1,D		;ERROR CODE TO AC1
	EMRETN			;ERROR RETURN PROPERLY

.FLIN:	MCENT
	CALL DIRT.
	 JRST FLINX

;CONVERT DOUBLE PRECISION TO SINGLE PRECISION AND RETURN IT

	JUMPL T2,[DMOVN T2,T2 ;HANDLE NEG CASE
		TXNE T3,1B1
		TXON T2,1B35
		JRST [	MOVN T2,T2
			JRST FLING]
		MOVN T3,T2
		ORCA T2,[000777777777]
		FADR T2,T3
		JRST FLING]
	TXNE T3,1B1		;LOW WORD GE .5 ?
	TXON T2,1B35		;YES, TRY FOR QUICK ROUNDING
	JRST FLING		;DONE
	MOVE T3,T2		;CAN'T ROUND QUICKLY, DO LONG WAY
	ANDX T3,<777000000001>	;EXTRACT EXPONENT AND LOW ORDER ONE
	FADR T2,T3		;ADD IT
FLING:	UMOVEM 2,2
	SMRETN

FLINX:	CALL TSTERJ		;ERJMP/ERCAL PRESENT?
	 UMOVEM D,3		;NO, RETURN ERROR CODE IN USER AC3
	UMOVEM 2,2		; AND "RESULTS" TO USER
	MOVE 1,D		;ERROR CODE TO AC1
	EMRETN			;ERROR RETURN PROPERLY
;DOUBLE PRECISION INPUT ROUTINE

DIRT.:	SETZ F,			;FLAGS AND EXPONENT INDICATOR
	SETZB AC,AC+1		;CHAR BY CHAR ASSEMBLY
	SETZ DIG,		;DIGIT COUNTER
	MOVEI D,276		;PRESUMED EXPONENT

;PROCESS MANTISSA

MMORE:	CALL GETCH		;GET ANOTHER CHARACTER
	 JRST OVTILC		;NON-DIGIT SEEN BEFORE DIGIT
	CAIE CH,"e"		; IS IT A LOWERCASE E
	CAIN CH,"E"		;ASCII "E"?
	JRST LFEL		;YES, LOOK FOR EXPONENT
	CAIE CH,"d"		;ASCII "d"?
	CAIN CH,"D"
	JRST LFEL		;D PREFIX TO EXPONENT OK TOO
LFEI:	JRST SPLASH		;ILLEGAL CHARACTER FOUND...END INPUT

;PROCESS EXPONENT

LFEL:	TLZ F,FLIGN!FLDIG!FLSGN	;RESET GETCH FLAGS AND "SIGN SEEN" FLAG
	TRO F,1			;INDICATE EXPONENT
	MOVEI T,0		;INITIAL EXPONENT = 0
XMORE:	CALL GETCH		;GET THE NEXT CHARACTER
	 JRST XSPCHI		;SPECIAL CHARACTER BEFORE DIGIT
				;SPEC CHAR AFTER DIGIT GOES SPLASH.
	; ..
;COMPLETE PROCESSING OF FLOATING POINT NUMBER

	; ..
SPLASH:	TRNN F,1		;WAS EXPONENT SEEN?
	JRST NORMAL		;NO.
	TLNE F,FLXSGN		;SHOULD EXP BE NEGATIVE?
	MOVNS T			;YES, MAKE IT SO
	ADD DIG,T		;COMBINE WITH DIGIT COUNT
NORMAL:	JUMPN AC,GOOF		;HI MANTISSA = 0?
	JUMPE AC+1,SIGN0		;YES, REST = 0?
GOOF:	TLNE AC,400		;NO, BIT 9 = 1?
	JRST SIGN		;YES, DONE
	ASHC AC,1		;LEFT MARCH
	SOJA D,GOOF		;MINUS ONE THE EXP

SIGN:	DPB D,[POINT 9,AC,8]	;DEPOSIT EXP. IN HI ORDER WORD
SIGN0:	TLNE F,FLMSGN		;SHOULD ANS BE NEGATIVE?
	DMOVN AC,AC		;YES
	JUMPG DIG,[MOVEI T1,TAB.P1 ;[2611] DECIMAL EXP IS +
		JRST MULL]
	MOVNS DIG		;DEC EXP IS -, MAKE IT +
	MOVEI T1,TAB.M1		;[2611] DECIMAL EXP IS NEG
MULL:	JFOV .+1		;READY TO CHECK FOR OVS
	CAIL DIG,1B<35-MXEXP>	;[2613] OUT OF TABLE RANGE?
	MOVEI DIG,1B<35-MXEXP>-1 ;[2613] YES, SET TO LIMIT
MULOOP:	TRZE DIG,1		;MULTIPLY THIS TIME?
	DFMP AC,0(T1)		;[2611] YES
	JFOV EXPOV		;JUMP IF OUT OF RANGE
	JUMPE DIG,OVT		;JUMP IF NO MORE MULTIPLY
	ASH DIG,-1		;LOOK AT NEXT BIT
	ADDI T1,2		;[2611] NEXT ENTRY IN TABLE
	JRST MULOOP		;LOOK FOR NEXT MULTIPLY


;SPECIAL CHARACTER BEFORE 1ST EXPONENT DIGIT

XSPCHI:	TLOE F,FLSGN		;HAS A SIGN BEEN ENCOUNTERED?
	JRST LFEI		;YES, ADDITIONAL SIGNS ILLEGAL
	CAIN CH,"+"		;ASCII "+"?
	JRST XMORE		;IGNORE
	CAIN CH," "		;ASCII " "?
	JRST XMORE		;IGNORE
	CAIN CH,"-"		;ASCII "-"?
	TLOE F,FLXSGN		;INDICATE FIRST AND ONLY MINUS
	JRST LFEI		;NOT SIGN
	JRST XMORE		;GET MORE EXPONENT
;RETURN TO MAIN PROGRAM

OVT:	AOS (P)			;NORMAL RETURN 3,4
OUT:	MOVE 2,AC		;RETURN ANSWER IN 2&3
	MOVE 3,AC+1
	RET

NOTNUM:	MOVEI D,FLINX1
	JRST OUT

ILLNUM:	MOVEI D,FLINX4
	JRST OUT

EXPOV:	TLNN F,FLXSGN		;EXP NEGATIVE?
	JRST TOOBIG		;POSITIVE - MEANS TOO LARGE
	SETZB AC,AC+1		;TOO SMALL, RETURN 0
	MOVEI D,FLINX2
	JRST OUT

TOOBIG:	MOVEI D,FLINX3
	MOVE AC,[377777777777]
	MOVE AC+1,[377777777777]
	TLNE F,FLMSGN
	DMOVN AC,AC
	JRST OUT

OVTILC:	CAIN CH,"+"		;PLUS IN MANTISSA FIELD
	JRST MMORE
	CAIE CH,"-"		;CHECK FOR MINUS IN MANTISSA FIELD
	JRST NOTNUM
	TLOE F,FLMSGN		;ONLY ONE ALLOWED
	JRST ILLNUM		;ELSE ILLFORMED NUMBER
	JRST MMORE
;GET A CHARACTER AND EXAMINE IT

GETCH:	CALL LCH1
	CAIE CH,.CHTAB		;TAB?
	CAIN CH," "		;ASCII " "?
	JRST BLNKIN		;YES, PROCESS IT
	CAIN CH,"."		;ASCII "."?
	JRST PERIN		;YES, PROCESS IT
	CAIL CH,"0"		;DIGIT?
	CAILE CH,"9"		;...
	RET			;NO, RETURN 1,4 OR 2,4
	TLNE F,FLIGN		;IGNORE FLAG ON?
	JRST EXDIG		;YES
	TLON F,FLDIG		;DIGIT SEEN?
	AOS (P)			;NO, FIRST DIGIT
	SUBI CH,"0"		;CAN'T DO INDEXING ON AC0
	HRRZ P5,F		;FIX EXTENDED ADDRESSING PROBLEM
	XCT PJ(P5)		;GO CONVERT DIGIT
	JRST GETCH		;GET ANOTHER CHARACTER

;DIGIT SEEN BEYOND MAXIMUM NUMBER THAT PRECISION WILL HANDLE

EXDIG:	TLNE F,FLPER		;SKIP IF POINT NOT SEEN YET
	JRST GETCH
	AOJA DIG,GETCH		;INDEX EXPONENT FOR EXTRA DIGIT BEFORE POINT

;BLANK SEEN

BLNKIN:	HRRZ P5,F
	TLNN F,FLDIG		;DIGIT SEEN?
	XCT BLNO(P5)		;NO
	RET			;ILC

;PERIOD SEEN

PERIN:	HRRZ P5,F
	XCT TLO(P5)		;FIRST PERIOD SEEN?
	JRST GETCH		;YES, GET ANOTHER CHARACTER
CPOPJ:	RET			;ILC

;THE INSTRUCTION PAIRS BELOW CONSIST OF:
;      AN INSTRUCTION EXECUTED WHILE COMPILING THE MANTISSA
;      AN INSTRUCTION EXECUTED WHILE COMPILING THE EXPONENT

TLO:	TLON F,FLPER		;IS THIS FIRST PERIOD?
	RET			;PERIOD ILLEGAL IN EXPONENT

PJ:	CALL MADD		;MANTISSA ADD IN CHARACTER
	CALL XADD		;EXPONENT ADD IN CHARACTER

BLNO:	JRST GETCH		;IGNORE BLANK IN MANTISSA
	RET			;TREAT BLANK AS "+" IN EXPONENT
;ADD A CHARACTER TO THE MANTISSA

MADD:	TLNE F,FLPER		;PERIOD SEEN?
	SOS DIG			;YES, COUNT DIGIT AFTER PERIOD
	MOVE T,AC		;MULTIPLY Y BY 10.
	MOVE T+1,AC+1		;...
	ASHC AC,2		;AC=4*Y
	JCRY1 .+1		;AC=5*Y
	ADD AC+1,T+1		;...
	JCRY1 [AOJA AC,.+1]	;...
	ADD AC,T		;...
	ASHC AC,1		;AC=10.*Y
	JCRY1 .+1		;AC=10.*Y+CHAR
	ADD AC+1,CH		;...
	JCRY1 [AOJA AC,.+1]	;...
	TLNN AC,-1		;AC TOO BIG? (LEAVE 18 EXPONENT AND SIGN BITS)
	RET			;NO, RETURN
	TLO F,FLIGN		;YES, IGNORE FURTHER DIGITS
	AOS DIG			;ADJUST EXPONENT FOR SKIPPED DIGIT
	MOVE AC,T		;AC=Y
	MOVE AC+1,T+1		;...
	CAIGE CH,5		;ATTEMPT CARRY?
	RET			;NO, RETURN
	AOJG AC+1,CPOPJ		;CARRY SUCCESSFUL IF NO OVERFLOW INTO SIGN
	AOS AC			;KEEP TRYING
	TLNN AC,-1		;OVERFLOW?
	RET			;NO, SUCCESSFUL CARRY
	ASHC AC,-1		;AT ANY COST
	AOJA D,CPOPJ		;NOTIFY EXP
;ADD A CHARACTER TO THE EXPONENT

XADD:	IMULI T,^D10		;EXPONENT SO FOR *10
	ADD T,CH		;PLUS NEW DIGIT
	CAIL T,1B<35-MXEXP>	;OUT OF TABLE RANGE?
	MOVEI T,1B<35-MXEXP>-1	;YES, SET TO LIMIT
	RET

LCH1:	PUSH P,1
	UMOVE 1,1		;SOURCE DESIG'RET GOES IN 1
	EXCH 2,CH		;CHARACTER WILL BE RETURNED IN 2
	CALL BIN1		;BIN WITHOUT CHANGING CLLFMMON FLG
	MOVEI 2,0		;EOF SEEN
	EXCH 2,CH		;PUT CHAR IN CH, RESTORE 2
	POP P,1			;RESTORE 1
	RET


;TABMP -- TABLES FOR DOUBLE PRECISION PDP-10 INPUT CONVERSION

TAB.M1:	OCT 175631463146,146314631463	;1.0E-1
	OCT 172507534121,353412172702 ;1.0E-2
	OCT 163643334272,307041454512 ;1.0E-4
	OCT 146527461670,214106071676 ;1.0E-8
	OCT 113715126245,366104674123 ;1.0E-16
	OCT 026637304365,152123462450 ;1.0E-32
MXEXP==<.-TAB.M1>/2		;SIZE OF EXPONENT TABLE

TAB.P1:	OCT 204500000000,0	;1.0E+1
	OCT 207620000000,0	;1.0E+2
	OCT 216470400000,0	;1.0E+4
	OCT 233575360400,0	;1.0E+8
	OCT 266434157115,370100000000 ;1.0E+16
	OCT 353473426555,101267026547 ;1.0E+32
	END