MATCHKEY        - MATCH A STRING AGAINST A KEY                   21-AUG-1978 18:59:25   VAX-11 MACRO X0.3-11               Page   0

TABLE OF CONTENTS   



   (2)      39  DECLARATIONS

   (3)      57  MATCH KEY

MATCHKEY        - MATCH A STRING AGAINST A KEY                   21-AUG-1978 18:59:25   VAX-11 MACRO X0.3-11               Page   1

V01                                                                                                                              (1)



                                     0000     1 	.TITLE	MATCHKEY - MATCH A STRING AGAINST A KEY

                                     0000     2 	.IDENT	/V01/

                                     0000     3 

                                     0000     4 ;

                                     0000     5 ;			  COPYRIGHT (c) 1977 BY

                                     0000     6 ;	      DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

                                     0000     7 ;

                                     0000     8 ; THIS SOFTWARE IS FURNISHED UNDER A LICENSE ANY MAY BE USED AND  COPIED

                                     0000     9 ; ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH  LICENSE AND WITH THE

                                     0000    10 ; INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR  ANY  OTHER

                                     0000    11 ; COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY

                                     0000    12 ; OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY

                                     0000    13 ; TRANSFERRED.

                                     0000    14 ;

                                     0000    15 ; THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE  WITHOUT  NOTICE

                                     0000    16 ; AND  SHOULD  NOT  BE  CONSTRUED  AS  A COMMITMENT BY DIGITAL EQUIPMENT

                                     0000    17 ; CORPORATION.

                                     0000    18 ;

                                     0000    19 ; DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR  RELIABILITY  OF  ITS

                                     0000    20 ; SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.

                                     0000    21 ;

                                     0000    22 

                                     0000    23 ;++

                                     0000    24 ; FACILITY:	GENERAL PURPOSE UTILITY SUBROUTINE

                                     0000    25 ;

                                     0000    26 ; ABSTRACT:	MATCH A STRING AGAINST A TABLE OF KEYS

                                     0000    27 ;

                                     0000    28 ;

                                     0000    29 ; ENVIRONMENT:	USER MODE/NON-PRIVILEGED CODE

                                     0000    30 ;

                                     0000    31 ; AUTHOR:	W.H.BROWN, CREATION DATE:3-JUN-1977

                                     0000    32 ;

                                     0000    33 ; MODIFIED BY:

                                     0000    34 ;

                                     0000    35 ;	, : VERSION

                                     0000    36 ; 01	- 

                                     0000    37 ;--

MATCHKEY        - MATCH A STRING AGAINST A KEY                   21-AUG-1978 18:59:25   VAX-11 MACRO X0.3-11               Page   2

V01             DECLARATIONS                                                                                                     (2)



                                     0000    39 	.SBTTL	DECLARATIONS

                                     0000    40 ;

                                     0000    41 ; INCLUDE FILES:

                                     0000    42 ;

                                     0000    43 ;

                                     0000    44 ; MACROS:

                                     0000    45 ;

                                     0000    46 ;

                                     0000    47 ; EQUATED SYMBOLS:

                                     0000    48 ;

                           00000004  0000    49 	TABLE	= 4			; ADDRESS OF KEYWORDS

                           00000008  0000    50 	DESCP	= 8			; ADDRESS OF DESCRIPTOR FOR STRING

                           0000000C  0000    51 	ADDR	= 12			; ADDRESS TO STORE RESULT

                                     0000    52 ;

                                     0000    53 ; OWN STORAGE:

                                     0000    54 ;

                                     0000    55 ;	NONE

MATCHKEY        - MATCH A STRING AGAINST A KEY                   21-AUG-1978 18:59:25   VAX-11 MACRO X0.3-11               Page   3

