*M*      FBCD     BCD/EBCDIC & EBCDIC/BCD CONVERSION
********************************************************
*P*
*P*      NAME:    FBCD
*P*
*P*      PURPOSE: TO CONVERT 8 BIT BYTES GENERATED AS A
*P*               RESULT OF READING CARDS PUNCHED IN THE
*P*               BCD FORMAT INTO THE CORRECT EBCDIC
*P*               COUNTERPART, AND TO CONVERT EBCDIC INTO
*P*               THE CORRECT 8 BIT EQUIVALENT SO THAT BCD
*P*               FORM CAN BE PUNCHED ONTO CARDS.
*P*
*P*      METHOD:  BYTE BY BYTE SUBSTITUTION USING TABLE LOOKUP.
*P*
         SYSTEM   UTS
*****************************************************************
         DEF      FBCD:             PATCHING DEF
FBCD:    RES
         DEF      EBCTOBCD          EBCDIC/BCD CONVERSION ENTRY(IORT)
         DEF      BCDTOEBC          BCD/EBCDIC CONVERSION ENTRY(COOP)
         DEF      XEBCTB            BCD/EBCDIC CONVERSION TABLE(IORT)
         DEF      XBCDTB            EBCDIC/BCD CONVERSION TABLE(WRTD)
***************************************************************
         REF      TSTACK            TEMP STACK
************************************************************************
D3       EQU      14                                                    85200070
R1       EQU      1                                                     85200080
R2       EQU      2                                                     85200090
R3       EQU      3                                                     85200100
R4       EQU      4                                                     85200110
LIMITS    DATA     X'7E',X'4A'
BCDTB    DATA,1   X'48',X'49',X'4A',X'4B',X'4E',X'6C',X'50',X'4F'       85200150
         DATA,1   X'50',X'51',X'52',X'53',X'54',X'55',X'56',X'57'       85200160
         DATA,1   X'58',X'59',X'5A',X'5B',X'5C',X'4C',X'5E',X'5F'       85200170
         DATA,1   X'60',X'61',X'62',X'63',X'64',X'65',X'66',X'67'       85200180
         DATA,1   X'68',X'69',X'6A',X'6B',X'6C',X'6D',X'7E',X'4A'       85200190
         DATA,1   X'70',X'71',X'72',X'73',X'74',X'75',X'76',X'77'       85200200
         DATA,1   X'78',X'79',X'7D',X'7B',X'7C',X'7C',X'7B',X'7F'       85200210
EBCTB    DATA,1   X'48',X'49',X'6F',X'4B',X'5D',X'4D',X'4C',X'4F'       85200220
         DATA,1   X'4E',X'51',X'52',X'53',X'54',X'55',X'56',X'57'       85200230
         DATA,1   X'58',X'59',X'5A',X'5B',X'5C',X'5D',X'5E',X'5F'       85200240
         DATA,1   X'60',X'61',X'62',X'63',X'64',X'65',X'66',X'67'       85200250
         DATA,1   X'68',X'69',X'6A',X'6B',X'4D',X'6D',X'6E',X'6F'       85200260
         DATA,1   X'70',X'71',X'72',X'73',X'74',X'75',X'76',X'77'       85200270
         DATA,1   X'78',X'79',X'7A',X'7E',X'7D',X'7A',X'6E',X'7F'       85200280
XEBCTB   EQU      EBCTB-18
XBCDTB   EQU      BCDTB-18
**************************************************************
*D*      NAME:    BCDTOEBC
*D*      ENTRY:   EBCTOBCD
*D*
*D*      BCD/EBCDIC & EBCDIC/BCD CONVERSION ROUTINES.
*D*
*D*      PURPOSE: TO CONVERT 8 BIT BYTES GENERATED AS A
*D*               RESULT OF READING CARDS PUNCHED IN THE
*D*               BCD FORMAT INTO THE CORRECT EBCDIC
*D*               COUNTERPART, AND TO CONVERT EBCDIC INTO
*D*               THE CORRECT 8 BIT EQUIVALENT SO THAT BCD
*D*               FORM CAN BE PUNCHED ONTO CARDS.
*D*
*D*      METHOD:  BYTE BY BYTE SUBSTITUTION USING TABLE LOOKUP.
*D*
*D*      REGISTERS: R1 IS LINK, D3 IS TABLE POINTER, R2 IS
*D*                THE BUFFER POINTER, R3 HAS THE BYTE COUNT.
*D*                ALL OTHER REGISTERS ARE NOT VOLATILE.
*D*
**************************************************************
BCDTOEBC LI,D3    XEBCTB
*
EBCTOBCD LCI      3
         PSM,R2   TSTACK
CNVLOP   EQU      %                                                     85200370
         LB,R4    0,R2                                                  85200380
         CLM,R4   LIMITS
         BCS,6    NOCNV                                                 85200400
         LB,R4    *D3,R4
         STB,R4   0,R2                                                  85200420
NOCNV    AI,R2    1                                                     85200430
         BDR,R3   CNVLOP                                                85200440
         LCI      3
         PLM,R2   TSTACK
         B        0,R1
         END                                                            85200530

