At 12:02 +0000 on 10/06/2010, john gilmore wrote about levels of
abstraction (was: 16-bytes the same):
Why use a TRT, which requires a table of, usually, 256 bytes, when
something more compact can be put together for the special case of
16 blanks (or nuls)? The answer can be boiled down to a single
word, reusability.
Just a note on the use of TRT in lieu of CLC for detecting a string
of the same character. In the case of a dump format where you want to
detect a string of 32 or more aligned bytes where all are the same,
you would start with a TRT table composed of stop characters
(256X"FF") and then set byte at the offset into the table of the
character you want that you want to look for to X"00". By starting at
offset 16 (or 32) into the area which is to be checked for the same
character you can get the same result as doing a loop with 16 byte
CLC compares (a trigger to use this routine could be CLC of 31 not 15
characters - a failure would indicate this is not a "Same As Above"
situation).
Note that ANY repeated character not just Blank or NULL could be
looked for with this method. Thus a dump of an area of 256F"-1" would
also trip the SAME AS ABOVE trigger and use the loop of TRTs where
CLCs would be much less efficient.
This is however a special subset of the more general SAME AS ABOVE
detection requirement. If what is being looked for is a repeated 16
byte pattern (where not all 16 of the bytes are the same character)
then a loop containing:
LOOP CLC 16(16,2),0(2)
BNE EXIT
LA 2,16(0,2)
B LOOP
EXIT DS 0H
is the required method.