Gil, The maximum negative value must also be treated as a special case.
John P. Baker -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Paul Gilmartin Sent: Tuesday, July 23, 2013 7:13 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Is there a "reverse bits" hardware instruction? On Tue, 23 Jul 2013 17:49:00 -0400, Charles Mills wrote: > >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. > Subtract 1. XOR with the original value. The leftmost 1 bit of the result now occupies the position of the rightmost 1 bit of the original value AND with the original value yields the mask to reset that bit. Zero must be treated as a special case. --gil ---------------------------------------------------------------------- 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