Sample INEXIT routine

The following sample message input exit program translates received data from 8-bit ASCII to EBCDIC.
         TITLE 'Sample INEXIT - Input Data Exit'
*---------------------------------------------------------------------*
* This routine is a sample input exit to translate received data      *
* from 8 bit ASCII to EBCDIC.  This exit performs this function       *
* for any SNA device.  It translates the RU portion of all received   *
* unformatted Function Management Data requests that have the         *
* alternate code bit set in the request/response header and it        *
* then resets that bit.  To locate the RU, it checks the TH FID       *
* type and increments past the TH and RH.                             *
*                                                                     *
* Use of this exit would be indicated by coding the INEXIT operand    *
* on the NTWRK statement (INEXIT=ASCIIIN).                            *
*---------------------------------------------------------------------*
ASCIIIN  CSECT
         STM   14,12,12(13)         Save caller's registers
         LR    12,15                Establish base register
         USING ASCIIIN,12
*
         LR    3,1                  Parameter list address
         L     4,8(3)               Get DEV address
         USING DEV,4                Use DEV DSECT
         TM    DEVTYPE,DEVSNA       Test for SNA device type
         BNO   RETURN               Skip translation if not SNA
         L     5,0(3)               Get address of data
         L     6,16(3)              Get length
         LH    6,0(6)                   of data
         LA    8,2                  Length of FID3 TH
         MVC   FIDTYPE,0(5)         Get byte containing FID type
         NI    FIDTYPE,X'F0'        Isolate FID type
         CLI   FIDTYPE,X'20'        Test for FID2
         BE    FID2                 Branch if found
         CLI   FIDTYPE,X'30'        Test for FID3
         BE    FIDFOUND             Branch if found
         CLI   FIDTYPE,X'40'        Test for FID4
         BNE   RETURN               Return if not FID4
         LA    8,20(8)              Add FID4/FID2 length difference
FID2     LA    8,4(8)               Add FID2/FID3 length difference
FIDFOUND LA    7,0(8,5)             Point to RH
         LA    8,3(,8)              Add length of RH
         LA    9,0(8,5)             Point to RU
         SLR   6,8                  Get length of RU
         BNO   RETURN               Branch if nothing to translate
         TM    0(7),X'E8'           Test for unformatted FM Data
         BNZ   RETURN                   request
         TM    2(7),X'08'           Test for alternate code
         BZ    RETURN               Not in alternate code
         NI    2(7),X'F7'           Reset alternate code
*
*  Translate the data from ASCII to EBCDIC
*
         LA    8,256                Translate 256 at a time
TRLOOP   CLR   6,8                  256 or less left
         BNH   TRREST               Go translate last if so
         TR    0(256,9),ASC2EBC     Translate 256 bytes
         SLR   6,8                  Decrement count
         ALR   9,8                  Increment data pointer
         B     TRLOOP
TRREST   BCTR  6,0                  Decrement for translate
         EX    6,TRRMDR             Translate remainder of data
*
RETURN   LM    14,12,12(13)         Restore registers
         BR    14                   Return to caller
*
TRRMDR   TR    0(0,9),ASC2EBC       Translate remainder of data
*
FIDTYPE  DS    C                    Workarea for determining FID type
*
ASC2EBC  DS    0CL256       An 8 bit ASCII to EBCDIC Translate Table
         DC    XL16'00010203372D2E2F1605250B0C0D0E0F'       0
         DC    XL16'101112133C3D322618193F27221D351F'       1
         DC    XL16'405A7F7B5B6C507D4D5D5C4E6B604B61'       2
         DC    XL16'F0F1F2F3F4F5F6F7F8F97A5E4C7E6E6F'       3
         DC    XL16'7CC1C2C3C4C5C6C7C8C9D1D2D3D4D5D6'       4
         DC    XL16'D7D8D9E2E3E4E5E6E7E8E9ADE0BD5F6D'       5
         DC    XL16'79818283848586878889919293949596'       6
         DC    XL16'979899A2A3A4A5A6A7A8A9C04FD0A107'       7
         DC    XL16'4320211C23EB249B7128384990BAECDF'       8
         DC    XL16'45292A9D722B8A9A6756644A53685946'       9
         DC    XL16'EADA2CDE8B5541FE5851524869DB8E8D'       A
         DC    XL16'737475FA15B0B1B3B4B56AB7B8B9CCBC'       B
         DC    XL16'AB3E3B0ABF8F3A14A017CBCA1A1B9C04'       C
         DC    XL16'34EF1E0608097770BEBBAC5463656662'       D
         DC    XL16'30424757EE33B6E1CDED3644CECF31AA'       E
         DC    XL16'FC9EAE8CDDDC39FB80AFFD7876B29FFF'       F
*
*        Copy DSECTS from WSim User Exit Interface Library
*
         COPY  DEV
         END