Google
 

Trailing-Edge - PDP-10 Archives - BB-P363B-SM_1985 - mcb/blis16/b16ch4.lst
There are no other files named b16ch4.lst in the archive.
B16CH4		OTS CH$ String Find Substring			25-Jan-1983 16:48:25	TOPS-20 Bliss-16 2A(530)	    Page   1
								25-Jan-1983 16:44:34	NETPKG:<BLIS16>B16CH4.B16.1 (1)

;	  0001	MODULE B16CH4 (IDENT = '2-6' %TITLE'OTS CH$ String Find Substring'
;	  0002		       ,LANGUAGE(BLISS16)
;	  0003		      ) =
;	  0004	BEGIN
;	  0005	
;	  0006	!
;	  0007	!         COPYRIGHT (c) 1977,1978,1979,1980,1981,1982 BY
;	  0008	!         DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;	  0009	!
;	  0010	! This software is furnished under a license and may be used and  copied
;	  0011	! only  in  accordance  with  the  terms  of  such  license and with the
;	  0012	! inclusion of the above copyright notice.  This software or  any  other
;	  0013	! copies  thereof may not be provided or otherwise made available to any
;	  0014	! other person.  No title to and ownership of  the  software  is  hereby
;	  0015	! transferred.
;	  0016	!
;	  0017	! The information in this software is subject to change  without  notice
;	  0018	! and  should  not  be  construed  as  a commitment by DIGITAL EQUIPMENT
;	  0019	! CORPORATION.
;	  0020	!
;	  0021	! DIGITAL assumes no responsibility for the use or  reliability  of  its
;	  0022	! software on equipment which is not supplied by DIGITAL.
;	  0023	!
;	  0024	
;	  0025	!++
;	  0026	! FACILITY:
;	  0027	!   Bliss-16 (and Bliss-16C/Bliss-11) Object Time System (OTS)
;	  0028	!
;	  0029	! ABSTRACT:
;	  0030	!   Implements CH$FIND_SUB.
;	  0031	!
;	  0032	! ENVIRONMENT:
;	  0033	!   May be compiled with /ENVIRONMENT:EIS or /ENVIRONMENT:NOEIS
;	  0034	!
;	  0035	! AUTHOR: Don Frank, David Leblang, CREATION DATE: 26-Feb-80
;	  0036	!
;	  0037	! MODIFIED BY:
;	  0038	!
;	  0039	! 4.	13-Feb-80	DGF	Brought into conformance Software Standards.
;	  0040	!
;	  0041	! 5.	18-FEB-80	DGF	MOVE BLISS-11 ENTRY POINTS TO B16B11
;	  0042	!
;	  0043	! 6.	26-Feb-80	DGF&DL	Rewrote the entire routine so that it finally
;	  0044	!				works!  Removed bug fixes 1-3 which introduced
;	  0045	!				new bugs rather than fixing old ones.
;	  0046	!
;	  0047	!--
;	  0048	!
;	  0049	! TABLE OF CONTENTS:
;	  0050	!
;	  0051	
;	  0052	FORWARD ROUTINE
B16CH4		OTS CH$ String Find Substring			25-Jan-1983 16:48:25	TOPS-20 Bliss-16 2A(530)	    Page   2
2-6								25-Jan-1983 16:44:34	NETPKG:<BLIS16>B16CH4.B16.1 (1)

;	  0053	    BL$FSB;
;	  0054	
;	  0055	MACRO
;	  0056	    BLANK=%NAME(' ')(WRITE,EXECUTE,LOCAL,CONCATENATE) %,
;	  0057	    ELIF=ELSE IF%;
;	  0058	
;	  0059	PSECT
;	  0060	    CODE=BLANK,
;	  0061	    PLIT=BLANK,
;	  0062	    OWN=BLANK;
B16CH4		OTS CH$ String Find Substring			25-Jan-1983 16:48:25	TOPS-20 Bliss-16 2A(530)	    Page   3
2-6								25-Jan-1983 16:44:34	NETPKG:<BLIS16>B16CH4.B16.1 (2)

