From: Tony Thigpen
Sent: Tuesday, 29 May 2012 12:51 PM

I am working with some IPv6 addresses that are 128 bits long. The input
to the program is an ip name or address and the number of high bits that
I need to use for a compare against another ip address.

So, I want to create run time routine to build the a 16 byte 'and' bit
field based on the input number of bits. (I will then 'and' both
addresses and then use a simple CLC.)

A good way is to determine the bit start position.
Put 8 bits in a GPR.  If shift is 1 thru 7, shift right the required no. of 
bits.
Then store that.
For the end byte, do the same, only shift left.
For the bytes between the initial byte and end byte,
store zero or more characters (each of 8 one-bits).

Although a table built at compile time might be a reasonable solution,

How so?  You say that the number of bits is input -- i.e. not a compile-time 
value.

I thought this would be a good time to learn a new trick if someone has
one they can share.

Reply via email to