Google
 

Trailing-Edge - PDP-10 Archives - BB-4170G-SM - sources/mflin.mac
There are 48 other files named mflin.mac in the archive. Click here to see a list.
;<3-MONITOR>MFLIN.MAC.25,  7-Nov-77 13:04:05, EDIT BY KIRSCHEN
;MORE COPYRIGHT UPDATING...
;<3-MONITOR>MFLIN.MAC.24, 12-Oct-77 13:59:14, EDIT BY KIRSCHEN
;UPDATE COPYRIGHT FOR RELEASE 3
;<3-MONITOR>MFLIN.MAC.23,  2-May-77 21:37:42, EDIT BY BOSACK
;<3-MONITOR>MFLIN.MAC.22, 23-Jan-77 15:06:17, Edit by MCLEAN
;<3-MONITOR>MFLIN.MAC.21,  3-Jan-77 13:10:23, Edit by MCLEAN
;<3-MONITOR>MFLIN.MAC.20, 27-Dec-76 17:34:47, EDIT BY HURLEY
;<3-MONITOR>MFLIN.MAC.19, 18-Dec-76 03:43:06, Edit by MCLEAN
;<3-MONITOR>MFLIN.MAC.18, 26-Nov-76 02:28:54, Edit by MCLEAN
;<MCLEAN>MFLIN.MAC.4, 21-Sep-76 16:38:09, Edit by MCLEAN
;<MCLEAN>MFLIN.MAC.3, 21-Sep-76 16:37:03, Edit by MCLEAN
;<MCLEAN>MFLIN.MAC.2, 29-Jul-76 13:38:27, Edit by MCLEAN
;<2-MONITOR>MFLIN.MAC.16,  6-Oct-76 08:38:57, EDIT BY HURLEY
;<2MONITOR>MFLIN.MAC.15, 19-JAN-76 12:20:28, EDIT BY MURPHY
;<2MONITOR>MFLIN.MAC.14, 23-DEC-75 12:51:58, EDIT BY LEWINE


;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 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SEARCH PROLOG,MONSYM,MACSYM
	TTITLE FLIN
	SALL
	SWAPCD

;SINGLE AND DOUBLE PRECISION FLOATING INPUT ROUTINES

	IFNDEF MONFLG,<MONFLG==1>

	INTERN .FLIN,.DFIN

	EXTERN EDFAD.,EDFMP.,GETEXP,PUTEXP
	EXTERN MENT0,MRETN
	EXTERN BIN1

;FLIN IS ASSEMBLED FOR MONITOR OR USER DEPENDING ON STATE
; OF MONFLG, 1 FOR MONITOR

;.FLIN IS CALLED BY:
;      PUSHJ P,.FLIN
;	ERROR RETURN
;      NORMAL RETURN

;0 CANNOT BE CHANGED

A=12
B=14
W=1				;SAVED CHAR PTR
CH=3				;CHARACTER UNDER TEST
D=4
DIG=5
F=6
CHP=7				;CHARACTER POINTER
TEN=10				;USED ONCE (?)

M=10				;MEMORY OPERAND POINTER FOR EDFMP.
T=10				;T+1 ALSO USED
AC=12				;AC+1 ALSO USED

P=17				;CONTROL PUSHDOWN

;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

;MACRO TO LOAD A CHARACTER INTO 1ST ARG USING CHAR PTR IN 2ND ARG
;CHAR PTR IS NUMBER OF CHARACTERS FROM BEG OF CORE. CLOBBERS 2,3.

	DEFINE LCH
<	PUSHJ P,LCH1>
;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:	PUSHJ P,GETCH		;GET ANOTHER CHARACTER
	SOJA CHP,OVTILC		;SPECIAL CHARACTER BEFORE DIGIT
				;UNSTEP CHAR PTR, GIVE RETURN 1.
				;SPECIAL CHARACTER AFTER DIGIT SKIPS INTO MPSCHA

;SPECIAL CHARACTER AFTER A MANTISSA DIGIT

MSPCHA:	MOVE W,CHP		;SAVE IR7
	CAIN CH,"E"		;ASCII "E"?
	JRST LFEL		;YES, LOOK FOR EXPONENT
	CAIN CH,"D"
	JRST LFEL		;D PREFIX TO EXPONENT OK TOO
				;CAIE CH,"*"		;ASCII "*"?

