I am pretty shure, that your last example will result in something like:
mov reg, val
cmp reg, 1
je @addr1
portx 1
ret
@addr1:
portx 0
ret
Whereas a exclusive or will produce something like:
mov reg, val
xor reg, 1
portx reg
ret
So, that why the xor is not just lazy trickery ![]()
Port manipulation would of course be even faster. But I will not recommend this unless the code is targeted at one, specific chip ![]()
EDIT: Pseudo-assembly alert! Added "ret" for completion ![]()