Coding a batch program in assembler language

The following code example shows how to write an IMS™ program to access the IMS database in assembler language.

The numbers to the right of the program refer to the notes that follow the program. This kind of program can run as a batch program or as a batch-oriented BMP.

Sample assembler language program

PGMSTART CSECT                                                               NOTES
*               EQUATE REGISTERS                                               1
*   USEAGE OF REGISTERS
R1       EQU   1              ORIGINAL PCBLIST ADDRESS
R2       EQU   2              PCBLIST ADDRESS1
R5       EQU   5              PCB ADDRESSS
R12      EQU   12             BASE ADDRESS
R13      EQU   13             SAVE AREA ADDRESS
R14      EQU   14
R15      EQU   15
*   
         USING PGMSTART,R12   BASE REGISTER ESTABLISHED                        2
         SAVE  (14,12)        SAVE REGISTERS
         LR    12,15          LOAD REGISTERS
         ST    R13,SAVEAREA+4 SAVE AREA CHAINING
         LA    R13,SAVEAREA   NEW SAVE AREA
         USING PCBLIST,R2     MAP INPUT PARAMETER LIST     
         USING PCBNAME,R5     MAP DB PCB
         LR    R2,R1          SAVE INPUT PCB LIST IN REG 2 
         L     R5,PCBDETA     LOAD DETAIL PCB ADDRESS 
         LA    R5,0(R5)       REMOVE HIGH ORDER END OF LIST FLAG               3
         CALL  ASMTDLI,(GU,(R5),DETSEGIO,SSANAME),VL                           4
*
*
         L     R5,PCBMSTA     LOAD MASTER PCB ADDRESS
         CALL  ASMTDLI,(GHU,(R5),MSTSEGIO,SSAU),VL                             5
*
*
         CALL  ASMTDLI,(GHN,(R5),MSTSEGIO),VL                                  6
*
*
         CALL  ASMTDLI,(REPL,(R5),MSTSEGIO),VL
*
*
         L     R13,4(R13)     RESTORE SAVE AREA
         RETURN (14,12)     RETURN BACK                                        7 
*
*     FUNCTION CODES USED
*
GU       DC    CL4'GU' 
GHU      DC    CL4'GHU'
GHN      DC    CL4'GHN' 
REPL     DC    CL4'REPL'                                                       8 
*
*       SSAS
*
SSANAME  DS    0C
         DC    CL8'ROOTDET' 
         DC    CL1'('
         DC    CL8'KEYDET'                                                      9
         DC    CL2' ='
NAME     DC    CL5'  '
         DC    C')'
*
SSAU     DC    CL9'ROOTMST'*
MSTSEGIO DC    CL100' '
DETSEGIO DC    CL100' '  
SAVEAREA DC    18F'0'
*                                                                                10
PCBLIST  DSECT
PCBIO    DS    A              ADDRESS OF I/O PCB
PCBMSTA  DS    A              ADDRESS OF MASTER PCB
PCBDETA  DS    A              ADDRESS OF DETAIL PCB                              11 
*
PCBNAME  DSECT
DBPCBDBD DS    CL8            DBD NAME
DBPCBLEV DS    CL2            LEVEL FEEDBACK
DBPCBSTC DS    CL2            STATUS CODES
DBPCBPRO DS    CL4            PROC OPTIONS
DBPCBRSV DS    F              RESERVED
DBPCBSFD DS    CL8            SEGMENT NAME FEEDBACK
DBPCBMKL DS    F              LENGTH OF KEY FEEDBACK
DBPCBNSS DS    F              NUMBER OF SENSITIVE SEGMENTS IN PCB
DBPCBKFD DS    C              KEY FEEDBACK AREA
         END   PGMSTART
Note:
  1. The entry point to an assembler language program can have any name. Also, you can substitute CBLTDLI for ASMTDLI in any of the calls.
  2. When IMS passes control to the application program, register 1 contains the address of a variable-length fullword parameter list. Each word in this list contains the address of a PCB that the application program must save. The high-order byte of the last word in the parameter list has the 0 bit set to a value of 1 which indicates the end of the list. The application program subsequently uses these addresses when it executes DL/I calls.
  3. The program loads the address of the DETAIL DB PCB.
  4. The program issues a GU call to the DETAIL database using a qualified SSA (SSANAME).
  5. The program loads the address of the HALDB master PCB.
  6. The next three calls that the program issues are to the HALDB master. The first is a GHU call that uses an unqualified SSA. The second is an unqualified GHN call. The REPL call replaces the segment retrieved using the GHN call with the segment in the MSTSEGIO area.

    You can use the parmcount parameter in DL/I calls in assembler language instead of the VL parameter, except for in the call to the sample status-code error routine.

  7. The RETURN statement loads IMS registers and returns control to IMS.
  8. The call functions are defined as four-character constants.
  9. The program defines each part of the SSA separately so that it can modify the SSA's fields.
  10. The program must define an I/O area that is large enough to contain the largest segment it is to retrieve or insert (or the largest path of segments if the program uses the D command code). This program's I/O areas are 100 bytes each.
  11. A fullword must be defined for each PCB. The assembler language program can access status codes after a DL/I call by using the DB PCB base addresses.

    This example assumes that an I/O PCB was passed to the application program. If the program is a batch program, CMPAT=YES must be specified on the PSBGEN statement of PSBGEN so that the I/O PCB is included. Because the I/O PCB is required for a batch program to make system service calls, CMPAT=YES should always be specified.

Restriction: The IMS language interface module (DFSLI000) must be bound to the compiled assembler language program.