+1 on this. Readability/maintainability is much more important than relative instruction speed on modern systems.
*Mark* On Wed, Mar 10, 2021 at 6:56 PM Charles Mills <charl...@mcn.org> wrote: > 1. "Instruction speed" is not exactly a concept anymore due to pipelining. > An instruction can take literally zero effective time because it overlaps > with something else such as a wait for cache. "Does an AHI or an LA take > longer?" is no longer a question that has an answer. > > 2. AHI is wonderful but not exactly the functional equivalent of LA and > BCTR. LA can add two registers plus an offset, AHI only one register. AHI > sets the condition code, which may be good for your situation, or bad. BCTR > is a branch instruction, which may affect cache performance, although > modern > CPUs are probably smart enough to realize that BCTR x,0 is not really a > branch. > > 3. Code readability is much more important than instruction speed. CPUs are > fast; programmers are relatively very, very slow and error-prone. I like > AHI > for its readability. LHI says what it does: adds an immediate value to a > register. Would a novice read BCTR as subtracting one? LHI also takes > equates, which improve maintainability. Prefix_Offset EQU > TablePrefix-TableStart / AHI R1,Prefix_Offset is a lot clearer than BCTR > R1,0 / BCTR R1,0. > > Charles > > > -----Original Message----- > From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@LISTSERV.UGA.EDU > ] > On Behalf Of Schmitt, Michael > Sent: Wednesday, March 10, 2021 3:26 PM > To: ASSEMBLER-LIST@LISTSERV.UGA.EDU > Subject: Add 1, Subtract 1 > > I was taught long ago to add 1 to a register using LA r#,1(,r#) and to > subtract 1 using BCTR r#,0. > > Is the fastest way now to use AHI r#,1 and AHI r#,-1? >