; *10^ EXPONENT FEATURE DISABLED 7/1/69 BECAUSE EXPRESSIONS SUCH AS
;  "2/3*10^4" WERE EVALUATED WRONG.

				;JRST SPLASH		;NO, ILLEGAL CHARACTER...END INPUT
				;LCH		;GET NEXT CHARACTER
				;CAIE CH,"1"		;ASCII "1"?
				;JRST LFEI		;NO ILLEGAL CHARACTER...END INPUT
				;LCH		;GET NEXT CHARACTER
				;CAIE CH,"0"		;ASCII "0"?
				;JRST LFEI		;NO ILLEGAL CHARACTER...END INPUT
				;LCH		;GET NEXT CHARACTER
				; CAIN CH,"^"		;ASCII "^"?
				;JRST LFEL		;YES, LOOK FOR EXPONENT
LFEI:	MOVE CHP,W		;RESTORE IR7
	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:	PUSHJ P,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,SIGN		;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
	SUBI D,^D27		;TO OBTAIN LOW ORDER EXP.
	LSH AC+1,-10		;MAKE ROOM FOR LO ORDER EXP.
	DPB D,[POINT 9,AC+1,8]	;DEPOSIT EXP. IN LOW ORDER WORD
	FADL AC,AC+1		;NORMALIZE RESULTS
	TLNE F,FLMSGN		;SHOULD ANS BE NEGATIVE?
	DFN AC,AC+1		;YES, NEGATE RESULTS
	JUMPG DIG,POSMUL	;DEC EXP IS +
NEGMUL:	MOVNS DIG		;DEC EXP IS -, MAKE IT +
	MOVEI F,TAB.M1		;BASE ADR FOR NEG EXP TABLE
	SKIPA			;GO STORE IT
