Below, an improvement (i) and a mandatory (m) change suggestion:

Date:    Fri, 2 Oct 2015 13:57:34 -0400
From:    Scott Ford <[email protected]>
Subject: Branch table

All:

I am building a branch table like this:


BTAB     DSECT
BADD     DS    AL4      or Y(..) i Routine address
BFUN     DS    CL10                Function code
BNXT     DS    0AL4 or EQU *     i (Align to) Next item
BLEN     EQU   *-BADD              One item length
PROG     CSECT ,                   (or LOCTR)
* ---------------------------------------------------
FUNC     DS    CL(L'BFUN)          Input

FUNCTBL  DS    0X                i Table
         DC    AL4(INIT_DSP),CL(L'BFUN)'INIT'
         DC    AL4(KILL_DSP),CL(L'BFUN)'KILL'
         DS    0X                i 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
         LA    R5,BNXT           m incr scan ptr  !!
         JCT   R5,LOOPTBL          No  - try next
         J     ENDOFDAYS           Not found

FOUND_IT DS    0H
         L     R15,BADD            Routine address
         DROP  R4
         BASR  R14,R15             Execute routine
*        etc...
* ---------------------------------------------------

If you hae  many table entries I'd use Y(..) instead of AL4(..)

Andreas Geissbuehler

Reply via email to