Again, context is all.  Bernd's point,

Man muss übrigens nicht mit Kanonen auf Spatzen schießen.

is well taken (Bowdlerized, it is overkill to launch a torpedo at a
canoe, even if you sink it.)

Still, I do have a MOVECHRS macro that optimizes, generates MVC, MVC
loops, MVCLE, etc., as appropriate.  In some situations I use it; in
others I code an MVC; it all depends.

For the situation under discussion, that of a (halfword current-length
prefixed)  PL/I VARYING CHARACTER value, a test for a nul string, one
of length zero, is clearly required, as it would be for a
nul-delimited C string.  Moreover, that test needs to be in close
proximity to the top of the loop.  The decision where exactly to put
it would require examination of all of the code involved.  In some
cases any competent person would take the same decision; in others
not.

On 2/13/12, robin <[email protected]> wrote:
> From: Gerhard Postpischil <[email protected]>
> Date: Sunday, 12 February 2012 13:45
>
>>On 2/12/2012 5:44 PM, robin wrote:
>>> In this case, BCTR is inappropriate, because the length can be zero,
>>> and use of SH provides the means to test for negative and to skip
>>> the MVC (or CLC).
>>
>>You're drawing an unwarranted conclusion. It is quite possible
>>that the length was tested earlier on in the code, and the
>>author knows better than you that the BCTR is safe.
>
> The programming world is littered with "it can't happen" cases.
> Everyone knows Murphy's Law ("If anything can go wrong, it will").
> But not many have heard of Robert's Law? ("Even if it can't go wrong, it
> will".)
>
> So, even it the length were tested prior, one can't assume that all
> will be well when the EX is reached.
> The MVC can be destructive, and the only case where it isn't is when
> the destination is of length 256.
>
> The intended use of BCTR suggests to me that the author has not allowed for
> the
> length being zero.
>
> What it also suggests to me that the code is not bulletproof.
>
> Setting up for a variable-length move (or compare) using EX
> involves decrementing a length.  That is part and parcel of the move
> (compare), and is best kept as a unit in order to avoid bugs.
>
> For such a routine operation as a variable move, a macro
> would offer many advantages.
>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>


--
John Gilmore, Ashland, MA 01721 - USA

Reply via email to