;	  0063	GLOBAL ROUTINE BL$FSB(CLEN,CPTR,PLEN,PPTR) =
;	  0064	!+
;	  0065	! FUNCTIONAL DESCRIPTION:
;	  0066	!    FINDS THE FIRST OCCURENCE OF A PATTERN STRING IN A CONTEXT
;	  0067	!    STRING.
;	  0068	!
;	  0069	! INPUTS:
;	  0070	!    CLEN:	LENGTH AND
;	  0071	!    CPTR:	POINTER TO THE CONTEXT STRING.
;	  0072	!    PLEN:	LENGTH AND
;	  0073	!    PPTR:	POINTER TO THE PATTERN STRING.
;	  0074	!
;	  0075	! VALUE:
;	  0076	!    POINTER TO THE FIRST MATCHING OCCURENCE. 0 IF NONE FOUND.
;	  0077	!-
;	  0078	    BEGIN
;	  0079	
;	  0080	    LOCAL
;	  0081		CONTEXT_END_PTR;		! Points 1 char past end of context.
;	  0082	
;	  0083	    LABEL
;	  0084		MATCH;
;	  0085	
;	  0086	    IF .PLEN LEQ 0 THEN RETURN 0;	! CHECK TO AVOID INVALID READ
;	  0087	    IF .CLEN LEQ 0 THEN RETURN 0;	! CHECK TO AVOID INVALID READ
;	  0088	
;	  0089	    CONTEXT_END_PTR = CH$PLUS(.CPTR, .CLEN);	! Past end of context.
;	  0090	
;	  0091	    WHILE 1 DO
;	  0092		BEGIN
;	  0093		!+
;	  0094		! Loop invariants::
;	  0095		!   1. The pattern never changes (PPTR is never stored to)
;	  0096		!   2. The CPTR pointer points to a sub-string of the original context
;	  0097		!	such that the context length (CLEN) is always maintained
;	  0098		!	as the length of the remaining context.  Characters to the
;	  0099		!	left of the CPTR are no longer of interest.
;	  0100		!-
;	  0101		CPTR = CH$FIND_CH(.CLEN, .CPTR, CH$RCHAR(.PPTR)); ! FIND POTENTIAL 
;	  0102		IF CH$FAIL(.CPTR)
;	  0103		THEN
;	  0104		    RETURN 0
;	  0105		ELSE
;	  0106		    !+
;	  0107		    ! The context has gotten smaller, update the context length
;	  0108		    !-
;	  0109		    CLEN = CH$DIFF(.CONTEXT_END_PTR, .CPTR);
;	  0110	
;	  0111		!+
;	  0112		! A potential match has been found, the remaining context must be
;	  0113		! at least as big as the pattern or else the pattern can't match.
;	  0114		!-
B16CH4		OTS CH$ String Find Substring			25-Jan-1983 16:48:25	TOPS-20 Bliss-16 2A(530)	    Page   4
2-6								25-Jan-1983 16:44:34	NETPKG:<BLIS16>B16CH4.B16.1 (2)

;	  0115		IF .CLEN LSS .PLEN
;	  0116		THEN
;	  0117		    RETURN 0;
;	  0118	
;	  0119	MATCH:	BEGIN
;	  0120		!+
;	  0121		! The first character of the pattern has matched a character in the
;	  0122		! current context.  The context is large enough to match the entire
;	  0123		! pattern.  Check to see is the rest of the pattern matches the
;	  0124		! next group of characters.
;	  0125		!-
;	  0126		LOCAL
;	  0127		    REST_OF_PAT,
;	  0128		    CTXT;
;	  0129	
;	  0130		REST_OF_PAT = CH$PLUS(.PPTR,1);
;	  0131		CTXT = CH$PLUS(.CPTR,1);
;	  0132	
;	  0133		DECR J FROM .PLEN-1 TO 1 DO
;	  0134		    BEGIN
;	  0135		    !+
;	  0136		    ! For each of the remaining pattern characters see if the char
;	  0137		    ! matches the next context character.
;	  0138		    !-
;	  0139		    IF CH$RCHAR_A(REST_OF_PAT) NEQ CH$RCHAR_A(CTXT)
;	  0140		    THEN
;	  0141			LEAVE MATCH;
;	  0142		    END;
;	  0143	
;	  0144		RETURN .CPTR;			! The entire pattern matches.
;	  0145		END;				! End of MATCH.
;	  0146	
;	  0147		CPTR = CH$PLUS(.CPTR,1);	! NO LUCK. TRY NEXT POSITION.
;	  0148		CLEN = .CLEN - 1;		! Maintain invariant on context length
;	  0149	
;	  0150		IF .CLEN LEQ 0
;	  0151		THEN
;	  0152		    RETURN 0;			! Ran out of context.
;	  0153		
;	  0154		END;
;	  0155	
;	  0156	    RETURN 0		! NO MATCH FOUND.
;	  0157	
;	  0158	    END;


						.TITLE	B16CH4 OTS CH$ String Find Substring
						.IDENT	/2.6/

						.SBTTL	BL$FSB
