Twiddle binary bit in Cobol? 
Author Message
 Twiddle binary bit in Cobol?

I work at Caterpillar and we are trying to pack data in a hex comp-3
field.  Is there a way to set individual bits in a hex field?  In C you
can use the << operator to look and set them, however, I don't know
about COBOL?  I am using IBM mainframe cobol.

What we have is a string of On-Offs that need to be stored very
effeicently.



Sat, 11 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?
Mark, It can't be done without an Assembler* subroutine, e.g. to set /
unset / test bit "n" or to pack / unpack bits to / from an 8-byte array.
(* It CAN be written in COBOL but it's really messy.)
Quote:

> I work at Caterpillar and we are trying to pack data in a hex comp-3
> field.  Is there a way to set individual bits in a hex field?  In C you
> can use the << operator to look and set them, however, I don't know
> about COBOL?  I am using IBM mainframe cobol.

> What we have is a string of On-Offs that need to be stored very
> effeicently.



Sat, 11 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?
On Tue, 23 Feb 1999 08:10:18 -0600, Mark Juchems

Quote:
>I work at Caterpillar and we are trying to pack data in a hex comp-3
>field.  Is there a way to set individual bits in a hex field?  In C you
>can use the << operator to look and set them, however, I don't know
>about COBOL?  I am using IBM mainframe cobol.

>What we have is a string of On-Offs that need to be stored very
>effeicently.

On an IBM mainframe running MVS or VSE, comp-3 is not binary data, but
packed data.  Example, if you have a field defined as PIC S999 COMP-3
and it had a value of +465, it would appear in storage as  00465C.
What you need are fields defines as COMP or USAGE IS BINARY.

HTH

Regards,

          ////
         (o o)
-oOO--(_)--OOo-

In prison there are wardens who are often {*filter*}ic and psychotic.
At work we call them managers.

 Steve



Sat, 11 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?

Quote:

>I work at Caterpillar and we are trying to pack data in a hex comp-3
>field.  Is there a way to set individual bits in a hex field?  In C you
>can use the << operator to look and set them, however, I don't know
>about COBOL?  I am using IBM mainframe cobol.

>What we have is a string of On-Offs that need to be stored very
>effeicently.

Assuming your machine's COMP-3 is BCD (one decimal digit per nibble), if
what you want to do is store a series of boolean values (true/false,
on/off), COMP (binary) might be more efficient.

Using binary storage, you could then set/unset/interrogate bits using basic
multiply-or-divide-by-two and check-the-remainder arithmetic.

I have a text and graphics tutorial I wrote on the various COBOL data types;
it describes bit patterns and allows you to display the numeric value plus
hex and binary images of selected data values in various PICTURE formats on
the screen. (MS-DOS program).

If you are interested in this tutorial, drop me a note and I'll send you a
copy. (Freeware). Or better still, maybe someone can suggest a suitable Web
site and I'll post the file for anyone else who who like to use it.

MCM
Racine WI



Sat, 11 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?
I don't mean to argue (too much) with John, but if you are running under LE,
there are specific "bit-twiddling" callable services that you can use to
test or set bits.  If you are under LE, they are documented in the
Programmers Guide under "Bit Manipulation".  If you have trouble finding
them, let me know.  (These are not available to COBOL applications that are
pre-LE, so then you would probably want to call Assembler, PL/I, or
something else to do it for you)

--
Bill Klein (wmklein at ix dot netcom dot com)

Quote:

>Mark, It can't be done without an Assembler* subroutine, e.g. to set /
>unset / test bit "n" or to pack / unpack bits to / from an 8-byte array.
>(* It CAN be written in COBOL but it's really messy.)


>> I work at Caterpillar and we are trying to pack data in a hex comp-3
>> field.  Is there a way to set individual bits in a hex field?  In C you
>> can use the << operator to look and set them, however, I don't know
>> about COBOL?  I am using IBM mainframe cobol.

>> What we have is a string of On-Offs that need to be stored very
>> effeicently.



Sat, 11 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?

Quote:

> I work at Caterpillar and we are trying to pack data in a hex comp-3
> field.  Is there a way to set individual bits in a hex field?  In C you
> can use the << operator to look and set them, however, I don't know
> about COBOL?  I am using IBM mainframe cobol.

You can use Language Environment (LE/370, LE/MVS, etc) routines to
manipulate bits on the mainframe .

+--------------+------------------------------------+

|              | http://www_dot_cix.co.uk/~watkins/ |
+--------------+------------------------------------+



Sat, 11 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?
The BITPK routine from ETK can manipulate bits.
Go to http://www.etk.com then downloads, then ETKPAK. Read the
documentation for ETKPAK.
Quote:

>Mark, It can't be done without an Assembler* subroutine, e.g. to set /
>unset / test bit "n" or to pack / unpack bits to / from an 8-byte array.
>(* It CAN be written in COBOL but it's really messy.)


>> I work at Caterpillar and we are trying to pack data in a hex comp-3
>> field.  Is there a way to set individual bits in a hex field?  In C you
>> can use the << operator to look and set them, however, I don't know
>> about COBOL?  I am using IBM mainframe cobol.

>> What we have is a string of On-Offs that need to be stored very
>> effeicently.



Sat, 11 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?
No, this there is nothing like that (yet) on IBM S/390 mainframes.  The next
Standard will support such constructs and (finally) IBM mainframe COBOL
programmers won't have to convert to hex and play with items that way - or
even use LE callable services.

--
Bill Klein (wmklein at ix dot netcom dot com)

Quote:

>On Unisys 2200s, the COBOL compiler allows PIC 1 to define a single bit eg:

>01  SOME_DATA.
>        03 FIRST_BIT   PIC 1 VALUE 0.
>        03 SECOND_BIT PIC 1 VALUE 1.
>        03 FILLER PIC 1(4).

>etc...
>Isn't there something like that on IBM?



Sat, 11 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?
On Unisys 2200s, the COBOL compiler allows PIC 1 to define a single bit eg:

01  SOME_DATA.
        03 FIRST_BIT   PIC 1 VALUE 0.
        03 SECOND_BIT PIC 1 VALUE 1.
        03 FILLER PIC 1(4).

etc...
Isn't there something like that on IBM?



Sun, 12 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?
Thanks for all of the help.   I found out we have an inhouse routine -
CTBYTBIT and CTBITBYT that can do what I need.  I asked a few gurus around
here and they had no idea how to do it without the subroutine....
Quote:

> I work at Caterpillar and we are trying to pack data in a hex comp-3
> field.  Is there a way to set individual bits in a hex field?  In C you
> can use the << operator to look and set them, however, I don't know
> about COBOL?  I am using IBM mainframe cobol.

> What we have is a string of On-Offs that need to be stored very
> effeicently.



Sun, 12 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?


Quote:

>Subject: Re: Twiddle binary bit in Cobol?
>Organization: StarZIP Pty Ltd

>On Unisys 2200s, the COBOL compiler allows PIC 1 to define a single bit eg:

>01  SOME_DATA.
>        03 FIRST_BIT   PIC 1 VALUE 0.
>        03 SECOND_BIT PIC 1 VALUE 1.
>        03 FILLER PIC 1(4).

>etc...
>Isn't there something like that on IBM?

At list in AS/400 COBOL there is. Dont know about the mainframe ones
though.

Frederico Fonseca



Sun, 12 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?
Does the PIC 1 on COBOL/400 actually give you bit-level access?  I thought
it was just a Boolean data-type - that still took a byte.  (However, I
easily could be wrong about this.)

--
Bill Klein (wmklein at ix dot netcom dot com)

Quote:




>>Subject: Re: Twiddle binary bit in Cobol?
>>Organization: StarZIP Pty Ltd

>>On Unisys 2200s, the COBOL compiler allows PIC 1 to define a single bit
eg:

>>01  SOME_DATA.
>>        03 FIRST_BIT   PIC 1 VALUE 0.
>>        03 SECOND_BIT PIC 1 VALUE 1.
>>        03 FILLER PIC 1(4).

>>etc...
>>Isn't there something like that on IBM?
>At list in AS/400 COBOL there is. Dont know about the mainframe ones
>though.

>Frederico Fonseca



Sun, 12 Aug 2001 03:00:00 GMT  
 Twiddle binary bit in Cobol?
Fujitsu allows a pic 1 also, but it's not explained very well.

The Unisys 1100/2200 pic 1 is just that, bit fields.
It's not standard, but it lets me write some things in COBOL and
skip ASM/MASM for some of my utilities. (i.e. Hard code screen formats
and send anything to a terminal/periperal device.)
....
04  a-9bit-byte.
    06 filler pic 1.
    06 upper-nibble pic 1(4).
    06 upper-two    pic 1(2).
    06 lower-two    pic 1(2).
....
36 bit word, 4 x 9-bit bytes internal, 8 or 9 bit bytes can be used
during I/O if desired, and medium supports it.

Gary

Quote:

> Does the PIC 1 on COBOL/400 actually give you bit-level access?  I thought
> it was just a Boolean data-type - that still took a byte.  (However, I
> easily could be wrong about this.)

> --
> Bill Klein (wmklein at ix dot netcom dot com)





> >>Subject: Re: Twiddle binary bit in Cobol?
> >>Organization: StarZIP Pty Ltd

> >>On Unisys 2200s, the COBOL compiler allows PIC 1 to define a single bit
> eg:

> >>01  SOME_DATA.
> >>        03 FIRST_BIT   PIC 1 VALUE 0.
> >>        03 SECOND_BIT PIC 1 VALUE 1.
> >>        03 FILLER PIC 1(4).

> >>etc...
> >>Isn't there something like that on IBM?
> >At list in AS/400 COBOL there is. Dont know about the mainframe ones
> >though.

> >Frederico Fonseca



Sun, 12 Aug 2001 03:00:00 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Bit Twiddling in IBM (LE) COBOL

2. Bit Twiddling??

3. Bit twiddling on Parallel port

4. UUDECODE - Bit-twiddling in Arexx

5. SIMD-like bit-twiddling on odd-sized quantities

6. New Mathematical bit-twiddle - stage on of a isPerfectSquare()

7. Crazy bit-twiddle algorithms needed!

8. Bit twiddling functions

9. Bit twiddling functions

10. Byte/Bit Twiddling in Ada

11. help - bit twiddling anomoly

12. Bit Twiddling

 

 
Powered by phpBB® Forum Software