Use the instruction most suitable for the task at hand, but remember that LAY is longer than the others. How do you want to affect the top half of the register? The cc? Do you need t add in another register?
-- Shmuel (Seymour J.) Metz http://mason.gmu.edu/~smetz3 עַם יִשְׂרָאֵל חַי נֵ֣צַח יִשְׂרָאֵ֔ל לֹ֥א יְשַׁקֵּ֖ר ________________________________________ From: IBM Mainframe Assembler List <ASSEMBLER-LIST@LISTSERV.UGA.EDU> on behalf of Ngan, Robert (DXC Luxoft) <robert.n...@dxc.com> Sent: Monday, July 14, 2025 2:39 PM To: ASSEMBLER-LIST@LISTSERV.UGA.EDU <ASSEMBLER-LIST@LISTSERV.UGA.EDU> Subject: Re: Food for thought. External Message: Use Caution I started using AHI instead of LA for addresses arithmetic since the operand specification was shorter and there was less chance of typo'ing one the register specifiers. However then it became confusing (at a glance) to determine whether you are doing arithmetic on a number or doing address calculations, so now I am sticking to LA for address calculations and AHI for numeric arithmetic. I do continue to use AHI for address arithmetic when the address is in R00 though. For subtracting values from an address, I'll use LAY -n(,Rxx) Also with AHI, you need to remember whether to code AHI or AGHI depending on whether your code is AMODE 31 or 64, as AHI will not give you the correct 64-bit address result if you cross 4GB boundary. With LHI/LFI, there is really no reason to use LA to load a numeric value. And when that numeric value is in an equate, if you're unfamiliar with the code, you need to hunt down the symbol definition to determine if you are loading the address of a field or just a numeric value. Robert Ngan DXC Luxoft -----Original Message----- From: IBM Mainframe Assembler List <ASSEMBLER-LIST@LISTSERV.UGA.EDU> On Behalf Of Mark Hammack Sent: Thursday, July 10, 2025 11:40 To: ASSEMBLER-LIST@LISTSERV.UGA.EDU Subject: Food for thought. 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*