FWIW, I've started using XGR or LGHI even when I'm not in 64 bit mode. Yes
it is a bit more memory, but potentially future-proofs the code if/when it
is re-written for 64 bit.

*Mark Hammack*
[email protected]
214-478-0955 (c)


On Tue, Feb 10, 2026 at 12:55 PM David Clark <[email protected]> wrote:

> >> Your initial description of the problem said that you were short on
> registers,
> >> so the second and third proposed code snippets – where you zero a
> register
> >> – seem to conflict with this goal.
>
> I wasn't clear on the situation.  Where I need to DO this, it is in an
> initialization section where R0 through R7 are available for whatever use.
> But where I need to USE this, I need all those registers free for other
> things.
>
> >> To avoid all of these issues, the MVHHI solution seems like a good bet
> if the instruction is available.
>
> Yes, MVHHI worked, but I ended up removing it because it turned out that I
> needed a register initialized to zero anyway.  So, I went with
> this--because I needed R5 at zero in the later code:
>
> XR    R5,R5              STARTING FROM ZERO
> STH   R5,STRGLEN          SET USED STRING LENGTH COUNTER
>
> Sincerely,
>
> Dave Clark
> --
> int.ext: 91078
> direct: (937) 531-6378
> home: (937) 751-3300
>
> Winsupply Group Services
> 3110 Kettering Boulevard
> Dayton, Ohio  45439  USA
> (937) 294-5331
>
>
> On Tue, Feb 10, 2026 at 12:37 PM Dan Greiner <[email protected]> wrote:
>
> > Your first and second proposed code snippets both use EXCLUSIVE OR, which
> > happens to set the condition code. As a general rule, I tend to avoid
> > CC-setting operations unless some subsequent instruction depends on the
> > CC.  Also, if you're writing exceedingly clever code where previously-set
> > CC is needed later, putting these snippets in between blows that
> cleverness
> > away.
> >
> > Your initial description of the problem said that you were short on
> > registers, so the second and third proposed code snippets – where you
> zero
> > a register – seem to conflict with this goal.
> >
> > To avoid all of these issues, the MVHHI solution seems like a good bet if
> > the instruction is available. MVHHI was introduced as part of the
> > general-instructions-extension facility in February 2008 (IIRC, this puts
> > it in the z10 family).
> >
>

Reply via email to