Google
 

Trailing-Edge - PDP-10 Archives - BB-Y393Q-SM - monitor-sources/mflin.mac
There are 48 other files named mflin.mac in the archive. Click here to see a list.
; UPD ID= 73, FARK:<4-1-WORKING-SOURCES.MONITOR>MFLIN.MAC.4,  26-Apr-82 12:55:27 by ZIMA
;Edit 2613 - Fix returning wrong values from overflowed exponent.
; UPD ID= 70, FARK:<4-1-WORKING-SOURCES.MONITOR>MFLIN.MAC.3,  22-Apr-82 16:16:32 by ZIMA
;Edit 2611 - fix FLIN/DFIN reporting undeflow as overflow.
; UPD ID= 4, FARK:<4-1-WORKING-SOURCES.MONITOR>MFLIN.MAC.2,  10-Mar-82 16:43:00 by ZIMA
;EDIT 2001 - Change TITLE for Autopatch consistency.
;<4-1-FIELD-IMAGE.MONITOR>MFLIN.MAC.2, 25-Feb-82 20:30:26, EDIT BY DONAHUE
;UPDATE COPYRIGHT DATE
; UPD ID= 166, FARK:<4-WORKING-SOURCES.MONITOR>MFLIN.MAC.3,  28-Aug-80 14:35:16 by ZIMA
;Edit 1772 - put 1737 into standard form, no code changes.
; UPD ID= 64, FARK:<4-WORKING-SOURCES.MONITOR>MFLIN.MAC.2,  11-Jun-80 11:51:11 by SCHMITT
;Edit 1737 - Allow lowercase E for FLIN JSYS
;<4.MONITOR>MFLIN.MAC.8,  3-Jan-80 08:09:35, EDIT BY R.ACE
;UPDATE COPYRIGHT DATE
;<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


;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,1978,1979,1980,1981,1982 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SEARCH PROLOG,MONSYM,MACSYM
;**;[2001] Change one line at SEARCH PROLOG, +1L	JGZ	10-MAR-82
	TTITLE MFLIN		;[2001] 
	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:	UMOVEM D,4		;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:	UMOVEM D,3		;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
;**;[1772] Change 3 [1737] lines at MMORE: +2L	JGZ	28-AUG-80
;**;[1737] Replace 1 line with following two at MMORE: +2L  RAS  11-JUN-80
	CAIE CH,"E"		;[1737] ASCII "E"?
	CAIN CH,"e"		;[1737]  or lowercase e
	JRST LFEL		;YES, LOOK FOR EXPONENT
	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
;**;[2611] Change 1 line at SIGN0: +2L	JGZ	12-APR-82
	JUMPG DIG,[MOVEI T1,TAB.P1 ;[2611] DECIMAL EXP IS +
		JRST MULL]
	MOVNS DIG		;DEC EXP IS -, MAKE IT +
;**;[2611] Change one line at SIGN0: +5L	JGZ	12-APR-82
	MOVEI T1,TAB.M1		;[2611] DECIMAL EXP IS NEG
MULL:	JFOV .+1		;READY TO CHECK FOR OVS
;**;[2613] Add 2 lines at MULL: +1L	JGZ	26-APR-82
	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?
;**;[2611] Change 1 line at MULOOP: +1L	JGZ	12-APR-82
	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
;**;[2611] Change 1 line at MULOOP: +5L	JGZ	12-APR-82
	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