Hi Mark,

Thanks for asking the question :-)

Use BCTR in a loop - that's what it's for ;-)

Use LA when incrementing a pointer,
but AHI when it's not a pointer.
Or consider CC preservation needs.

Speed is no concern here. Think pipeline.

The speed of the processor (or rather, the process)
is determined by all it can do in parallel, rather than clock speed.
The processor does so many things at the same time.
So much parallelism in there nowadays ...

Remember the issues with self-modifying code?
It required a flush of the pipeline and then the
CPU would lose so many cycles refilling it,
the delays were measurable...

Side note: around 2000 I worked on a microprocessor
that had very long instruction word (VLIW) technology.
It had instructions up to 48 bytes (!) in length.
Those instructions allowed us to address CPU
components directly: adders, shifters, logic units,
multipliers, etc. Extremely powerful.
The new VEVAL instruction is going that way.

It's not how fast you run, it's how much luggage
you can carry while running.
Setting the CC I'll wager will not cost any additional time.
Zero femtoseconds ;-)

Kind regards & happy programming!
Abe Kornelis
==========


On 10/07/2025 18:39, Mark Hammack wrote:
> Is there any advantage to using:
>
> LA  Rx,1(,Rx)  vs.
> AHI Rx,1
>
> Back in the old days (I started on S/370 with MVS right before XA came
> out), to increment a register, you had to use option 1.  Now, either will
> work.  I prefer the latter because I think it is clearer what you intend
> but since it sets the CC flags, I'm not sure it is any "better" and may be
> (slightly) slower.
>
> Really, the same question can be asked about:
>
> BCTR Rx,0 vs.
> AHI  Rx,-1
>
> and
>
> LA   Rx,value
> LHI  Rx,value
>
> Same thing, the latter is much clearer, especially for new-to-assembler
> programmers. In the LA vs LHI case, LA is limited to 4095 whereas LHI can
> go to 32767 so there is an advantage in some situations.
>
> IDK, maybe it's the closet C programmer in me...
>
>
>
>
> *Mark Hammack*

Reply via email to