Decode value |< "value"
MAElektronik Posts: 82
in Propeller 1
A simple question using bitwise decode operator.
If |<value & % 0000_0001
"Do something else"
What happens if value is outside 0 to 31 ?
What if value == TRUE (-1 decimal) ?
I'm decently sure it just wraps around. I.e.
|<x == |<(x&31). So
|<(-1) == |<31 == $8000_0000.
If |<value & %0000_0001could just be written as
ifnot value&31, but I guess that's just your example nonsense.
Ada is correct. Think of the
1 << (x & $1F)A bit of test code proves that.
Well, really just
1 << x, since the shift operators have the same wraparound behaviour
I just noticed that, which was was a surprise. I had always that believed that shifting with a value > 31 resulted in 0.
As I understand it, the Propeller uses a "barrel shifter", so nothing really get "shifted." It's just a fancy set of multiplexers that take part of the input and gate it somewhere else into the result. The multiplexers themselves are gated by a decoder, whose inputs are the lower five bits of the shift amount.
Thanks everybody 😊
Perhaps the manual should have added this information?