000000						.PSECT	.
B16CH4		OTS CH$ String Find Substring			25-Jan-1983 16:48:25	TOPS-20 Bliss-16 2A(530)	    Page   5
2-6								25-Jan-1983 16:44:34	NETPKG:<BLIS16>B16CH4.B16.1 (2)

000000	004167  000000G			BL$FSB::JSR	R1,$SAVE5			;					0063
000004	005746 					TST	-(SP)
000006	016605  000022 				MOV	22(SP),R5			; PLEN,*				0086
000012	003467 					BLE	7$
000014	016600  000026 				MOV	26(SP),R0			; CLEN,*				0087
000020	003464 					BLE	7$
000022	010016 					MOV	R0,(SP)				; *,CONTEXT.END.PTR			0089
000024	066616  000024 				ADD	24(SP),(SP)			; CPTR,CONTEXT.END.PTR
000030	010004 					MOV	R0,R4				; CLEN,*				0101
000032	010446 				1$:	MOV	R4,-(SP)
000034	016646  000026 				MOV	26(SP),-(SP)			; CPTR,*
000040	005046 					CLR	-(SP)
000042	117616  000026 				MOVB	@26(SP),(SP)			; PPTR,*
000046	004767  000000G				JSR	PC,BL$FCH
000052	010066  000032 				MOV	R0,32(SP)			; *,CPTR
000056	010002 					MOV	R0,R2				; CPTR,*				0102
000060	001003 					BNE	3$
000062	062706  000006 			2$:	ADD	#6,SP				;					0104
000066	000441 					BR	7$
000070	016666  000006  000034 		3$:	MOV	6(SP),34(SP)			; CONTEXT.END.PTR,CLEN			0109
000076	160266  000034 				SUB	R2,34(SP)			; *,CLEN
000102	026605  000034 				CMP	34(SP),R5			; CLEN,*				0115
000106	002765 					BLT	2$				;					0117
000110	016601  000026 				MOV	26(SP),R1			; PPTR,REST.OF.PAT			0130
000114	005201 					INC	R1				; REST.OF.PAT
000116	010200 					MOV	R2,R0				; *,CTXT				0131
000120	005200 					INC	R0				; CTXT
000122	010503 					MOV	R5,R3				; *,J					0133
000124	005303 					DEC	R3				; J
000126	003403 					BLE	5$
000130	122120 				4$:	CMPB	(R1)+,(R0)+			; REST.OF.PAT,CTXT			0139
000132	001005 					BNE	6$				;					0141
000134	077303 					SOB	R3,4$				; J,*					0000
000136	062706  000006 			5$:	ADD	#6,SP				;					0091
000142	010200 					MOV	R2,R0				;					0092
000144	000413 					BR	8$
000146	005266  000032 			6$:	INC	32(SP)				; CPTR					0147
000152	005366  000034 				DEC	34(SP)				; CLEN					0148
000156	016604  000034 				MOV	34(SP),R4			; CLEN,*				0150
000162	003737 					BLE	2$				;					0152
000164	062706  000006 				ADD	#6,SP				;					0092
000170	000720 					BR	1$				;					0091
000172	005000 				7$:	CLR	R0				;					0063
000174	005726 				8$:	TST	(SP)+
000176	000207 					RTS	PC

; Routine Size:  64 words,	Routine Base:  . + 0000
; Maximum stack depth per invocation:  11 words


;	  0159	
;	  0160	
B16CH4		OTS CH$ String Find Substring			25-Jan-1983 16:48:25	TOPS-20 Bliss-16 2A(530)	    Page   6
2-6								25-Jan-1983 16:44:34	NETPKG:<BLIS16>B16CH4.B16.1 (2)

;	  0161	END ELUDOM



;					OTS external references
						.GLOBL	$SAVE5, BL$FCH


;					PSECT SUMMARY
;
;	Psect Name			Words	  Attributes
;	 .				   64	    RW ,  I  ,  LCL,  REL,  CON





; Size:		64 code + 0 data words
; Run Time:	00:01.2
; Elapsed Time:	00:01.6
; Memory Used:	11 pages
; Compilation Complete