Tony,
Try this --
LH R2,........ Get the number of bits to be
retained
LGHI R4,-1 Populate the high-order portion of
the mask
CHI R2,64 Are more than 64 bits required ?
JH L05 Yes..
LHI R3,64 Get the size of a register
SR R3,R2 Calculate the number of bits to be
discarded
LGHI R5,0 Populate the low-order portion of
the mask
SLLG R4,0(R3) Discard the unneeded portion of the
mask
J L10 Go save the mask
L05 DC 0H'0'
LHI R3,128 Get the size of two (2) registers
SR R3,R2 Calculate the number of bits to be
discarded
LGR R5,R4 Populate the low-order portion of
the mask
SLLG R5,0(R3) Discard the unneeded portion of the
mask
L10 DC 0H'0'
STMG R4,R5,........ Save the mask
John P. Baker
-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]]
On Behalf Of Tony Thigpen
Sent: Monday, May 28, 2012 10:51 PM
To: [email protected]
Subject: Generating a bit mask
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.)
Although a table built at compile time might be a reasonable solution, I
thought this would be a good time to learn a new trick if someone has one
they can share.
--
Tony Thigpen