Using MicroBlaze MCS in ISE 14.5 there could be incorrect behavior when the compiler optimization is set to Os.
When set to -O0 or -O2 the code seems to work correctly.
The 14.5 compiler emits incorrect code for shift right with -Os:
The first srl is correct, and is presumably used to handle signed/unsigned shift, but the addk is wrong.
does a left-shift instead of a right-shift.
The correct code would have been srl r4, r4
The same program emits correct code with the 14.6 compiler, but it is not size-optimized.
(Note that the first addk is meaningless here, and should not have been emitted at all):
This issue has been fixed in EDK 14.7 and Vivado 2013.4.