× 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.




Thanks to all who replied to my original question.  I am at V5R2 so I just
broke the bit map into 8 fields and used the biton/bitoff opcode.

Consider using %bitand and %bitor to retrieve and set (respectively) the bits. It'll be faster and require less code.

Also, consider coding a constant that corresponds to each bit to make it clear what the bit is for. That'll make your code easier to read.


I have a somewhat related question.  Some of the fields in the message
need to be coded as Binary Coded Decimal (BCD).  From what I understand
this is a unsigned packed numeric.  Odd length fields are padded with a
leading zero.  So 99,999 would be represented in packed as:   99 99 9F and
in BCD:  09 99 99.

Assuming the BCD field is big-endian:

Create a data structure that overlays a packed field with an unsigned integer field. (make the packed field 15P 0 and the unsigned field 20U 0). Maybe overlay it with an 8A character field as well (depending on what you're doing.)

To convert from BCD to packed, use the char field to store the BCD field into the data structure. Then multiply the unsigned field by 16 and then use %bitor (or BITON if like, or even MLLZO) to set the last nibble to x'0f'.Read the result from the packed field.

To convert from packed to BCD, store the data by setting the packed field, then divide the unsigned field by 16, and retrieve the results from the char field.

If it's little-endian, you'd need to convert it to bigendian when assigning the BCD to the data structure, and convert it back to little endian when extracting the BCD field from the DS.

Make sense?

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.