#include #include #include /* libOCbits -- A library of C functions that allow Cobol to process data at the bit level. /* chk_bit32: chk/get a single bit in the unsigned 32 bit int passed into 'b', by reference. Pass a bit number (0-31), by value, to specify which bit is to be returned. ----------------------------------------------------------*/ int chk_bit32(unsigned int *b, int bit) { unsigned int x; x = *b; if (x & (1<= 0; i--) { if (instr[i-1]=='1') dectotal = (dectotal + (1<<(bit))); else instr[i-1]='0'; bit++; } *b=dectotal; } /* itobs32: Converts a 32-bit Integer to a 32 byte binary string. Each byte of the binary string will contain a '1' or '0', representing the bit values in the integer. -----------------------------------------------------------*/ void itobs32(unsigned int *b, char outstr[32] ) { // outstr is the binary string that will contain the 1's and 0's unsigned int saveb = *b; int i; for (i = 31; i >= 0; i--) { outstr[i] = (*b & (1<<0)) ? '1' : '0'; *b = *b >> 1; } *b=saveb; } /* on_bit32: Turn on a single bit in the unsigned int passed into 'b', by reference. Pass a bit number (0-31), by value, to specify which bit is to be turned on. ----------------------------------------------------------*/ int on_bit32(unsigned int *b, int bit) { unsigned int x; x = *b; if (x & (1<