On the page Parsing - Modern Techniques, it was stated that there may be times when TRT might be a better instruction to use than SRST. So what are the pros and cons.

TRT

The Translate and Test Instruction (TRT) is one of the original System/360 instruction, with a single byte within the instruction used to indicate the length of the field to be searched. This limits the length of said field to 256 bytes.

The second argument of a TRT instruction is a 256-byte table containing binary zeroes in all bytes except the locations where the character to be searched for resides in the collating sequence.

For Example:

TRTTAB

 

DC

 

256X'0'

DEFINES THE TRANSLATION TABLE.

 

 

ORG

 

TRTTAB+C' '

BLANK

 

DC

 

CL1' '

A BLANK

 

 

ORG

 

TRTTAB+C','

COMMA

 

DC

 

CL1','

A COMMA

 

 

ORG

 

TRTTAB+C'='

EQUALS

 

DC

 

CL1'='

AN EQUALS SIGN

 

 

ORG

 

,

LOGICAL END OF TABLE

This combination means that more than one character can be searched for at a time. This is useful when Parsing JCL, when a parameter might end with either a comma or a blank.

SRST

The Search String (SRST) instruction is more modern and effectively uses three registers.

The low-order byte of General Purpose Register 0 contains the character to be searched for. Note that this usage is implicit, and is not explicitly defined in the coding of the SRST instruction, which only has two registers on the statement.

The two registers used by SRST are:

Because the two registers contain the start and end locations of the search, fields in excess of 256 bytes can be handled. However the use of the low-order byte in Register 0 to hold the character to be found, means that only one character can be searched for at a time.

So which instruction should I use?

Basically it comes down to the size of the field to be searched, and the number of character to be searched for concurrently.

End of Topic

Copyright © KMS-IT Limited 2002