redhotsonic, on 28 March 2012 - 10:18 AM, said:
flamewing, on 27 March 2012 - 05:46 PM, said:
Now that I looked more closely at the code, I think it should also be asr instead or lsr
I'm not at home at the moment so I can't test it out, but what will be the difference? To me, once all bits have shifted to the right, the new bit introduced may be a 1 instead of a 0 (depends if it's a negative value).
ASR shifts arithmetically, which means -4 will become -2 after shifting.
%1111111111111100 -> %1111111111111110
LSR shifts logically ignoring source data's sign, so -4 will eventually become 32766!
%1111111111111100 -> %0111111111111110
If you're calculating signed numbers, there will be a huge bug with it.
However, if you were dealing with shifting left (in case you wanted to multiply something by power of 2), there would be no difference between ASL and LSL, expect for ASL would set Overflow bit if sign bit was changed after operation.
This post has been edited by vladikcomper: 28 March 2012 - 01:22 PM