Home Back to 370 Assembler Tips & Tricks Index Links

Let the Assembler work for you

Recently, (August 2001) I read an article entitled "Assembler Programming Revisited" by a systems programmer from whom I have learned much and for whom I have a great deal of respect.

In this article, however, I disagree with him strongly.  He cites an example where one might need to define a print line as 0CL133 and in doing so, incorrectly define the 133 bytes that must follow.  If you define fewer than 133 bytes within the scope of the 0CL133, fields following the 0CL133 can potentially be overlaid.

This systems programmer suggests that you should "pad" the 0CL133 with perhaps an extra 30 bytes or so.  To use that systems programmer's expression, with all due respect. . ."malarkey!"

The correct way to ensure that your print line (or any other data area consisting of multiple fields) occupies as many bytes as you intended, is to let the assembler do it for you.

You can accomplish this using the ORG pseudo-op as follows:

 


WORKDS  DSECT  ,                   Working Storage DSECT.
           .
           .
           .
PRINTLN  DS    CL133               Print line.
         ORG   PRINTLN             Set Origin to start of line.
PRLNCC   DS    C                   Print line CC.
         SPACE ,
PRNTLN1  EQU   *                   Report Line 1.
         ORG   *+4                 4  Byte Margin.
PRL1FL1  DS    CL8                 8  Byte Field 1.
         ORG   *+4                 4  Byte Margin.
PRL1FL2  DS    CL16                16 Byte Field 2.
         ORG   *+4                 4  Byte Margin.
PRL1FL3  DS    CL12                12 Byte Field 3.
         SPACE ,
         ORG   PRINTLN+1
PRNTLN2  EQU   *                   Report Line 2.
         ORG   *+4                 4  Byte Margin.
PRL2FL1  DS    CL80                80 Byte Field 1.
         ORG   *+4                 4  Byte Margin.
PRL2FL2  DS    CL8                 8  Byte Field 2.
         ORG   *+4                 4  Byte Margin.
PRL2FL3  DS    CL8                 8  Byte Field 3.
         ORG   *+4                 4  Byte Margin.
PRL2FL4  DS    CL8                 8  Byte Field 4.
         SPACE ,
         ORG   PRINTLN+1
PRNTLN3  EQU   *                   Report Line 3.
         ORG   *+4                 4  Byte Margin.
PRL3FL1  DS    CL2                 2  Byte Field 1.
         ORG   *+4                 4  Byte Margin.
PRL3FL2  DS    CL2                 2  Byte Field 2.
         ORG   *+4                 4  Byte Margin.
PRL3FL3  DS    CL12                12 Byte Field 3.
         ORG   *+4                 4  Byte Margin.
PRL3FL4  DS    CL6                 6  Byte Field 4.
         ORG   *+4                 4  Byte Margin.
PRL3FL5  DS    C                   1  Byte Field 5.
         ORG   ,                   Reset Origin.
         SPACE ,
WORKFL1  DS    XL5                 Any work field(s).
           .
           .
           .
*                                  End of DSECT.

In the above example, three different report lines redefine the report line buffer named PRINTLN.

Before you move any data to the report line fields, you should initialize the report line to blanks as follows: 


INITPL   DS    0H                  Initialize the report line.
         MVI   PRLNCC,X'40'        Set the first byte to a blank.
         MVC   PRLNCC+1(L'PRINTLN-1),PRLNCC  Clear entire area.

I will continue to add tips and techniques as time permits.

Please direct any inquiries or problems regarding this web to webmaster@marcsweb.com


Page design, composition and HTML by Marc Niegowski
Copyright © 1998-2012, Marc Niegowski - Connectivity, Inc., All Rights Reserved
23 W. Fourth Street • Media • Pennsylvania • 19063-2805 • USA
Phone: 610-566-0227 • Fax: 610-566-0641 • Email: Marc@Tech-Center.com

Revision Date: Wednesday, November 15, 2006 10:02:53 AM