BSAM

Home Up Search Credits Site Map Contact Info. Links Disclaimer Download

Below is a sample BSAM program.  You may download the program here.

 

         TITLE 'BSAM I/O EXAMPLE'                                       00010000
BSAMIO   CSECT                                                          00020000
         XSAVE                                                          00030000
         SPACE 5                                                        00040000
*********************************************************************** 00050000
*        OPEN ALL DCBS, CARDCB TO READ DATA, PRNTDCB TO ALLOW         * 00060000
*        WRITE TO THE PRINTER, AND THE INTERMEDIATE DISK              * 00070000
*        STORAGE.  OUTIN OPTION IN OPEN MACRO ALLOWS A WRITE          * 00080000
*        OPERATION FOLLOWED BY A READ OPERATION WITHOUT AN            * 00090000
*        ADDITIONAL OPEN-CLOSE SET.                                   * 00100000
*********************************************************************** 00110000
         SPACE 5                                                        00120000
*********************************************************************** 00130000
*        REGISTERS USED                                               * 00140000
*        R0    SYSTEM                                                 * 00150000
*        R1    SYSTEM - PARM POINTER                                  * 00160000
*        R2      AVAILABLE                                            * 00170000
*        R3      AVAILABLE                                            * 00180000
*        R4      AVAILABLE                                            * 00190000
*        R5    CARD COUNTER                                           * 00200000
*        R6      AVAILABLE                                            * 00210000
*        R7      AVAILABLE                                            * 00220000
*        R8      AVAILABLE                                            * 00230000
*        R9      AVAILABLE                                            * 00240000
*        R10     AVAILABLE                                            * 00250000
*        R11     AVAILABLE                                            * 00260000
*        R12     AVAILABLE                                            * 00270000
*        R13   SYSTEM - SAVE AREA                                     * 00280000
*        R14   SYSTEM - RETURN ADDRESS                                * 00290000
*        R15   SYSTEM - ENTRY POINT                                   * 00300000
*********************************************************************** 00310000
OPENDCBS OPEN  (CARDCB,(INPUT),PRNTDCB,(OUTPUT),DISKDCB,(OUTIN))        00320000
*                                                                       00330000
*        TEST THE OPEN, IF OPENS DID NOT GO, TERMINATE WITH ABEND       00340000
*        GIVE THE USER A 500 ABEND CODE                                 00350000
*                                                                       00360000
         TM    CARDCB+48,X'10'     DID THE CARD READER OPEN OK?         00370000
         BNO   ABTERM              NO GO     ABEND THE JOB              00380000
         TM    PRNTDCB+48,X'10'    DID PRINTER OPEN OK?                 00390000
         BNO   ABTERM              NO GO     ABEND THE JOB              00400000
         TM    DISKDCB+48,X'10'    DID THE DISK OPEN OK?                00410000
         BNO   ABTERM              NO GO     ABEND THE JOB              00420000
*                                                                       00430000
* READ A CARD FROM THE READER                                           00440000
*                                                                       00450000
*                                                                       00460000
* READ A CARD FROM THE READER                                           00470000
*                                                                       00480000
         XR    R5,R5               SET CARD COUNTER TO ZERO             00490000
READ     READ  CARDECB,SF,CARDCB,BLOCK   READ A CARD IMAGE INTO BLOCK   00500000
         CHECK CARDCB              CHECK FOR I/O COMPLETION             00510000
         LA    R5,1(R5)            ADD ONE TO THE CARD COUNTER          00520000
*                                                                       00530000
*        WRITE THE CARD IMAGE TO THE DISK FILE                          00540000
*                                                                       00550000
         WRITE DISKDECB,SF,DISKDCB,BLOCK  WRITE TO DISK                 00560000
         CHECK DISKDECB                                                 00570000
         WRITE PRNTDECB,SF,PRNTDCB,BLOCK-1                              00580000
         CHECK PRNTDCB                                                  00590000
         B     READ                                                     00600000
*                                                                       00610000
*        PRINT A LITERAL INDICATING EOD ON CARD READER, BEGIN           00620000
*        READING FROM THE DISK                                          00630000
*                                                                       00640000
ENDATA   WRITE PRNTDEC1,SF,PRNTDCB,LITERAL                              00650000
         CHECK PRNTDEC1                                                 00660000
*                                                                       00670000
*        SINCE DISK DCB WAS NOT CLOSED AT EOD A POINT MACRO MUST        00680000
*        BE ISSUED TO REPOSITION THE DISK AT THE FRIST RECORD.          00690000
*                                                                       00700000
         POINT DISKDCB,POINT                                            00710000
*                                                                       00720000
*        NOW READ FROM DISK AND WRITE TO PRINTER, USING SAME DATA       00730000
*                                                                       00740000
DISKRD   READ  DISKDEC1,SF,DISKDCB,BLOCK                                00750000
         CHECK DISKDEC1                                                 00760000
*                                                                       00770000
*        WRITE TO PRINTER                                               00780000
*                                                                       00790000
         WRITE PRNTDEC2,SF,PRNTDCB,BLOCK-1                              00800000
         CHECK PRNTDEC2                                                 00810000
         BCT   R5,DISKRD           REDUCE COUNTER TILL ZERO AND LOOP    00820000
END      CLOSE (CARDCB,,PRNTDCB,,DISKDCB)  CLOSE ALL ACTIVE DCBS        00830000
         XRETURN                                                        00840000
*                                                                       00850000
*        ABEND ROUTINE WITH A DUMP                                      00860000
*                                                                       00870000
ABTERM   ABEND 500,DUMP                                                 00880000
         DC    0F'0'                                                    00890000
POINT    DC    X'00000100'                                              00900000
         DC    C' '  ASA CARRIAGE CONTROL CHARACTER                     00910000
BLOCK    DC    80C' '                                                   00920000
LITERAL  DC    C'-REPEAT READ DATA FROM DISK',80C' '                    00930000
         SPACE 5                                                        00940000
CARDCB   DCB   RECFM=F,                                                X00950000
               BLKSIZE=80,                                             X00960000
               DDNAME=SYSIN,                                           X00970000
               EODAD=ENDATA,                                           X00980000
               SYNAD=ABTERM,                                           X00990000
               MACRF=(R),                                              X01000000
               DSORG=PS                                                 01010000
PRNTDCB  DCB   RECFM=FA,                                               X01020000
               BLKSIZE=80,                                             X01030000
               LRECL=80,                                               X01040000
               DDNAME=SYSPRINT,                                        X01050000
               SYNAD=ABTERM,                                           X01060000
               DSORG=PS,                                               X01070000
               MACRF=(W)                                                01080000
DISKDCB  DCB   RECFM=F,                                                X01090000
               BLKSIZE=80,                                             X01100000
               LRECL=80,                                               X01110000
               DDNAME=DISK,                                            X01120000
               EODAD=END,                                              X01130000
               SYNAD=ABTERM,                                           X01140000
               DSORG=PS,                                               X01150000
               MACRF=(RP,W)                                             01160000
*                                                                       01170000
*        END OF DCBS FOR I/O OPERATIONS                                 01180000
*                                                                       01190000
         REGEQU                                                         01200000
         END  BSAMIO                                                    01210000


 

The information on this site is the combined effort of a lot of people, please credit the authors if you use their information.
Please read the Disclaimer page for the restrictions, copyright, and other uses of the information contained on this site.
For problems or questions regarding this web contact Bob.
Last updated: April 28, 2004.