SUBROUTINE ASC4R(INBYTE,OUTBYTE) C C This subroutine is the inverse of ASC4. It takes an array of 4 C bytes, each of which must represent an ASCII character in the range C 040(8) to 137(8), subtracts 40(8) from each byte and extracts C the least significant 6 bits from each byte. The four 6-bit C bit strings are packed into the 24 bits that make up the output C byte array. C C Input data Output data C C 00aaaaaa + 00100000 byte 1 bbaaaaaa byte 1 C 00bbbbbb + 00100000 byte 2 ccccbbbb byte 2 C 00cccccc + 00100000 byte 3 ddddddcc byte 3 C 00dddddd + 00100000 byte 4 C BYTE INBYTE(4) !Input byte array. BYTE OUTBYTE(3) !Output byte array. INTEGER TEMP1,TEMP2 !Work space for bit manipulations. DATA MASK2,MASK4,MASK6,MASK8 !MASKn is an AND mask used to eliminate 1/"3,"17,"77,"377/ !all but the lowest n bits of a word. C C Compute first output byte. C TEMP1=INBYTE(1) !Get byte with 1st bit string. TEMP1=TEMP1-"040 !Remove bias that made it printable. TEMP1=TEMP1.AND.MASK6 !Erase all but 1st string. TEMP2=INBYTE(2) !Get byte with 2nd bit string. TEMP2=TEMP2-"040 !Remove bias. TEMP2=TEMP2 .AND. MASK2 !Keep only last 2 bits of 2nd string. TEMP2=ISHFT(TEMP2,6) !Shift them to top of byte. TEMP1=TEMP1 .OR. TEMP2 !Merge the two pieces. OUTBYTE(1)=TEMP1 !Copy to 1st output byte. C C Compute second output byte. C TEMP1=INBYTE(2) !Get byte with 2nd bit string. TEMP1=TEMP1-"040 !Subtract bias. TEMP1=TEMP1 .AND. MASK6 !Keep only lowest 6 bits. TEMP1=ISHFT(TEMP1,-2) !Already have bottom 2 bits. TEMP2=INBYTE(3) !Get byte with 3rd bit string. TEMP2=TEMP2-"040 !Subtract bias. TEMP2=TEMP2 .AND. MASK4 !Keep only lowest 4 bits. TEMP2=ISHFT(TEMP2,4) !Shift to top of byte. TEMP1=TEMP1 .OR. TEMP2 !Merge the two pieces. OUTBYTE(2)=TEMP1 !Copy to 2nd output byte. C C Compute 3rd output byte. C TEMP1=INBYTE(3) !Get byte with 3rd bit string. TEMP1=TEMP1-"040 !Subtract bias. TEMP1=TEMP1 .AND. MASK6 !Keep last 6 bits. TEMP1=ISHFT(TEMP1,-4) !Already have bottom 4 bits. TEMP2=INBYTE(4) !Get byte with 4th bit string. TEMP2=TEMP2-"040 !Subtract bias. TEMP2=TEMP2 .AND. MASK6 !Keep last 6 bits. TEMP2=ISHFT(TEMP2,2) !Shift to top of byte. TEMP1=TEMP1 .OR. TEMP2 !Merge the two pieces. OUTBYTE(3)=TEMP1 !Copy to 3rd output byte. C RETURN END