V01             MATCH KEY                                                                                                        (3)



                                     0000    57 	.SBTTL	MATCH KEY

                                     0000    58 ;++

                                     0000    59 ; FUNCTIONAL DESCRIPTION:

                                     0000    60 ;

                                     0000    61 ;	THIS ROUTINE ACCEPTS A LIST OF COUNTED STRINGS

                                     0000    62 ;	AND A DESCRIPTOR FOR A VARAIABLE LENTHG STRING.

                                     0000    63 ;	AN ATTEMPT IS MADE TO FIND A STRING IN THE LIST

                                     0000    64 ;	THAT MATCHES THE VARIABLE STRING CHECKING THE

                                     0000    65 ;	LENGTH OF THE SHORTER STRING.  IF A MATCH IS NOT FOUND,

                                     0000    66 ;	A ZERO IS RETURNED. IF MORE THAN 1 VALUE MATCHES, THE

                                     0000    67 ;	INDEX TO THE FIRST MATCH IS RETURNED A NEGATIVE NUMBER.

                                     0000    68 ;	OTHERWISE THE INDEX IN THE TABLE OF STRINGS IS RETURNED,

                                     0000    69 ;	AS A VALUE STARTING WITH 1.

                                     0000    70 ;

                                     0000    71 ; CALLING SEQUENCE:

                                     0000    72 ;

                                     0000    73 ;	CALLS	#2,LIB$MATCHKEY		; RETURN INDEX IN R1

                                     0000    74 ;

                                     0000    75 ; INPUT PARAMETERS:

                                     0000    76 ;

                                     0000    77 ;	THE ADDRESS OF THE LIST OF COUNTED STRINGS FOLLOWED BY A 0 BYTE

                                     0000    78 ;	THE ADDRESS OF A QUADWORD DESCRIPTOR DESCRIBING THE STRING TO MATCH

                                     0000    79 ;

                                     0000    80 ; IMPLICIT INPUTS:

                                     0000    81 ;

                                     0000    82 ;	NONE

                                     0000    83 ;

                                     0000    84 ; OUTPUT PARAMETERS:

                                     0000    85 ;

                                     0000    86 ;	R0 IS RETURNED AS THE INDEX TO THE MATCH

                                     0000    87 ;

                                     0000    88 ; IMPLICIT OUTPUTS:

                                     0000    89 ;

                                     0000    90 ;	NONE

                                     0000    91 ;

                                     0000    92 ; COMPLETION CODES:

                                     0000    93 ;

                                     0000    94 ;	A ZERO INDICATES NO MATCH, A MINUS NUMBER IS MORE THAN 1 MATCH

                                     0000    95 ;

                                     0000    96 ; SIDE EFFECTS:

                                     0000    97 ;

                                     0000    98 ;	NONE

                                     0000    99 ;

                                     0000   100 ;--

                                 00000000   101 	.PSECT	LIB_CODE	EXE,RD,NOWRT

                                     0000   102  

                                     0000   103 LIB$MATCHKEY::				; MATCH KEYWORD

                               007C  0000   104 	.WORD	^M<R2,R3,R4,R5,R6>	; REGISTERS TO SAVE

            54         08 BC     7D  0002   105 	MOVQ	@DESCP(AP),R4		; GET DESCRIPTOR FOR THE STRING

            56         04 AC     D0  0006   106 	MOVL	TABLE(AP),R6		; THE INPUT STRINGS

                          0E     10  000A   107 	BSBB	100$			; TRY FOR FIRST MATCH

                          50     DD  000C   108 	PUSHL	R0			; SAVE THE INDEX

                          07     13  000E   109 	BEQL	10$			; BR IF NO MATCH

                          08     10  0010   110 	BSBB	100$			; TRY FOR AMBIGUOUS MATCH

                          03     13  0012   111 	BEQL	10$			; NOT AMBIGUOUS

            7E            8E     CE  0014   112 	MNEGL	(SP)+,-(SP)		; CHANGE TO NEGATIVE

                          01     BA  0017   113 10$:	POPR	#^M<R0>			; GET INDEX

MATCHKEY        - MATCH A STRING AGAINST A KEY                   21-AUG-1978 18:59:25   VAX-11 MACRO X0.3-11               Page   4

V01             MATCH KEY                                                                                                        (3)



                                 04  0019   114 	RET				; 

                                     001A   115  

                          01     DD  001A   116 100$:	PUSHL	#1			; GET A INITIAL VALUE

            50            86     9A  001C   117 110$:	MOVZBL	(R6)+,R0		; GET THE LENGTH

                          18     13  001F   118 	BEQL	130$			; BR IF END OF STRING

            51            56     D0  0021   119 	MOVL	R6,R1			; SET ADDRESS

            56            50     C0  0024   120 	ADDL	R0,R6			; POINT AT NEXT

            54            50     D1  0027   121 	CMPL	R0,R4			; SEE WHICH IS BIGGER

                          03     15  002A   122 	BLEQ	120$			; BR IF TARGET IS SHORTER

            50            54     D0  002C   123 	MOVL	R4,R0			; SET INPUT LENGTH

            61            50     29  002F   124 120$:	CMPC3	R0,(R1),(R5)		; CHECK FOR MATCH

                          65         0032       

                          06     13  0033   125 	BEQL	140$			; BR IF FOUND A MATCH

                          6E     D6  0035   126 	INCL	(SP)			; COUNT THE ITERATIONS

                          E3     11  0037   127 	BRB	110$			; TRY AGAIN

                          6E     D4  0039   128 130$:	CLRL	(SP)			; SET ZERO INDEX

                          50   8ED0  003B   129 140$:	POPL	R0			; GET THE VALUE

                                 05  003E   130 	RSB				; RETURN WITH CONDITION CODE SET

                                     003F   131  

                                     003F   132 	.END

MATCHKEY        - MATCH A STRING AGAINST A KEY                   21-AUG-1978 18:59:25   VAX-11 MACRO X0.3-11               Page   5

SYMBOL TABLE                                                                                                                     (3)



ADDR           = 0000000C            

DESCP          = 00000008            

LIB$MATCHKEY     00000000 RG    02   

TABLE          = 00000004            





PROGRAM SECTION SYNOPSIS



.  ABS  .        00000000      00     NOPIC   USR   CON   ABS   LCL NOSHR NOEXE NORD  NOWRT BYTE  

. BLANK .        00000000      01     NOPIC   USR   CON   REL   LCL NOSHR   EXE   RD    WRT BYTE  

LIB_CODE         0000003F      02     NOPIC   USR   CON   REL   LCL NOSHR   EXE   RD  NOWRT BYTE  





THERE WERE NO ERRORS OR WARNINGS.

28382. BYTES LEFT IN FREE MEMORY POOL.

OBJ$:MATCHKEY,LIS$:MATCHKEY/-SP=EXECML$/ML,LIB$:CLIUTL/ML,SRC$:MATCHKEY

0 MLB DIR RDS - 0 GETS TO DEFINE 0 MACROS. 1 INTER. FILE WRITES. 

