Ref:  Your note of Thu, 2 Oct 2014 12:14:37 -0400

You can do things like this using OPSYN to intercept standard
definitions (written using DC) and then generate modified
versions (using renamed copies of the original opcodes).

About 25 years ago, when I was younger and more energetic, I
spent several months implementing a robust set of Assembler H
macros which made it possible to define data structures using
standard DC, DS, ORG and EQU in the usual way but to reuse the
same definitions to generate additional instances of the
structure, with or without initial values, and with or without
field names.  This worked for most existing DSECTs and macros as
well as new ones, although they needed to be enclosed in RECORD
and ENDREC macros (which defined a structure, supporting
hierarchical nesting).

I even implemented a LIKE macro which would generate one data
structure like another with systematically prefixed fields, but I
decided not to use it for production code because of
maintainability concerns, partly because I broke the Assembler H
in several ways when doing complicated things using variable
symbols with generated names.

An irritating limitation was the fact that one cannot pick up
the comments from the original statement and re-emit them, which
impacted the usability of the listing for sections where the
statements were being rewritten.  I think that limitation still
exists.

The RECORD and ENDREC macros then recognise options and section
declarations which are used to specify the storage class and
other options to control which format is to be generated.  If a
section is marked "private" then field names within that section
are only generated if the name of the current module is in the
list of "friends" specified on the outer structure definition.

Initialised dynamic structures are supported, either embedded
within a contiguous area of initialised automatic storage or
allocated individually.  These are compiled as separate CSECTs
but copied to dynamic storage when initialised, then the CSECT
version is used as a map of the dynamic storage.  (Read-only
sections were defined using RSECT which was enhanced for HLASM
to perform reentrancy checks even when NORENT was specified).
This was particularly useful for MF=L parameter lists, which
only needed to be defined once.

(Any relocatable addresses pointing within initialised dynamic
storage needed fixing up using a RELOCATE macro which would
subtract the address of the CSECT and add the address of the
dynamic storage area).

A data structure can also include "methods".  The extended
equivalent of the CALL macro detects a call to a method rather
than a procedure, and passes the address of the context data
structure instance in R0 as well as passing the parameters in R1.

Together with many other macros for structured and modular
programming (and other trivial stuff such as extended MVC for
more than 256 bytes) this stuff effectively formed a sort of
"object-oriented assembler".  After using it for some internal
prototyping work, I later used it as the implementation language
for writing a substantial amount of IBM product code (especially
CICS authorised cross-memory server code).  Nowadays IBM would
write that sort of stuff in PL/X.

Unfortunately, I never had the opportunity to make the macros
available externally, and IBM later picked up another set of
structured programming macros which are now available with the
HLASM toolkit.

So HLASM provides the capability to "magically" intercept and
edit statements using OPSYN, but you need to be very cautious
to avoid creating a solution which is more complex than the
original problem.

Jonathan Scott
IBM Hursley, UK

Gary Weinhold wrote:
> I am trying to develop a technique to force a DSECT (describing some
> private control block of mine)  to stay synchronized with the
> inline-constant and space-reserving versions of the same control block.
>
> For example, for DSECT ABC with field definitions of
> ABCID    DS    CL4               Eyecatcher
> ABCLEN   DS    AL2               Length of ABC
> ABCLVL   DS    AL2               ABC modification level
> ABCDATA  DS    F                  Some binary data
> ABCL     EQU   (*-ABCID)
>
> I would like to be able to generate in-line constants:
> label1   DS    0F
>           DC    CL4'EYEC'
>           DC    AL2(ABCL)
>           DC    AL2(1)
>           DC    F'0'
> ABCL     EQU   (*-label1)
>
> and space:
> label2   DS    CL(ABCL)
>
> The DSDC macro generates a labeled DS statements or unlabeled DC
> statements depending on &TYPE; its format is, for example:
> ABCEYE   DSDC  CL4,C'ABCD','EYECATCHER',&TYPE
> ABCLEN   DSDC  AL2,(ABCBLKLN),'LENGTH OF THIS CONTROL BLOCK',&TYPE
>
> Although I started work on this with a macro I call DSDC, I was
> wondering if I'm reinventing the wheel.   Is there a model for this out
> there?
>
> Any suggestions are welcome.
>
> Gary Weinhold
> Data Kinetics, Ltd.

Reply via email to