I've used rotate (ROTL and ROTR) before but can't remember ever needing to use all 32 bits before.
Well, today I've tried it and am getting completely screwy results!
Consider the following snippet.
START
set var1 2048
x:
delay 1000
rotr var1 1 var1
goto x
END
You'd expect it to count 2048, 1024, 512... which it does. But once it rotates the bit out 0 and into bit 31, it seems bit 31 remains ALWAYS set. After a further 31 rotates, we end up with -1 (and stay at -1 forever more)
Similarly, changing the rotr to rotl we would expect to see 2048, 4096, 8192, etc... which we do... until bit 31 gets set, then we get to -1 and again, stay there.
This isn't "rotate" as I know it - am I doing something wrong, or is this a bug in the code?
Well, today I've tried it and am getting completely screwy results!
Consider the following snippet.
START
set var1 2048
x:
delay 1000
rotr var1 1 var1
goto x
END
You'd expect it to count 2048, 1024, 512... which it does. But once it rotates the bit out 0 and into bit 31, it seems bit 31 remains ALWAYS set. After a further 31 rotates, we end up with -1 (and stay at -1 forever more)
Similarly, changing the rotr to rotl we would expect to see 2048, 4096, 8192, etc... which we do... until bit 31 gets set, then we get to -1 and again, stay there.
This isn't "rotate" as I know it - am I doing something wrong, or is this a bug in the code?