Re: [Jprogramming] A bit-twisting puzzle

2019-07-28 Thread Aai
I think of a nand-function. On 29-07-19 02:51, Henry Rich wrote: Many of the members of this Forum will remember the days of assembler language   ...and who could less than merry be   when writing out BXLE? AND, OR, XOR were our meat.  Those days are returning. You have two integer variables

Re: [Jprogramming] A bit-twisting puzzle

2019-07-28 Thread Louis de Forcrand
I am missing something: a == 0 iff popcnt(a) == 0, so indeed a == 0 || b == 0 is equivalent to popcnt(a) == 0 || popcnt(b) == 0 which can be written as !(popcnt(a) && popcnt(b)), but if this is translated into a single-branch sequence of machine instructions, then wouldn’t !(a && b) be as well? T

Re: [Jprogramming] A bit-twisting puzzle

2019-07-28 Thread Roger Hui
If you have thought about this for a year then the following can't be the answer, but here it is: There is either a popcnt instruction, or you can implement it with straight-line code without branching. Whence: if !(popcnt(a)&&popcnt(b)) stmt; On Sun, Jul 28, 2019 at 5:51 PM Henry Rich wrote:

Re: [Jprogramming] A bit-twisting puzzle

2019-07-28 Thread Gilles Kirouac
How about multiply a and b, followed by a branch on zero? ~ Gilles Le 2019-07-28 à 20:51, Henry Rich a écrit : > Many of the members of this Forum will remember the days of assembler > language > >   ...and who could less than merry be >   when writing out BXLE? > > AND, OR, XOR were our meat.  T

Re: [Jprogramming] A bit-twisting puzzle

2019-07-28 Thread Louis de Forcrand
Do we have access to an instruction which counts leading zero bits? Interesting problem, Louis > On 28 Jul 2019, at 19:51, Henry Rich wrote: > > Many of the members of this Forum will remember the days of assembler language > > ...and who could less than merry be > when writing out BXLE? >

[Jprogramming] A bit-twisting puzzle

2019-07-28 Thread Henry Rich
Many of the members of this Forum will remember the days of assembler language   ...and who could less than merry be   when writing out BXLE? AND, OR, XOR were our meat.  Those days are returning. You have two integer variables a and b and you want to do something if one or both of them are 0