Data-in-virtual sample program code

The first part of DIVSAMPL identifies the linear data set and accesses the object. If the object is not empty, the program obtains the virtual storage required to view (MAP) the entire object. Then it opens the input and message sequential data sets.
DIV      TITLE 'Data-in-Virtual Sample Program'
DIVSAMP  CSECT ,
DIVSAMP  AMODE 31                  Program runs in 31-bit mode
DIVSAMP  RMODE 24                  Program resides in 24-bit storage
         SAVE  (14,12),,'DIVSAMP -- Sample Program'
         LR    R11,R15             Establish base register
         USING DIVSAMP,R11         *
         LA    R2,VSVEAREA         Chain save areas together
         ST    R13,4(,R2)          *
         ST    R2,8(,R13)          *
         LR    R13,R2              *
* IDENTIFY and ACCESS the object pointed to by DD 'DIVDD'.
* Save the object's token in VTOKEN, and its size in VSIZEP.
         DIV   IDENTIFY,TYPE=DA,ID=VTOKEN,DDNAME=CDIVDD Specify DDNAME
         LA    R2,1                Error code
         LTR   R15,R15             IDENTIFY work ok ?
         BNZ   LERROR              * No -- quit
         DIV   ACCESS,ID=VTOKEN,MODE=UPDATE,SIZE=VSIZEP Open the object
         LA    R2,2                Error code
         LTR   R15,R15             ACCESS work ok ?
         BNZ   LERROR              * No -- quit
* If object not empty (VSIZEP > 0), get workarea to hold the object,
* and issue a MAP to it. The area must start on page boundary.
* Referencing byte "n" of this workarea gets byte "n" of the object.
         L     R2,VSIZEP           Current size (in 4K blocks)
         SLA   R2,12               Current size (in bytes)
         ST    R2,VSIZEB           VSIZEB = object size in bytes
         BZ    LEMPTY              If object not empty, get MAP area =
         GETMAIN RU,LV=(R2),LOC=(ANY,ANY),BNDRY=PAGE object size
         ST    R1,VAREAPTR         Save MAP area
         DIV   MAP,ID=VTOKEN,AREA=VAREAPTR,SPAN=VSIZEP
         LA    R2,3                Error code
         LTR   R15,R15             MAP work ok ?
         BNZ   LERROR              * No -- quit
LEMPTY   EQU   *                   Mapped, unless empty
* OPEN the SYSIN input data set, and SYSPRINT listing data set.
* Must be in 24-bit mode for this.  Then return to 31-bit mode.
         LA    R4,L31B01           Return to L31B01 in 31-bit mode
         LA    R1,L24B01           Go to L24B01 in 24-bit mode
         BSM   R4,R1               R4 = A(X'80000000'+L31B01)
L24B01   OPEN  (VSYSIN,(INPUT),VSYSPRT,(OUTPUT)) OPEN SYSIN/SYSPRINT
         BSM   0,R4                Return to 31-bit mode at next instr
L31B01   LA    R2,4                Error code from SYSIN OPEN
         LTR   R15,R15             OPEN ok ?
         BNZ   LERROR              * No -- quit