Using TRTRE makes it very simple. Build a TRT table with all bytes non-zero
except the C' ' byte and execute the instruction. After the instruction R1
will point at the 'D' in field. TRTRE works right to left rather than left to
right.
TRTTABLE DC 256XL1'04'
ORG TRTTABLE+C' '
DC XL1'00'
ORG ,
Chris Blaicher
Principal Software Engineer, Software Development
Syncsort Incorporated
50 Tice Boulevard, Woodcliff Lake, NJ 07677
P: 201-930-8260 | M: 512-627-3803
E: [email protected]
-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On
Behalf Of Michael Harding
Sent: Thursday, May 15, 2014 3:19 PM
To: MVS List Server 2
Subject: Re: Right Justification Subroutine
If "this is your field " I wouldn't want to right-justify it based on
finding the first blank with TRT/R/E.
--
Mike Harding
z/VM System Support
/sp
IBM Mainframe Assembler List
<[email protected]<mailto:[email protected]>> wrote
on
05/15/2014 12:00:52 PM:
> From: "Blaicher, Christopher Y."
> <[email protected]<mailto:[email protected]>>
> To: [email protected]<mailto:[email protected]>
> Date: 05/15/2014 12:07 PM
> Subject: Re: Right Justification Subroutine Sent by: IBM Mainframe
> Assembler List
> <[email protected]<mailto:[email protected]>>
>
> John,
> Because of the nature of TRT, TRTE and TRTRE a single byte CLI loop
> can be faster to much faster, or at least they have been in the past.
> I don't think they have changed the underlying hardware process in the
> EC12, but I have been wrong in the past. I once read that if you were
> looking for up to 3 different characters in a string, the open code
> method will beat any of those three instructions.
>
> The problem with TRT is it validates the whole TRT table before it
> starts to do the TRT. I believe TRTE and TRTRE also suffer from that,
> but also they are milli-coded, or is it micro-coded, which incurs a
> non-trivial amount of instruction startup and termination time. The
> overheads are similar to MVCL compared to MVC used in a loop. A loop
> of MVC's will reduce the CPU time of a routine until you get to close
> to moving 32K at a time. If you are moving more than 32K at a time,
> then MVCL can win.
>
> As you say, the single CLI loop is ugly, but it can be much faster.
> I am writing code right now that uses the TRT and TRTRE instructions,
> but that is for exception error processing, not record level or
> sub-record level processing so speed was not my primary concern.
>
> Chris Blaicher
> Principal Software Engineer, Software Development Syncsort
> Incorporated
> 50 Tice Boulevard, Woodcliff Lake, NJ 07677
> P: 201-930-8260 | M: 512-627-3803
> E: [email protected]<mailto:[email protected]>
>
> -----Original Message-----
> From: IBM Mainframe Assembler List
[mailto:[email protected]
> ] On Behalf Of John Gilmore
> Sent: Thursday, May 15, 2014 2:32 PM
> To: MVS List Server 2
> Subject: Re: Right Justification Subroutine
>
> If your routine is to be used heavily there is a much faster way to do
> left justifications. It is to use a TRTE with a 256-byte table that
> defines only a blank, x'40', as a licit character. This approach
> yields the zero-origin offset of the leftmost non-blank
directly.
>
> If I were writing such a routine, as I did long ago, I would also give
> it an additional entry point for right justification, which can [now]
> be accomplished using the same approach [and the same table] but using
> a TRTRE instead of a TRTE.
>
> I agree 'philosophically' with most of what Bill wrote; but single-
> character-by-single-character operations on strings are, I think, not
> just tedious but ugly where better approaches are available.
>
> John Gilmore, Ashland, MA 01721 - USA
>