At IBM, I created some macros to make programming simpler, including CODE and 
DATA macros to switch between different types of storage, with a specific 
option (DATA AUTO) for initialised automatic storage variables (as opposed to 
DATA WORK for uninitialized automatic storage).  This area was defined as a 
CSECT, but the procedure initialisation code allocated a dynamic storage area 
for automatic storage which included space for the initialised automatic 
variables, then copied the CSECT contents into that area with MVCL and used a 
dependent USING to base the CSECT at the appropriate offset within the 
automatic storage area.  This was particularly useful for MF=L macro 
expansions.  The only thing to watch out for was that any address constants 
pointing within that initialised section would of course point within the 
initial value CSECT, not the dynamic copy, and would need to be relocated (but 
I had a macro for that too, which would adjust a specified field by the 
difference between the CSECT address and the initialised dynamic section 
address).  The macros also supported initialised heap storage by a similar 
mechanism, so you could just use ALLOCATE MYSTRUCT to allocate a new 
initialised instance and put its address in the register currently established 
as a USING base for that structure (via a somewhat devious trick).  The initial 
value was always addressed via an A-type constant.

But if performance is important, an in-line sequence of fixed-length MVCs 
moving 256 bytes at a time has always been somewhat faster than variable-length 
moves such as MVCL (including setting up the registers), and I expect that's 
still true.  

Jonathan Scott

Reply via email to