Page 1 of 1

Conditional Assemble GBL(x) Definition

PostPosted: Tue Aug 24, 2021 7:19 am
by papadilbert
I'm attempting to dust off a few brain cells.

How do I concatenate the GBLB variable name using 2 variables?

I'm writing a data macro (DSECT) that I want to suffix.
the GBLB really needs to be something like &MYMAC&SUF to set/check the global if I've already called the macro with this suffix.

I'm thinking that I can set a
GBLA &MAC
&MAC SETA C'MYMAC'
GBLB &MAC&SUF

...
&MAC&SUF SETB 1
...
IF(&MAC&SUF.1).AGO .SKIP

How do I concatenate the GBLB variable name using 2 variables?


       MACRO
        MYMAC &REG,&SUF
        GBLB   &SFX
        AIF   (&SFX.1).AGO .SKIP
  MYMAC&SUF DSECT
ALAB1&SUF DS   CL5
ALAB2&SUF DS   CL10
.SKIP  ANOP
         USING  MYMAC&SUF,&REG
&SFX  SETB   1
         MEND


       MYMAC  REG=1,SUF=IN
       MYMAC  REG=2,SUF=OUT
....
       MYMAC  REG=3,SUF=IN

Re: Conditional Assemble GBL(x) Definition

PostPosted: Tue Aug 24, 2021 1:18 pm
by willy jensen
Logically speaking you cannot concatenate two bits as the result would not be a bit, but part of a byte.
You can only concatenate GBLCs and LCLCs, so you could do like this:
         gblb  &b1,&b2
         lclc  &c1          
&b1      setb  1            
&b2      setb  1            
&c1      setc  '&b1&b2'    
          aif   ('&c1' eq '10').first

But personally I would use AND / OR in the test like
  AIF (&GB1 AND &GB2).BOTH

Re: Conditional Assemble GBL(x) Definition

PostPosted: Tue Aug 24, 2021 10:21 pm
by steve-myers
Certainly you can can build a variable, like this -
        MACRO
&PREFIX  GENDSECT
         GBLB  &CNTR
         LCLC  &NAME
&NAME    SETC  '&PREFIX&CNTR'
&NAME    DSECT                
&NAME    SETC  '&PREFIX.A&CNTR'
&NAME    DS    CL8
&NAME    SETC  '&PREFIX.B&CNTR'
&NAME    DS    F
&NAME    SETC  '&PREFIX.C&CNTR'
&NAME    DS    F
         MEND
         GBLB &CNTR
S        GENDSECT
&CNTR    SETB (1)
T        GENDSECT
         END

I prefer to create the additional symbol in the way I used in my macro definition: it produces a more pleasing expansion -

                                     14          GBLB &CNTR
                                     15 S        GENDSECT
000000                00000 00010    16+S0       DSECT
000000                               17+SA0      DS    CL8
000008                               18+SB0      DS    F
00000C                               19+SC0      DS    F
                                     20 &CNTR    SETB (1)
                                     21 T        GENDSECT
000000                00000 00010    22+T1       DSECT
000000                               23+TA1      DS    CL8
000008                               24+TB1      DS    F
00000C                               25+TC1      DS    F
                                     26          END