Re:A semantic model for a substantial fragment of C
by wott on Saturday April 01, 2017 @11:56AM
(#14012701)
> - on ARM, the "y" operand is evaluated mod 32
> - on x86, if y is greater than 31, the result is 0
You mixed them up, didn't you ?
AFAIK, ARM does set all bits to 0 if the shift if greater than 31, but it only uses the lowest byte of the shift amount register, so it feels like a mod 256.
x86[^1] does mask the lower 5 bits of the shift amount, so it feels like a mod 32. And the amount can only be 8 bits, so a 32-bit C variable must be truncated somehow.
[1] except on 8086, there is no mask there, so no modulo.
> - on x86, if y is greater than 31, the result is 0
You mixed them up, didn't you ?
AFAIK, ARM does set all bits to 0 if the shift if greater than 31, but it only uses the lowest byte of the shift amount register, so it feels like a mod 256.
x86[^1] does mask the lower 5 bits of the shift amount, so it feels like a mod 32. And the amount can only be 8 bits, so a 32-bit C variable must be truncated somehow.
[1] except on 8086, there is no mask there, so no modulo.