There's a RLLG instruction to rotate the bits in a 64-bit integer. I know that you want to call such a routine from C/C++. If you need to write ffs64() in assembler you may find the linkage overhead of calling the routine is far greater than a slower implementation that has been inlined. It's about time IBM enhanced C/C++
to support __asm for non-Metal/C compiles.

On 24/07/2013 5:49 AM, Charles Mills wrote:
Is there a quick way to reverse MSB to LSB the bits of a 64-bit register? If
I have a register that contains 01234567_89ABCDEF to convert it to
F7B3D591_E6A2C480? (I think I got that at least mostly right.) A bit-wise
Load Reversed?

Yes, I am familiar with the Pops. Hard to find an instruction when you don't
know its name or even if it actually exists.

Why? Those of you following another thread I started know I am looking to
implement a 64-bit version of the UNIX library function ffs(), which returns
the bit number of the least significant one bit of a word. z architecture
provides the FLOGR instruction but it works MSB to LSB. I could potentially
live with that but it would introduce some new complications, one of them
being that counting from the LSB is much more compatible with how C promotes
integer types. If I could flip the bits of a word in one or two hardware
instructions I would have a solution. FLOGR provides an additional benefit
for me because I ultimately want to do the other chore that FLOGR does,
resetting the found bit.

I guess you could do it with TR (to reverse the bits) and then LRVG (to
reverse the bytes) but that is overly complex and probably slow (IMHO).

Thanks in advance,
Charles

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to