If I understand correctly, you have a work area of known length and a macro
that will build code.  You want an assembly "trick" what will confirm the
length of the generated code fits or lets you know if it doesn't.

Two approaches come to mind

1 - At the point where the macro generates the first byte of code, insert an
instruction of the form
                ST&SYSNDX DS 0H
If you need stronger alignment you could use 0F or 0D.  If alignment has
already been handled, you could use 0x to avoid disturbing it.  The intent
is to have a symbol that points to the start of the code.  Similarly, at the
end of the generated code, insert an instruction of the form
                EN&SYSNDX DS 0X
Change the alignment if needed to satisfy the method you use to move the
code into the work area.  The intent is to have symbol that points one past
the end of your code.  Immediately following this statement insert
                                          DS
0AL(MACRO_PARM_SPECIFYING_LENGTH -(EN&SYSNDX-ST&SYSNDX)+1)
If the generated code does not fit, the length will evaluate to a
non-positive value which will generate an assembler error.  (The +1 deals
with the situation where the generated code just fits.)  If the code does
fit, the 0 factor insures no memory is wasted.

2 - (Not recommended: too much work and error prone)  If the known length is
a self-defining term, you could keep a running total and test it whenever
you feel it is appropriate.  At the beginning of the macro, create a LCLA
variable (defaults to 0).  After each generated statement, increment the
variable by the number of bytes that statement generates.  To test, use 
                                         AIF (CURRENT_LENGTH >
KNOWN_LENGTH).MNOTE_STATEMENT_TO_SET_CONDITION_CODE

> -----Original Message-----
> From: IBM Mainframe Assembler List [mailto:ASSEMBLER-
> l...@listserv.uga.edu] On Behalf Of Peter Hunkeler
> Sent: Saturday, August 16, 2014 5:33 AM
> To: ASSEMBLER-LIST@LISTSERV.UGA.EDU
> Subject: How to assign length of generated instructions to macro variable?
> 
> Hello list members,
> 
> This is my first post to this list. I've been working on MVS for some
decades
> and have been an active member of IBM-MAIN for many years. This time I
> need some help with an assembler macro. In former times I've programmed
> in assembler quit a lot. However, this knowledge is a bit rusty.
> 
> I want to modify a macro I've written long ago to generate reentrant code.
> For that, I'm asking for two new parameters: WORKA= and WORKL=, the
> address of a workarea (in dynamically allocated storage) for the macroo
use,
> and the length of that area.
> 
> The code generated varies in length, depending n what parms are specified
> on the macro. Some of what he code does is to generate list forms of other
> macros inline plus the instructions to move that part to the workarea,
where
> it can be further modified by my macro.
> 
> I want the macro to check that the length of the code generated does not
> exeed the length of the workarea as indicatedby WORKL=.
> 
> I have not come up with a way to get the length of  a code section the
macro
> generated into macro variables, so that I can compare to WORKL= and abort
> if neccessary.

Reply via email to