0
\$\begingroup\$

In ARM,

Data-processing instructions have an unusual immediate representation involving an 8-bit unsigned immediate, imm8, and a 4-bit rotation, rot. imm8 is rotated right by 2 × rot to create a 32-bit constant.

enter image description here

Here is an example. I just can't figure out how it is that... enter image description here

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

As in your quote, the immediate is rotated right by twice the value given in the rot field.

So for example in the case with rot=0001 the immediate value is rotated right two places causing two 1's to re-appear in the most significant position.

In the case of rot=1111 or 15 decimal, the rotation would be by 30 places. Consider for a minute that rotating by 32 places would put the immediate value right back where it started, rotating right two places short of "completing the circle" back to the starting value yields an effective rotation left by 2 places, which is exactly what you see.

If that's still unclear, momentarily pencil in a hypothetical case as if the illegal value rot=10000 (16 decimal) were actually legal. You'd then see that this yields the same result as the legal value rot=0000, making it unnecessary. You could also fill in all the intermediate possibilities as desired.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.