Simple features that I've always missed from C...

Don nospam at nospam.com
Tue Oct 18 12:50:10 PDT 2011


On 18.10.2011 11:43, Manu wrote:
> On 18 October 2011 12:12, Don <nospam at nospam.com
> <mailto:nospam at nospam.com>> wrote:
>
>     You mean bsr and bsf.
>     Unfortunately, there are some big problems with them. What is bsr(0) ?
>
>
> True ;) .. but that's why the API needs to be defined and standardised.
> On PowerPC it returns 32 (or 64), and the x86 version returns 2 values,
> the position, and also a bool telling you if it was zero or not (useful
> for loop termination)

Even worse -- Intel says that the position value of bsr(0) is undefined. 
But AMD does define it, they say it's what was in the register before.


> I think all hardware that I've seen is easy to factor into the win32
> intrinsic api.

That would be nice. What do you think it should do for the zero case?
Note that on x86, one possibility is to do a bsr followed by a cmov, to 
get the PowerPC semantics.


More information about the Digitalmars-d mailing list