photomankc
04-03-2012, 08:37 PM
So is it widely known that using <- and -> on values that are less than 32bits will rotate in the 0's from the upper, unused bits? If I define a word variable and give it the value of say:
10010110_11110000
Then if I rotate it right 8 bits I get:
00000000_10010110
So the zeros come marching in from memory that was not part of my variable. However if I define a long variable and use it then it works just as expected. I suppose this probably has to do with the hardware but I didn't see it mentioned in the manual beyond the fact that all the examples are 32bit. Spent a couple nights tearing my hair out before I finally honed on where things were going off the rails. Might be helpful if the manual mentioned that operator always assumes a 32bit value regardless of the size of the declared variable.
I know spin is not typed but the shift operators work exactly as I would expect for any given variable size. Wasn't expecting the rotate to be different.
10010110_11110000
Then if I rotate it right 8 bits I get:
00000000_10010110
So the zeros come marching in from memory that was not part of my variable. However if I define a long variable and use it then it works just as expected. I suppose this probably has to do with the hardware but I didn't see it mentioned in the manual beyond the fact that all the examples are 32bit. Spent a couple nights tearing my hair out before I finally honed on where things were going off the rails. Might be helpful if the manual mentioned that operator always assumes a 32bit value regardless of the size of the declared variable.
I know spin is not typed but the shift operators work exactly as I would expect for any given variable size. Wasn't expecting the rotate to be different.