Home Back to 370 Assembler Tips & Tricks Index Links

Coding and using OS/390 (MVS) DCB's in 31-Bit mode

All too frequently I see some of the most bizarre ideas when it comes to 31-Bit assembler modules that need to use general purpose Data Control Blocks - DCB's (SYSIN and SYSPRINT, for example).

Many programmers are confused because they know that the actual DCB must reside in 24-Bit storage.  What confuses them is that they then sometimes believe that the program that uses the DCB must also reside in 24-Bit storage or that they must temporarily set the program's addressing mode to 24-Bit mode.  Both beliefs are incorrect!

Be sure to see the related tutorial that discusses mixing 31-Bit CSECT's and 24-Bit CSECT's in a single load module.

The following outlines all that is necessary to use DCB's in 31-Bit programs:

  • Code your DCB's in a separate module with 31-Bit AMODE and 24-Bit RMODE directives.
    This will provide 31-Bit addressing in the DCB module and force the OS/390 (MVS) loader to load the DCB module into 24-Bit storage.

  • Set up address constants (ADCON's) at the entry point of your DCB module to point to the individual DCB's inside the module.

  • Code your actual program with 31-Bit AMODE and ANY RMODE directives.
    Your module will then use 31-Bit addressing and the OS/390 loader will load it into any available storage (24-Bit or 31-Bit).

  • Within your program, simply issue an operating system LOAD to load your assembled and link edited DCB module into 24-Bit storage.

  • Set a 31-Bit end of data address (EODAD) for any input DCB's by finding the DCBE for the input DCB and setting the EODAD to an entry point somewhere in your program.

Here's a sample DCB module:


STDDCB   TITLE 'Standard DCB Module.'
*---------------------------------------------------------------------*
*        Private code Copyright preamble.                             *
*---------------------------------------------------------------------*
         CSECT ,                   Private Code CSECT.
         AMODE 31                  Set 31-Bit Addressing mode.
         RMODE 24                  Set 24-Bit Residency mode.
         DC    C'Assembly date && time: &SYSDATE &SYSTIME '
         DC    C'Copyright (C) 1993-2003, Marc Niegowski '
         DC    C'Systems Programmer At Large '
         DC    C'All Rights Reserved.'
         SPACE ,
*---------------------------------------------------------------------*
*        Standard DCB Module.                                         *
*---------------------------------------------------------------------*
STDDCB   CSECT ,                   Standard DCB module CSECT.
STDDCB   AMODE 31                  Set 31-Bit Addressing mode.
STDDCB   RMODE 24                  Set 24-Bit Residency mode.
*
*        Marc Reibstein's vector table.
*
         DC    A(STDSPR)       +00 Vector to standard SYSPRINT DCB.
         DC    A(STDSIN)       +04 Vector to standard SYSIN DCB.
         DC    A(0)            +08 End of Vector table.
         EJECT ,
*---------------------------------------------------------------------*
* SYSPRINT DCB.                                                       *
*---------------------------------------------------------------------*
         DC    C'SYSPRINT DCB.'
STDSPR   DCB   DDNAME=SYSPRINT,    Standard SYSPRINT DD.               C
               DCBE=STDSPX,        Standard SYSPRINT DCB extension.    C
               LRECL=133,          132 Char lines + 1 byte CC.         C
               DSORG=PS,           Physical sequential organization.   C
               RECFM=FBA,          Fixed, blocked ANSI control chars.  C
               MACRF=(PM)          Put macro, move mode.
         SPACE ,
*---------------------------------------------------------------------*
* SYSPRINT DCB Extension                                              *
*---------------------------------------------------------------------*
         DC    C'SYSPRINT DCB Extension.'
STDSPX   DCBE  RMODE31=BUFF        31-Bit Buffer addressing.
         EJECT ,
*---------------------------------------------------------------------*
* SYSIN DCB.                                                          *
*---------------------------------------------------------------------*
         DC    C'SYSIN DCB.'
STDSIN   DCB   DDNAME=SYSIN,       Standard SYSIN DD.                  C
               DCBE=STDSIX,        Standard SYSIN DCB extension.       C
               LRECL=80,           80 Byte input cards.                C
               DSORG=PS,           Physical sequential organization.   C
               RECFM=FB,           Fixed, blocked.                     C
               MACRF=(GL)          Get macro, locate mode.
         SPACE ,
*---------------------------------------------------------------------*
* SYSIN DCB Extension.                                                *
*---------------------------------------------------------------------*
         DC    C'SYSIN DCB Extension.'
STDSIX   DCBE  EODAD=0,            31-Bit End of Data address.         C
               RMODE31=BUFF        31-Bit Buffer addressing.
         SPACE ,
*---------------------------------------------------------------------*
         END   STDDCB              End of Assembly.
         PUNCH ' MODE AMODE(31)'   Binder AMODE statement.
         PUNCH ' MODE RMODE(24)'   Binder RMODE statement.
         PUNCH ' ENTRY STDDCB'     Binder Module Entry Point.
         PUNCH ' NAME STDDCB(R)'   Binder Module Name.
         END ,                     End of Binder Input.

If you assemble and bind (link edit) the above module, your 31-Bit assembler program will be able to load it into a 24-Bit storage pool and use the DCB's directly.

Notice the PUNCH pseudo-ops at the end of the source module above.  These statements will generate the appropriate binder (linkage editor) control cards so that the module is link edited with a 31-Bit addressing mode and 24-Bit residency.

Also, be sure to link your DCB module without the re-entrant attribute (NORENT).

Here's some sample code that illustrates using a DCB module like the one shown above:


IOMOD    CSECT ,                   An I/O module CSECT.
IOMOD    AMODE 31                  Set 31-Bit addressing mode.
IOMOD    RMODE ANY                 Set ANY (24 or 31-Bit) residency.
         ENTRY IOMODEP             I/O module entry point.
           .
           .
           .
         LOAD  EP=STDDCB           Load our standard DCB module.
         LR    R1,R0               Get the load address of the module.
         L     R3,0(,R1)           Use R3 for our SYSPRINT DCB.
         L     R4,4(,R1)           Use R4 for our SYSIN DCB.
           .
           .
           .
PRINT    DS    0H                  Print routine.
         USING IHADCB,R3           Establish DCB DSECT addressability.
         OPEN  ((R3),OUTPUT),      Open SYSPRINT for output.           C
               MODE=31             31-Bit addressing mode.
         TM    DCBOFLGS,DCBOFOPN   Did SYSPRINT open?
         BNO   PRERR               No, Branch to some error handler.
           .
           .
           .
         PUT   (R3),OUTPUT         Write some output to SYSPRINT.
           .
           .
           .
         CLOSE ((R3)),             Close SYSPRINT.                     C
               MODE=31             31-Bit addressing mode.
         DROP  R3                  Drop IHADCB.
           .
           .
           .
READ     DS    0H                  Read routine.
         USING IHADCB,R4           Establish DCB DSECT addressability.
         L     R1,DCBDCBE          Load A(SYSIN DCBE).
         USING DCBE,R1             Establish DCBE addressability.
         MVC   DCBEEODA,=A(ENDATA) Set our 31-Bit EODAD.
         DROP  R1                  Drop DCBE.
         OPEN  ((R4),INPUT),       Open SYSIN for input.               C
               MODE=31             31-Bit addressing mode.
         TM    DCBOFLGS,DCBOFOPN   Did SYSIN open?
         BNO   REERR               No, Branch to some error handler.
           .
           .
           .
         GET   (R4)                Read some input from SYSIN.
         MVC   INPUT,0(R1)         Our input data is at R1.
           .
           .
           .
ENDATA   DS    0H                  End of data routine (EOD).
         CLOSE ((R4)),             Close SYSIN.                        C
               MODE=31             31-Bit addressing mode.
         DROP  R4                  Drop IHADCB.
           .
           .
           .
         DCBD  DSORG=(PS)          DCB DSECT (IHADCB).
         IHADCBE                   DCBE DSECT.
           .
           .
           .
         END   IOMODEP             End of module.

A very good friend of mine, Marc Reibstein, came up with the technique to place address constants (ADCON's) at the beginning of the DCB module to provide addressability to the individual DCB's.

Marc Reibstein is a senior systems programmer for whom I have a great deal of respect and from whom I have learned much over the past 20 years or so.

Before he suggested the address constant technique to me, I used all manner of ugly techniques to address the individual DCB's within a DCB module.  Thank you Marc Reibstein.

Kie Muzyka pointed out some typo's in my example where I had inadvertently coded "DCBEODA" instead of "DCBEEODA" and forgotten to add the "MODE=31" on the "CLOSE" macro's.  Thank you for your corrections, Kie.

Joachim Appel pointed out another typo where I had coded "CLOSE (Rn),MODE=31" instead of "CLOSE ((Rn)),MODE=31".  Thank you for pointing this error out, Joachim.

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:03:57 AM