With the help of you fine people in this list I've created a basic macro for
use with LE enabled assembler routines. It's called AUTOSTG and has the
following options:
- AUTOMAIN AUTOSTG DSECT=START
This creates a DSECT for my LE "automatic (stack) storage". The DSECT is named
@AUTOMAIN and it is given a "starting point" at the end of CEEDSA, as is
required by LE.
- AUTOMAIN AUTOSTG DSECT=END
This creates an alias named AUTOMAIN for the DSECT named @AUTOMAIN. This alias
has a defined length of the length of the @AUTOMAIN DSECT. This allows me to
do the following:
ASMCEE CEEENTRY MAIN=YES,AUTO=L'AUTOMAIN
Note that the AUTO parm is set to the length of the @AUTOMAIN/AUTOMAIN DSECT.
This is why I was wanting the length of the DSECT field to be, well, the length
of the DSECT. :-) But the recommended workaround works (almost!) just as well.
DSECT=END also inserts a CSECT instruction with the label of the "current"
CSECT, in order to terminate the auto storage DSECT.
- AUTOMAIN AUTOSTG USING=YES
This inserts a USING statement to address the AUTOMAIN area. It uses a
dependent USING so that both the CEEDSA DSECT and the automatic storage are
addressable at the same time.
You can, if you like (I do), use these to place your automatic storage DSECT
definition "inside" of your code area by doing something like this:
ASMCEE CEEENTRY MAIN=YES,AUTO=L'AUTOMAIN
*
AUTOMAIN AUTOSTG DSECT=START
[...automatic storage fields here...]
AUTOMAIN AUTOSTG DSECT=END,USING=YES
*
MAINLINE DS 0H
[...mainline code starts here...]
This generates the following open code, following the CEEENTRY:
+@AUTOMAIN DSECT ,
+ ORG *+CEEDSASZ Leave space for the DSA fixed part
[...automatic storage fields here...]
+AUTOMAIN EQU @AUTOMAIN,*-@AUTOMAIN
+ASMCEE CSECT , Continue primary CSECT
+ USING AUTOMAIN,CEEDSA Auto stg and DSA use the same base
*
MAINLINE DS 0H
[...mainline code starts here...]
Here is the macro. It has little error checking. Didn't feel the need at this
point.
MACRO
&LABEL AUTOSTG &DSECT=,&USING=NO
GBLC &CEEOEPVNX Label of Main Entry; from CEEENTRY
LCLC &AUTOSECT
&AUTOSECT SETC '@&LABEL'
.DSECT ANOP ,
AIF ('&DSECT' EQ 'START').START
AIF ('&DSECT' EQ 'END').END
AGO .CHKUSING
MEXIT ,
.**********************************************************************
.* DSECT=START *
.**********************************************************************
.START ANOP ,
&AUTOSECT DSECT ,
ORG *+CEEDSASZ Leave space for the DSA fixed part
AGO .CHKUSING
.**********************************************************************
.* DSECT=END *
.**********************************************************************
.END ANOP ,
LCLC &OEPVNX
&LABEL EQU &AUTOSECT,*-&AUTOSECT
&OEPVNX SETC '&CEEOEPVNX'
AIF ('&OEPVNX' EQ '').CHKUSING
&OEPVNX CSECT , Continue primary CSECT
.**********************************************************************
.CHKUSING AIF ('&USING' NE 'YES').EXIT
.**********************************************************************
.* USING=YES *
.**********************************************************************
USING &LABEL,CEEDSA Auto stg and DSA use the same base
.EXIT MEXIT
.**********************************************************************
MEND
I've written a little test program to demonstrate its usage. This will be
posted in a separate email, because apparently this listserv doesn't like
emails of more then 250 lines!