Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/23/scanto.mac
There are 2 other files named scanto.mac in the archive. Click here to see a list.
00100	COMMENT * SIMULA specification;
00200	OPTIONS(/E:QUICK,scanto);
00300	TEXT PROCEDURE scanto(tt,c);
00400	NAME tt; TEXT tt; CHARACTER c;
00500	COMMENT Scans from tt.Pos until the next occurrence of
00600	the character c.  Places tt.Pos after the character found.
00700	The function value of scan is the text starting at the initial tt.Pos
00800	and not including the character c found. If no character c is found,
00900	tt.Pos will be = tt.Length+1, and scan denotes the rest of tt starting
01000	at the initial tt.Pos.
01100	;
01200	
01300	!*;! MACRO-10 code !*;!
01400	
01500		TITLE	scanto
01600		ENTRY	scanto
01700		SUBTTL	SIMULA utility, Lars Enderin Nov 1975
01800	
01900	;!*** Copyright 1975 by the Swedish Defence Research Institute. ***
02000	;!*** Copying is allowed.					***
02100	
02200		sall
02300		search	simmac,simmcr,simrpa
02400		macinit
02500	
02600		;! Local definitions ;!
02700	
02800		tt==XWAC1
02900		t==tt
03000		c==XWAC3
03100		bp==X0
03200		lng==XIAC
03300		c1==t+1
03400	
03500	
03600	scanto:	PROC
03700		IF	;! Xtop is not XWAC1
03800			CAIN	XTAC,XWAC1
03900			GOTO	FALSE
04000		THEN	;! Rearrange ac's
04100			EXCH	XWAC1,(XTAC)
04200			EXCH	XWAC2,1(XTAC)
04300			EXCH	XWAC3,2(XTAC)
04400		FI
04500		ADDI	t,(t+1)	;! Address of text variable
04600		LF	X1,ZTVCP(t)	;! X1:=t.Pos-1
04700		LF	lng,ZTVLNG(t)	;! lng:=t.Length-X1
04800		SUBI	lng,(X1)
04900		IF	;! NOT t.more
05000			JUMPG	lng,FALSE
05100		THEN	;! Return NOTEXT, do not change tt.Pos
05200			SETZB	t,t+1
05300			GOTO	L9
05400		FI
05500		LF	,ZTVSP(t)
05600		ADDI	(X1)
05700		IDIVI	5
05800		ADD	(t)
05900		HRRZ
06000		ADD	bytep(X1)
06100		LOOP
06200			ILDB	c1,
06300			CAIN	c1,(c)
06400			GOTO	found
06500		AS
06600			SOJG	lng,TRUE
06700		SA
06800	found:	LF	X1,ZTVLNG(t)
06900		SUBI	X1,(lng)		;! X1:=t.Length-lng
07000		LF	,ZTVCP(t)	;! tt.Pos
07100		SF	X1,ZTVCP(t)	;! tt.Pos:=X1+1
07200		IF	;! Found
07300			JUMPLE	lng,FALSE
07400		THEN	;! Adjust tt.Pos
07500			AOS	OFFSET(ZTVCP)(t)
07600		FI
07700		SUB	X1,		;! X1:=X1-t.Pos+1
07800		IF	;! X1 > 0
07900			JUMPLE	X1,FALSE
08000		THEN
08100			L	c,t		;! Save text var address
08200			MOVSI	t+1,(X1)	;! scan.Length:=X1;! scan.Pos:=1
08300			MOVSM	t		;! tt.Pos,,0
08400			ADD	t,(c)		;! +offset,,text obj addr
08500		ELSE
08600			SETZB	t,t+1	;! NOTEXT
08700		FI
08800	L9():!
08900		IF	;! Xtop is not XWAC1
09000			CAIN	XTAC,XWAC1
09100			GOTO	FALSE
09200		THEN
09300			EXCH	XWAC3,2(XTAC)
09400			EXCH	XWAC2,1(XTAC)
09500			EXCH	XWAC1,(XTAC)
09600		FI
09700		RETURN
09800		EPROC
09900	
10000	bytep:	POINT	7,2,-1
10100		POINT	7,2,6
10200		POINT	7,2,13
10300		POINT	7,2,20
10400		POINT	7,2,27
10500		LIT
10600		END;