Previous Topic: Coding a COBOL Output ModuleNext Topic: Coding a PL/I Output Module


Coding an Assembler Output Module

The following example writes an 80-byte record.

Output Module

CULLUS93 CSECT
R0       EQU   0
R1       EQU   1
R2       EQU   2
R3       EQU   3
R4       EQU   4
R5       EQU   5
R6       EQU   6
R7       EQU   7
R8       EQU   8
R9       EQU   9
R10      EQU   10
R11      EQU   11
R12      EQU   12
R13      EQU   13
R14      EQU   14
R15      EQU   15
         STM   R14,R12,12(R13)        SAVE CALLER'S REGISTERS
         BALR  R3,0                   ESTABLISH BASE REGISTER
         USING *,R3
         ST    R13,SAVEAREA+4
         LA    R13,SAVEAREA
         ST    R13,SAVEAREA+8
         L     R4,0(R1)               R4 POINTS TO OUTPUT BUFFER
         L     R5,8(R1)               R5 POINTS TO OPEN/CLOSE SW
         CLI   0(R5),X'FF'            IS FILE CLOSED?
         BE    OPEN                   YES
         CLI   0(R5),X'00'            IS FILE OPEN?
         BE    WRITE                  YES
         B     CLOSE
RETURN   EQU    *
         L     R13,SAVEAREA+4      RESTORE REGISTERS
         LM    R14,R12,12(R13)
         BR    R14

SAVEAREA DS    18F                 SAVE REGISTER AREA
OPEN     EQU   *
         OPEN  (OUTPUTFI,OUTPUT)   OPEN OUTPUT FILE
         MVI   0(R5),X'00'         SET OPEN/CLOSE SW TO OPEN
WRITE    EQU   *
         MVC   OUTAREA,0(R4)       MOVE OUTPUT BUFFER TO OUTAREA
         PUT   OUTPUTFI,OUTAREA    WRITE RECORD
         B     RETURN
CLOSE    EQU   *
         CLOSE OUTPUTFI            CLOSE OUTPUT FILE
         MVI   0(R5),X'FF'         SET OPEN/CLOSE SW TO CLOSE
         B     RETURN
OUTAREA  DS    CL80                OUTPUT RECORD
OUTPUTFI DCB   DSORG=PS,MACRF=PM,DDNAME=SYS004,RECFM=FBA,BLKSIZE=80,   X
               LRECL=80
         END   CULLUS93