Google
 

Trailing-Edge - PDP-10 Archives - tops20tools_v6_9-jan-86_dumper - tools/tvaxv2/gtvr05.mar
There are 7 other files named gtvr05.mar in the archive. Click here to see a list.
	.TITLE	GTVR05 - EVALUATE EXPRESSION IN INPUT
;	IN 	GSIADR(R11),GSILL(R11)
;
;	OUT	GEXP1 = RESULT VALUE FL4
;		GSIADR(R11),GSILL(R11) UPDATED
;
	INIT	GTVR05
	MOVL	GSIADR(R11),R6
	MOVAB	WCTAB,R8
	CLRB	WCSTAT(R8)		;INITIAL STATUS
	CLRL	WNB			;NR NESTED (
	BITB	#GXVAL,GSTAT
	IF.	*ON		;VALUE PREVIOUSLY SET
		BICB2	#GXVAL,GSTAT
		BISB2	#WCXVAL,WCSTAT(R8)
		MOVL	GEXP1,R7
	ENDIF.
L0:	CASEB	(R6),#32,#90
DE:	.WORD	D43X-DE		;SPACE = +
	.WORD	L3-DE		;33
	.WORD	L3-DE		;34
	.WORD	D35-DE		;#
	.WORD	L3-DE		;36
	.WORD	D37-DE		;%
	.WORD	D38-DE		;&
	.WORD	L3-DE		;39
	.WORD	D40-DE		;(
	.WORD	D41-DE		;)
	.WORD	D42-DE		;*
	.WORD	D43-DE		;+
	.WORD	D44-DE		; ,
	.WORD	D45-DE		;-
	.WORD	D46-DE		;.
	.WORD	D47-DE		;/
	.REPEAT	10
	.WORD	D48-DE		;0-9
	.ENDR
	.REPEAT	6
	.WORD	L3-DE		;58-63
	.ENDR
	.WORD	D64-DE		;@
	.WORD	L3-DE		;65
	.WORD	D66-DE		;B
	.REPEAT	5
	.WORD	L3-DE		;67-71
	.ENDR
	.WORD	D72-DE		; H
	.REPEAT	8
	.WORD	L3-DE		;72-80
	.ENDR
	.WORD	D81-DE		;Q
	.REPEAT	8
	.WORD	L3-DE		;82-89
	.ENDR
	.WORD	D90-DE		;Z
	.REPEAT	7
	.WORD	L3-DE		;91-97
	.ENDR
	.WORD	D66-DE		;b
	.REPEAT	5
	.WORD	L3-DE		;99-103
	.ENDR
	.WORD	D72-DE		; h
	.REPEAT	8
	.WORD	L3-DE		;105-112
	.ENDR
	.WORD	D81-DE		;q
	.REPEAT	8
	.WORD	L3-DE		;114-121
	.ENDR
	.WORD	D90-DE		;z
	BRW	L3
;
;
L1:				;OPERAND
	BITB	#WCXVAL,WCSTAT(R8)
	IF.	*ON		;2 * OPERAND IN ROW
		MOVW	#14,GERRN
		RET
	ENDIF.
	BITB	#WCXMIN,WCSTAT(R8)
	IF.	*ON		;UNARY - PRESENT
		MNEGL	R7,R7
		BICB2	#WCXMIN,WCSTAT(R8)
	ENDIF.
	BISB2	#WCXVAL,WCSTAT(R8)
	BITB	#WCXOPER,WCSTAT(R8)
	IF.	*ON		;OPERATOR SET
		BICB2	#WCXOPER,WCSTAT(R8)
		CASEB	WCOPER(R8),#0,#5
L1A:		.WORD	L100-L1A		;+
		.WORD	L101-L1A		;-
		.WORD	L102-L1A		;*
		.WORD	L103-L1A		;/
		.WORD	L104-L1A		;# OR
		.WORD	L105-L1A		;&
L100:		ADDL2	WCVAL(R8),R7
		BRW	L1X
L101:		SUBL3	R7,WCVAL(R8),R7		;-
		BRW	L1X
L102:		MULL2	WCVAL(R8),R7		;*
		BRW	L1X
L103:		TSTL	R7
		IF.	*EQ		;DIVIDE BY ZERO
			MOVW	#18,GERRN
			RET
		ENDIF.
		DIVL3	R7,WCVAL(R8),R7		;/
		BRW	L1X
L104:						;#
		BISL2	WCVAL(R8),R7
		BRW	L1X
L105:						;&
		MCOML	WCVAL(R8),R1
		BICL2	R1,R7
L1X:
	ENDIF.
	BRW	L2X
;
;
;
L2:	BITB	#WCXVAL,WCSTAT(R8)
	IF.	*OFF		;NO OPERAND PRESENT
		CMPB	R0,#1
		IF.	*EQ		;MINUS
			BISB2	#WCXMIN,WCSTAT(R8)
		ELSE.
			IF.	*GT	;NOT UNARY OPERATOR
				MOVW	#15,GERRN
				RET
			ENDIF.
		ENDIF.
	ELSE.			;OPERAND PRESENT
		BISB2	#WCXOPER,WCSTAT(R8)
		MOVL	R7,WCVAL(R8)		;SAVE OPERAND
		MOVB	R0,WCOPER(R8)
		BICB2	#WCXVAL,WCSTAT(R8)
	ENDIF.
L2X:	INCL	R6
	DECW	GSILL(R11)
	IF.	*LES		;NO MORE INPUT
		MOVW	#4,GERRN
		RET
	ENDIF.
	BICB2	#GXIN1,GSTAT		;TURN OFF IMM COMM
	BRW	L0
;
;
;
L3:	BICB2	#GXIN1,GSTAT
	MOVL	R6,GSIADR(R11)	;RETURN START NEXT COMMAND
	BITB	#WCXOPER+WCXN,WCSTAT(R8)
	IF.	*ON		;NOT CORRECT SYNTAX
		MOVW	#16,GERRN
		RET
	ENDIF.
	BITB	#WCXVAL,WCSTAT(R8)
	IF.	*ON		;OPERAND PRESENT
		MOVL	R7,GEXP1
		BITB	#GXRNG,GSTAT
		IF.	*OFF		;NOT A RANGE PRESENT
			BISB2	#GXVAL,GSTAT	;INDICATE GLOBAL
		ENDIF.
	ELSE.
		BITB	#GXRNG,GSTAT
		IF.	*ON		;RANGE WITHOUT SECOND ARG
			MOVW	#23,GERRN
			RET		;INVALID RANGE
		ENDIF.
		BICB2	#GXVAL,GSTAT
		BITB	#WCXMIN,WCSTAT(R8)
		IF.	*ON		;UNARY -
			MOVL	#-1,GEXP1
		ELSE.
			MOVL	#1,GEXP1
		ENDIF.
	ENDIF.
	RET
	.PAGE
D35:			;#
	MOVB	#4,R0
	BRW	L2
;
D37:				;%
	MOVB	1(R6),R1		;Q-REG
	BSBW	GTVR06ON
	INCL	R0
	MOVL	R0,R7
	MOVB	1(R6),R1
	BSBW	GTVR06IN
	INCL	R6
	DECW	GSILL(R11)
	BRW	L1
;
D38:			;&
	MOVB	#5,R0
	BRW	L2
;
D40:			;(
	INCL	WNB
	MOVL	WNB,R1
	MOVAQ	WCTAB[R1],R8
	CMPL	R1,#10
	IF.	*GT		;11 IS TOO MANY
		MOVW	#17,GERRN
		RET
	ENDIF.
	MOVB	#WCXN,WCSTAT(R8)	;INITIAL STATUS
	BRW	L2X
;
;
D41:			;)
	BITB	#WCXN,WCSTAT(R8)
	IF.	*OFF		;NO ( PRESENT
		MOVW	#16,GERRN
		RET
	ENDIF.
	BITB	#WCXVAL,WCSTAT(R8)
	IF.	*OFF		;NO VALUE PRESENT
		MOVW	#16,GERRN
		RET
	ENDIF.
	DECL	WNB
	MOVL	WNB,R1
	MOVAQ	WCTAB[R1],R8
	BRW	L1			;USE VALUE
WNB:	.BLKL
WCTAB:	.BLKQ	11
WCVAL=0			;OPERAND
WCOPER=4		;OPERATOR
WCSTAT=5		;STATUS
WCXN=^X80		;( PRESENT
WCXVAL=^X40		;OPERAND PRESENT
WCXOPER=^X20		;OPERATOR PRESENT
WCXMIN=^X10		;UNARY MINUS PRESENT
;
;
;
D42:			;*
	MOVB	#2,R0
	BRW	L2
;
D43X:				;SPACE
	BITB	#GXIN1,GSTAT
	IF.	*ON		;IMMIDIATE SPACE
		BRW	L3
	ENDIF.
D43:			;+
	CLRB	R0
	BRW	L2
;
D44:			;,
	BITB	#GXRNG,GSTAT		;RANGE SET?
	IF.	*ON
		MOVW	#22,GERRN
		RET
	ENDIF.
	BITB	#WCXOPER+WCXN,WCSTAT(R8)
	IF.	*ON
D4401:		MOVW	#16,GERRN
		RET
	ENDIF.
	BITB	#WCXVAL,WCSTAT(R8)
	IF.	*OFF			;NO VALUE
		BRW	D4401
	ENDIF.
	MOVL	R7,GEXP2
	BISB2	#GXRNG,GSTAT
	CLRB	WCSTAT(R8)
	BRW	L2X
D45:			;-
	MOVB	#1,R0
	BRW	L2
;
D46:			;.
	MOVL	GFPTR,R7		;RETURN CURRENT /\
	BRW	L1
D47:			;/
	MOVB	#3,R0
	BRW	L2
;
D48:			;0-9
	SPANC	GSILL(R11),(R6),GSCT,#2
	SUBW3	R0,GSILL(R11),R9		;NR OF DIGITS
	CMPW	R9,#9
	IF.	*GT		;TOO MANY DIGITS
		MOVW	#9,GERRN
		RET
	ENDIF.
	MOVC3	R9,(R6),WOPER+1
	MOVL	R1,R6
	SUBW2	R9,GSILL(R11)		;ADJUST INPUT PTRS
	CMPB	#^A'.',(R6)
	IF.	*EQ			;OCTAL WANTED
		INCL	R6
		DECW	GSILL(R11)
		CLRL	R7
		CLRL	R2
		DECL	R1
		MOVZWL	R9,R9		;CLEAR HIGH ORDER
D4801:		CMPB	#^A'7',(R1)
		IF.	*LT		;8 OR 9
			MOVW	#36,GERRN
			RET
		ENDIF.
		CLRL	R0
		SUBB3	#^A'0',(R1),R0
		ASHL	R2,R0,R0
		ADDL2	R0,R7
		DECL	R1
		ADDL2	#3,R2
		SOBGTR	R9,D4801
	ELSE.				;DECIMAL
		CVTSP	R9,WOPER,#11,WPACK	;CVT TO PACKED
		CVTPL	#11,WPACK,R7
	ENDIF.
	DECL	R6
	INCW	GSILL(R11)
	BRW	L1
;
D64:			;@
	MATCHC	#1,1(R6),#WMT1L,WMT1
	IF.	*EQ		; : I R OR S
		INCL	R6
		DECW	GSILL(R11)
		BRW	L3
	ENDIF.
	MOVL	GMIDPTR,R7
	BRW	L1
WMT1:	.ASCII	/:ISRisr/
WMT1L=.-WMT1
;
D66:			;B
	CLRL	R7
	BRW	L1
;
D72:
	TSTB	WCSTAT(R8)		; H
	IF.	*NE
		MOVW	#16,GERRN	; INVALID SYNTAX
		RET
	ENDIF.
	BITB	#GXRNG,GSTAT
	IF.	*ON			;TWICE A RANGE
		MOVW	#21,GERRN
		RET
	ENDIF.
	MOVL	GFCNT,GEXP1
	BISB2	#GXRNG,GSTAT
	CLRL	GEXP2
	DECW	GSILL(R11)
	IF.	*LES			;NO COMMAND
		MOVW	#4,GERRN
		RET
	ENDIF.
	ADDL3	#1,R6,GSIADR(R11)		;RETURN NEXT INPUT COMMAND
	RET
D81:			;Q
	INCL	R6
	DECW	GSILL(R11)
	MOVB	(R6),R1			;QREG NR
	BSBW	GTVR06ON
	MOVL	R0,R7			;SET REURNED QREG VALUE
	BRW	L1
;
D90:			;Z
	MOVL	GFCNT,R7
	BRW	L1
WPACK:	.BLKB	6
WOPER:	.BYTE	^A'+'		;OPERAND IN STRING FORM
	.BLKB	9
ESC=27
	.END