All,

Really appreciate it, I am prototyping some dataspace code, that can be
called.. So i want to make sure my thinking is right or close..Tony I like
the above code. Very nice and flexible which I like.

On Fri, Oct 2, 2015 at 2:49 PM, Tony Harminc <[email protected]> wrote:

> On 2 October 2015 at 13:57, Scott Ford <[email protected]> wrote:
> > I am building a branch table like this:
> >
> > FUNC         DS    CL10
> >
> > FUNCTBL   DS   0H
> >                     DC  'INIT      'A(INIT_DSP)
> > ......etc
> > TBLENT      DS   F'5'
> >
> >
> ------------------------------------------------------------------------------
> >
> >                     LA        R4,FUNCTBL
> >                     L          R5,TBLENT
> > LOOPTBL   DS       0H
> >                    CLC     FUNC,0(R4)
> >                    BE       FOUND_IT
> >
> > FOUND_IT DS       0H
> >                    LA        R4,10(R4)
> >                    L          R14,R4
> >                    BALR  R14,R15
> >
> >
> > Is my logic correct ? or did i miss something ?
>
> It's on the right track, but is a little confused...
>
> Your CLC is using the implict length of FUNC, which is 10, so you need
> to be sure all your table entries like DC  'INIT      ' are also (at
> least) 10 bytes long. This is a lot easier to see in a fixed-pitch
> font; yours is correct, but best to specify them as CL10'INIT' to get
> trailing blank padding. Even better would be to define a symbol,
> either an ordinary symbol with an EQU or a variable symbol via SETA,
> to use in all places. Then you can easily change the length of your
> function keywords globally. Something like:
>
> &FunLen SETA 10
> FUNC      DS    CL&FunLen
> ...
>           CL&FunLen'INIT      '
> ...
>           LA    R4,&FunLen(,R4)
>
> I appreciate that it's just a snippet, but your code falls into the
> "found" case. You show no code for the case where the CLC fails. You
> need to increment the table pointer over both the text and the adcon.
>
> But... FUNCTBL starts on a halfword boundary. The assembler will force
> the adcon following the 10 bytes of text to a fullword boundary, which
> may or may not be correct for the first table entry, but will
> certainly be incorrect for each subsequent entry. So when you
> increment by 10 as you search, you will not be pointing at the text in
> the next entry. Either make your text field (&FunLen) a multiple of 4
> (perhaps 8 or 12), or change your adcon to not boundary-align, i.e.
> AL4 rather than just A. Or put the adcon before the text; there are
> several approaches.
>
> TBLENT is a DS rather than a DC. It won't be set to any predictable
> value at run time.
>
> >                    L          R14,R4
> This sets R14 to the address of the adcon in the entry you just found
> in the table (or it would if the above-mentioned boundary alignment
> problem wasn't there). You need
>           L     Rn,0(,R4)
> But in any case you don't want R14 since the immediately following
> BALR sets R14 and branches to the unset R15.
>
> Tony H.
>

Reply via email to