Browse Prior Art Database

Algorithm for Expanding a String of Bytes to Bits for Binary Printout

IP.com Disclosure Number: IPCOM000078551D
Original Publication Date: 1973-Jan-01
Included in the Prior Art Database: 2005-Feb-26
Document File: 1 page(s) / 12K

Publishing Venue

IBM

Related People

Page, DR: AUTHOR

Abstract

When it is desirable to display the individual bits of a string of bytes, each bit must be represented by a full byte in the external code, for example EBCDIC, for writing to an output device. This can be achieved efficiently with only two different instructions which are commonly available.

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

Page 1 of 1

Algorithm for Expanding a String of Bytes to Bits for Binary Printout

When it is desirable to display the individual bits of a string of bytes, each bit must be represented by a full byte in the external code, for example EBCDIC, for writing to an output device. This can be achieved efficiently with only two different instructions which are commonly available.

It is assumed that a byte contains eight bits and that the required output is a byte containing hexadecimal F0 for each 0-bit, or hexadecimal F1 for each 1-bit. The two instructions used are an unpacking instruction, which is commonly used to convert a packed decimal representation into a zoned decimal representation with zones of hexadecimal F, and a translate instruction which uses each byte of its argument as an index to a byte table to find a byte to replace the argument byte.

The algorithm is:
(1) Use an unpack instruction to replace the original string, by a string of double its length containing all zones of hexadecimal F.
(2) Translate this double-length string using a table whose first 240 bytes are irrelevant and whose last 16 bytes are: 00 01 04 05 10 11 14 15 40 41 44 45 50 51 54 55 (3) Use another unpack instruction to replace this translated string by one four times as long as the original. This string will again have zones of hexadecimal F.
(4) Translate this string as in step (2) using the same translate table.
(5) Finally, unpack the string again to produce the required output string eight...