MATCHKEY        - MATCH A STRING AGAINST A KEY                   22-AUG-1978 05:17:44   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                   22-AUG-1978 05:17:44   VAX-11 MACRO X0.3-11               Page   1

BB02                                                                                                                             (1)



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

                                     0000     2 	.IDENT	/BB02/

                                     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                   22-AUG-1978 05:17:44   VAX-11 MACRO X0.3-11               Page   2

BB02            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                   22-AUG-1978 05:17:44   VAX-11 MACRO X0.3-11               Page   3

BB02            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 SECOND 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.  AN EXACT MATCH RETURNS THE INDEX

                                     0000    70 ;	OF THE EXACT MATCH IGNORING POSSIBLE AMBIGUITIES.

                                     0000    71 ;

                                     0000    72 ; CALLING SEQUENCE:

                                     0000    73 ;

                                     0000    74 ;	CALLS	#2,MATCHKEY		; RETURN INDEX IN R0

                                     0000    75 ;

                                     0000    76 ; INPUT PARAMETERS:

                                     0000    77 ;

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

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

                                     0000    80 ;

                                     0000    81 ;

                                     0000    82 ; OUTPUT PARAMETERS:

                                     0000    83 ;

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

                                     0000    85 ;-

                                     0000    86 	PURE

                                 00000000       	.PSECT	PURE_	BYTE,RD,EXE,NOWRT

                                     0000    87  

                                     0000    88 MATCHKEY::				; MATCH KEYWORD

                               01FC  0000    89 	.WORD	^M<R2,R3,R4,R5,R6,R7,R8>; REGISTERS TO SAVE

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

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

                          58     D4  000A    92 	CLRL	R8			; INITIALIZE THE INDEX

                          1D     10  000C    93 	BSBB	20$			; TRY FOR FIRST MATCH

                          58     DD  000E    94 	PUSHL	R8			; SAVE THE INDEX

                          16     13  0010    95 	BEQL	10$			; BRANCH IF NO MATCH

            57            54     B1  0012    96 	CMPW	R4,R7			; IS THIS AN EXACT MATCH?

                          11     13  0015    97 	BEQL	10$			; BRANCH IF YES

                          12     10  0017    98 	BSBB	20$			; TRY FOR AMBIGUOUS MATCH

                          58     D5  0019    99 	TSTL	R8			; DID ANOTHER ENTRY MATCH?

                          0B     13  001B   100 	BEQL	10$			; BRANCH IF NOT AMBIGUOUS

            6E            58     D0  001D   101 	MOVL	R8,(SP)			; SET NEW INDEX

            57            54     B1  0020   102 	CMPW	R4,R7			; IS THIS AN EXACT MATCH?

                          03     13  0023   103 	BEQL	10$			; BRANCH IF IT IS

            6E            6E     CE  0025   104 	MNEGL	(SP),(SP)		; CHANGE TO NEGATIVE

                          01     BA  0028   105 10$:	POPR	#^M<R0>			; GET INDEX

                                 04  002A   106 	RET				; 

                                     002B   107  

                          58     D6  002B   108 20$:	INCL	R8			; COUNT THE ITERATIONS

            57            86     9A  002D   109 	MOVZBL	(R6)+,R7		; GET THE LENGTH

                          18     13  0030   110 	BEQL	50$			; BRANCH IF END OF STRING

            51            56     D0  0032   111 	MOVL	R6,R1			; SET ADDRESS

            56            57     C0  0035   112 	ADDL	R7,R6			; POINT AT NEXT

MATCHKEY        - MATCH A STRING AGAINST A KEY                   22-AUG-1978 05:17:44   VAX-11 MACRO X0.3-11               Page   4

BB02            MATCH KEY                                                                                                        (3)



            50            57     D0  0038   113 	MOVL	R7,R0			; MAKE COPY FOR ADJUSTMENT

            54            50     D1  003B   114 	CMPL	R0,R4			; SEE WHICH IS BIGGER

                          03     15  003E   115 	BLEQ	40$			; BRANCH IF TARGET IS SHORTER

            50            54     D0  0040   116 	MOVL	R4,R0			; SET INPUT LENGTH

            61            50     29  0043   117 40$:	CMPC3	R0,(R1),(R5)		; CHECK FOR MATCH

                          65         0046       

                          E2     12  0047   118 	BNEQ	20$			; BRANCH IF NO MATCH

                                 05  0049   119 	RSB				; RETURN WITH COUNT IN R8

                          58     D4  004A   120 50$:	CLRL	R8			; SET ZERO INDEX

                                 05  004C   121 	RSB				; RETURN WITH COUNT IN R8

                                     004D   122  

                                     004D   123 	.END

MATCHKEY        - MATCH A STRING AGAINST A KEY                   22-AUG-1978 05:17:44   VAX-11 MACRO X0.3-11               Page   5

SYMBOL TABLE                                                                                                                     (3)



ADDR           = 0000000C            

DESCP          = 00000008            

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  

PURE_            0000004D      02     NOPIC   USR   CON   REL   LCL NOSHR   EXE   RD  NOWRT BYTE  





THERE WERE NO ERRORS OR WARNINGS.

28228. BYTES LEFT IN FREE MEMORY POOL.

OBJ$:MATCHKEY,LIS$:MATCHKEY/-SP/LI:MEB=EXECML$/ML,LIB$:B/ML,SRC$:B/ML,MATCHKEY

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

