Dismiss
Surety is performing system maintenance this weekend. Electronic date stamps on new Prior Art Database disclosures may be delayed.
Browse Prior Art Database

# Conversion of Character String Data to Bit String Data

IP.com Disclosure Number: IPCOM000084537D
Original Publication Date: 1975-Nov-01
Included in the Prior Art Database: 2005-Mar-02
Document File: 2 page(s) / 14K

IBM

## Related People

Wheatcroft, A: AUTHOR

## Abstract

In any programming language which supports both BIT class data and CHARACTER class data, it is often desirable to convert character string data to bit string data. Described is an algorithm for performing this conversion.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 52% of the total text.

Page 1 of 2

Conversion of Character String Data to Bit String Data

In any programming language which supports both BIT class data and CHARACTER class data, it is often desirable to convert character string data to bit string data. Described is an algorithm for performing this conversion.

In the algorithm it is assumed that each byte contains 8 bits and a character string contains Hex 'F1' for character 1, HEX 'F0' for character 0 and the source character string is 8-bytes long.

For the conversion, only two types of instruction are used: OR CHARACTERS (OC) The contents of the first operand and the second operand are OR'ed together and the result is placed in the first operand location. TRANSLATE (TR) Each byte of the first operand is used as an index down the table specified by the second operand, and the corresponding byte replaces the byte in the first operand location. The algorithm is: 1. Use an OC instruction with the source character string as the first operand and the following eight-byte character string as the second operand: F0 F2 F4 F6 F8 FA FC FE 2. Use a TR instruction with the character string resulting from (1) as the first operand and a table as the second operand, whose first 240 bytes are irrelevant and whose last sixteen bytes are: 00 80 00 40 00 20 00 10 00 08 00 04 00 02 00 01 3. Use an OC instruction to propagate the string resulting from (2) with itself: e.g., OC STRING + 1 (7), STRING The final byte will thus contain the required bit pattern. Hence to implement the PL/I instruction: B = C; with B as BIT (8) ALIGNED and C as CHAR (8) ALIGNED

Two MOVE CHARACTERS (MVC) instructions are required around the algorithm to give: MVC TEMP (8),C /* MOVE SOURCE INTO WORKSPACE */ OC TEMP (8),SS1 /* OR WITH STATIC STRING No. 1 */ TR TEMP (8), TT /* TRANSLATE STRING WITH TABLE */ OC TEMP+1 (7) TEMP/* PROPAGATE STRING WITH ITSELF*/ MVC B(1), TEMP +7 /* MOVE RESULT INTO TARGET */ It should be noted: A. Static string (SS1) used in the first OC instruction need only be: 00 02 04 06 08 0A 0C 0E if the original string contains correct data. However, using the string: F0 F2 F4 F6 F8 FA FC FE ensures execution, even if the original data string does not consist entirely of HEX 'F0' / 'F1' This is particularly important since the actual physical length...