Re: Precedence testing
- Posted by Spock Oct 22, 2020
- 1232 views
petelomax said...
I've added six new operators to phix:
&& - bitwise and, same as and_bits(lhs,rhs) || - bitwise or, same as or_bits(lhs,rhs) >> - shift right, same as floor(lhs/power(2,rhs)) << - shift left, same as lhs*power(2,rhs) ~ - same as length(rhs) [unary] . - subscripts and/or struct/class members
...
This might tempt me to drop Eu 2010 in favour of Phix 2020. What about about !! and ^^ for not_bits() & xor_bits() ? Presumably the equivalent assignment operators will be there as well. For c2ypt0 apps perhaps >>> and <<<? Mind you, a decent integrated assembler would make such bit-twiddling tricks redundant. I have about 90 ASM fragments in my base library to speed up various graphics functions. I use fasm4e but the calling overhead dominates for small functions. Eg, the following ASM code is only about 30% faster than Eu.
"mov eax, rgb", "bswap eax", "shr eax, 8", "ret eax"
[Orac code follows] -- Use for when a colour value is BGR but you need to convert it to RGB (or vice versa) int b = (rgb && #FF) * 65536 int g = rgb && #FF00 int r = floor((rgb && #FF0000)/65536) return b || g || r
How does Phix compare for context switching?
Spock