	.TITLE	RNOIF
;
;	This section handles the following commands
;
;	.IF
;	.ENDIF
;	.VARIABLE
;
	.psect	TEXT,RO,LCL,D,CON
ENTX:	.ASCIZ	/ENDIF/
	.even
	.psect	$VARS,RW,LCL,D,CON
	INLAB:	.BLKB	12.
	.psect	$CODE,RO,LCL,I,CON
;
;	Routine to test if label present
;
LABTST:	CALL	SKPSP
	BCS	90$			; Control char ?
10$:	CALL	BKSPI			; Backspace over char
	MOV	#INLAB,R2		; Temporary buffer for label
20$:	CALL	CCINUC			; Get 1 character of label
	BCS	30$			; At end of buffer ?
	MOVB	R1,(R2)+		; Save char
	CMP	R2,#INLAB+10.		; Check how many chars
	BLO	20$			; Not too many ?
30$:	CLRB	(R2)+			; Chock end of buffer
	TSTEQB	INLAB,90$		; No string ?
	MOV	#IFBF,R3		; If buffer address
	CALL	BEGBF			; Start at beginning of IF buffer
40$:	MOV	#INLAB,R2		; Now search buffer for label
50$:	CALL	GBYT			; Get first label
	BCS	80$			; None ?
	BLE	55$			; At end of string ?
	CMPEQB	(R2)+,R1,50$		; Chars match ?
	BR	70$
55$:	TSTNEB	(R2),70$		; Not end of input ?
	CLC
	RETURN
60$:	CALL	GBYT			; Get next input byte
	BCS	80$			; End of buffer ?
70$:	TST	R1			; Check for end of string
	BLE	40$			; End of string ?
	BR	60$			; Not yet
80$:	SEC
	RETURN				; No success
90$:	JMP	ILCM
;
;	Test if label is not present
;
IFNOT::	CALL	LABTST			; Test for label
	BCC	IFSKP			; Found one ?
	RETURN				; Label NOT found !!!
;
;	Test if label is true
;
IF::	CALL	LABTST			; Test for label
	BCS	IFSKP			; None ?
	RETURN
IFSKP:	
10$:	CALL	CCIN			; Search for next .ENDIF
	TSTNEB	EOFSW,60$		; At end of file?
	CMPNEB	R1,#LF,10$		; Not end of line yet ?
	CALL	CCIN			; New line begins with command ?
	CMPNEB	R1,$NFLSW,10$		; Not end of input ?
	MOV	#ENTX,R5		; Get correct text to find
40$:	CALL	CCINUC			; Get char
	BCS	45$			; End of command ?
	CMPNEB	R1,(R5)+,10$		; Not ENDIF
	BR	40$			; Try again
45$:	TSTNEB	(R5),10$		; At end of command ?
50$:	CALL	SKPSP			; Skip over spaces
	BCS	60$			; No label ?
	CALL	BKSPI			; Back over first char
	MOV	#INLAB,R2		; Get lable
54$:	CALL	CCINUC			; Get 1 char
	BCS	55$			; End of input
	CMPEQB	(R2)+,R1,54$		; Chars match ?
	BR	10$			; No try next line
55$:	TSTNEB	(R2),10$		; Not end of input ?
60$:	RETURN
ENDIF::	CALL	LABTST			; Ignore the 3 char label
	RETURN
VARIAN:: CALL	LABTST			; Get char string
	BCC	50$			; String already present
	MOV	#IFBF,R3		; If buffer address
	CALL	ENDBF			; Set up for output
	MOV	#INLAB,R2		; get input buffer
10$:	MOVB	(R2)+,R1		; Get char
	BEQ	20$			; Done ?
	CALL	PBYT			; Save it
	BR	10$
20$:	CALL	PBYT
50$:	RETURN
;
;	Subroutine to get only upper case input
;
CCINUC:	CALL	CCIN			; Get input char
	CMPNEB	GCTABL(R1),#GC.LC,10$	; Not lower case ?
	SUB	#40,R1			; Make it upper
10$:	CMPB	GCTABL(R1),#GC.UC	; Test for letter
	BNE	20$			; Now backspace over input
	CLC				; Set char ok !
	RETURN
20$:	CALL	BKSPI			; Kill input
	SEC				; And set end of input
	RETURN
	.END
