Instruction speed is still a concept, but it is much less relevant to predicting performance than it used to be, and even in the old days the execution time of an instruction could differ based on its data. Pipeling and caches are subject to various kinds of flushes and stalls. Predicting the performance of an instruction mix on a particular processor is far too complicated to be practical.
LA behaves differently depending on the addressing mode. The importance of code maintainability and readability cannot be overstated. If a code sequence is not crystal clear, add a comment to explain what, how and why it does what it does, in terms of the application. Pillory the programmer that writes L R7,=A(MAGIC_NUMBER) Put magic number in register 7 Note: you can also use equated symbols in LA, and should, for the same reasons that you should use them on AHI. -- Shmuel (Seymour J.) Metz http://mason.gmu.edu/~smetz3 ________________________________________ From: IBM Mainframe Assembler List [ASSEMBLER-LIST@LISTSERV.UGA.EDU] on behalf of Charles Mills [charl...@mcn.org] Sent: Wednesday, March 10, 2021 7:56 PM To: ASSEMBLER-LIST@LISTSERV.UGA.EDU Subject: Re: Add 1, Subtract 1 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.