Oops! Clearly it's desirable to step to the next item each time round the loop. Whether to use AHI or LA is probably not significant in a modern pipelined engine, but probably has supporters in both camps.
I would never use JXLE here (or, indeed, anywhere else) for a number of complementary reasons: 1. If the table is big enough for JXLE to make a significant difference, it should be done via binary search; 2. JXLE just isn't sufficiently readable/understandable to most people (at lease, to me), whereas I think AHI/JCT is much more immediately comprehensible; 3. JXLE uses an extra register, and requires the use of an even-odd pair -- under some circumstances this may introduce the additional overhead of an extra save and restore. 4. In any event, JXLE and JXH are derived from BXLE and BXH, instructions which should never have existed -- the instructions that *should* have been created are JXL and JXHE. Why? Because BXLE and BXH are optimised for 1-origin indexing (COBOL compiler?), while BXL and BXHE would have been better for zero-origin indexing, which I believe is now universally recognised as being a better paradigm which helps to avoid off-by-one mistakes. A good reference: E. Dijkstra: "Why numbering should start at zero", https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html * --------------------------------------------------- BTAB DSECT BADD DS A Routine address BFUN DS CL10 Function code BNXT DS 0A Align to next item BLEN EQU BNXT-BTAB One item length PROG CSECT , (or LOCTR) * --------------------------------------------------- FUNC DS CL(L'BFUN) Input FUNCTBL DS 0A Table DC A(INIT_DSP),CL(L'BFUN)'INIT' DC A(KILL_DSP),CL(L'BFUN)'KILL' DS 0A Align end TBLENT EQU (*-FUNCTBL)/BLEN * --------------------------------------------------- LA R4,FUNCTBL Start of table USING BTAB,R4 LHI R5,TBLENT Item count LOOPTBL DS 0H CLC FUNC,BFUN This one? JE FOUND_IT Yes - handle AHI R4,BLEN No - try next * or LA R4,BNXT (Debatable) JCT R5,LOOPTBL Until done J ENDOFDAYS Not found FOUND_IT DS 0H L R15,BADD Routine address DROP R4 BASR R14,R15 Execute routine * ---------------------------------------------------