POSMUL:	MOVEI F,TAB.P1		;BASE ADR FOR POS EXP TABLE
MULOOP:	MOVEI M,0(F)		;TABLE PICKUP
	TRZE DIG,1		;MULTIPLY THIS TIME?
	PUSHJ P,EDFMP.		;YES, GO EAT TIME C(AC,AC+1)*C(C(M),"+1).
	JUMPE DIG,OVT		;JUMP IF NO MORE MULTIPLY
	ASH DIG,-1		;LOOK AT NEXT BIT
	ADDI F,2		;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
	POPJ P,
NOTNUM:	MOVEI D,FLINX1
	JRST OUT
ILLNUM:	MOVEI D,FLINX4
	JRST OUT
TOOBIG:	MOVEI D,FLINX3
	MOVE AC,[377777777777]
	MOVE AC+1,[344777777777]
	TLNE F,FLMSGN
	DFN AC,AC+1
	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
.DFIN:	IFG MONFLG,<MCENT	>
	PUSHJ P,DIRT.
	JRST DFINX
	AOS -1(P)
.DFIN1:	IFG MONFLG,<
	UMOVEM 2,2
	UMOVEM 3,3
	JRST MRETN>
	IFLE MONFLG,<
	POPJ P,>
DFINX:	IFG MONFLG,<
	UMOVEM D,4>
	JRST .DFIN1

.FLIN:	IFG MONFLG,<MCENT	>
	PUSHJ P,DIRT.
	JRST FLINX
	TLNE 3,400000
	JRST FLINXX		;NUMBER OUT OF RANGE
FLINXG:	SKIPN A
	JRST FLING
	SKIPG A
	DFN 2,3
	TLNN 3,400		;SEE IF ROUNDING NECESSARY
	JRST NORND		;NO
	PUSHJ P,GETEXP		;DO A DOUBLE PRECISION EXTENDED ROUND
	SUBI B,^D27
	SKIPG A
	DFN 2,3
	SETZ A+1
	HRLZI A,400
	PUSHJ P,PUTEXP
	MOVEI M,2
	PUSHJ P,EDFAD.
	MOVE 2,A
	MOVE 3,A+1
	TLNN A,377000
	JRST FLINXR		;SUPER BAD, NUMBER OUT OF RANGE AFTER ROUNDING
FLING:	AOS -1(P)
.FLIN1:	IFG MONFLG,<
	UMOVEM 2,2
	JRST MRETN>
	IFLE MONFLG,<
	POPJ P,>
FLINX:	IFG MONFLG,<
	UMOVEM D,3>
	JRST .FLIN1
NORND:	SETZ 3,			;FOR PROPER ROUNDING
	SKIPG A
	DFN 2,3
	JRST FLING		;NORMAL RETURN
FLINXX:	TLNN A+1,377000		;ANY EXP BITS ON IN WORD 2?
	JRST FLINXG		;NO, UNNECESSARY EXTENSION
FLINXR:	PUSHJ P,GETEXP
	JUMPGE B,FLINXB
	SETZ 2,
	MOVEI D,FLINX2
	JRST FLINX
FLINXB:	MOVEI D,FLINX3
	MOVE 2,[377777777777]
	TLNE A,400000
	MOVE 2,[400000000000]
	JRST FLINX
;GET A CHARACTER AND EXAMINE IT

GETCH:	LCH			;GET NEXT CHARACTER
	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"		;...
	POPJ P,			;NO, RETURN 1,4 OR 2,4
BLNK0:	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 14,F		;FIX EXTENDED ADDRESSING PROBLEM
	XCT PJ(14)		;GO CONVERT DIGIT
	JRST GETCH		;GET ANOTHER CHARACTER

;DIGIT SEEN BEYOND MAXIMUM NUMBER THAT PRECISION WILL HANDLE

EXDIG:				;JUMPN X,GETCH		;IGNORE EXTRA DIGITS IN EXPONENT
				;4/15/69:	CANT HAPPEN IN EXPONENT
	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 14,F
	TLNN F,FLDIG		;DIGIT SEEN?
	XCT BLNO(14)		;NO
	POPJ P,			;ILC

;PERIOD SEEN

PERIN:	HRRZ 14,F
	XCT TLO(14)		;FIRST PERIOD SEEN?
	JRST GETCH		;YES, GET ANOTHER CHARACTER
CPOPJ:	POPJ P,			;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?
	POPJ P,			;PERIOD ILLEGAL IN EXPONENT

PJ:	PUSHJ P,MADD		;MANTISSA ADD IN CHARACTER
	PUSHJ P,XADD		;EXPONENT ADD IN CHARACTER

BLNO:	JRST GETCH		;IGNORE BLANK IN MANTISSA
	POPJ P,			;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)
	POPJ P,			;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?
	POPJ P,			;NO, RETURN
	AOJG AC+1,CPOPJ		;CARRY SUCCESSFUL IF NO OVERFLOW INTO SIGN
	AOS AC			;KEEP TRYING
	TLNN AC,-1		;OVERFLOW?
	POPJ P,			;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
	CAIG T,^D99		;BIGGER THAN TENEX LIMIT?
	POPJ P,			;NO, RETURN
	SUB P,BHC+2		;YES, GREATER THAN 99,
	MOVEI TEN,-1(CHP)	;10 IS TEXT PTR USED BY ERROR ROUTINE
	TLNN F,FLXSGN
	JRST TOOBIG		;...GIVE IMMEDIATE ERROR RETURN
TOOSML:	MOVEI D,FLINX2
	SETZB AC,AC+1
	JRST OUT

	IFLE MONFLG,<
LCH1:	PUSH P,1
	PBIN
	MOVEM 1,CH
	POP P,1
	POPJ P,>

IFG MONFLG,<
LCH1:	PUSH P,1
	UMOVE 1,1		;SOURCE DESIG'RET GOES IN 1
	EXCH 2,CH		;CHARACTER WILL BE RETURNED IN 2
	PUSHJ P,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
	POPJ P,
>


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

TAB.M1:	OCT 175631463146	;1.0E-1
	OCT 142314631463	;...
	OCT 172507534121,137727024365 ;1.0E-2
	OCT 163643334272,130616103131 ;1.0E-4
	OCT 146527461670,113430214163 ;1.0E-8
	OCT 113715126245,060754211570 ;1.0E-16
	OCT 026637304365,400324247140 ;1.0E-32
	OCT 254520777521,777172247164 ;1.0E-64
				;OCT 327673501063,776706227450		;1.0E-128
				;OCT 056600305031,775126157140		;1.0E-256

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,233760200000 ;1.0E+16
	OCT 353473426555,320202556050 ;1.0E+32
	OCT 125604740372,401237771734 ;1.0E+64
				;OCT 52447351076,402230235124		;1.0E+128
				;OCT 323524773537,403671677120		;1.0E+256

	END