× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi,

I am trying to convert a statement that turns off the first four bits in a
single byte field to free-form and am unsure of the best way to do that.

Original statement:
C                   BITOFF    '0123'        BYTE

Create a hex field containing the bits that you want to keep on. The %bitand() BIF will return a new byte where only those bits are copied from the original.


The old opcodes (like your example above) confuse me, so I hope I'm right, but this is what I suggest:

   byte = %bitand(x'0F': BYTE);

How this works is based on copying the bits that are on in BOTH bytes to the result. For the sake of example, let's say that BYTE contains the letter R, which is x'D9' in EBCDIC (I just picked this as a random value)
You'll have the following in binary:


   x'0F' = 00001111
   x'D9' = 11011001

So, it copies the bits that are in on BOTH fields, yielding:
           00001001

In other words, since I used x'0F' (which has the first 4 bits off, and the last 4 bits on) it copies just the last 4 bits of the field, and sets the rest of them off.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.