MOVS with LSL Carry Flag

1

I'm learning The Arm System Developers Guide and I am wondering about one of the examples in the book:

cpsr = nzcvqiFt_USER   // capital indicates flag is set
r0 = 0x00000000
r1 = 0x80000004

MOVS r0, r1, LSL #1

cpsr = nzCvqiFt_USER   // capital indicates flag is set
r0 = 0x00000008
r1 = 0x80000004

I understand that the 8 is carried over and the C flag is set due to this carry based on the logical shift left. Why is the 4 in r1 not shifted as well? Is the MOVS operation only moving the carried 8?

arm
asked on Stack Overflow May 2, 2012 by iOSThing

1 Answer

2

Because your result ends up in r0.

So, what happens is:

carry = r1[31] = 1
r0    = r1 << 1

Thats why r0 becomes 0x00000008 because the MSB of r1 got shifted out to the carry and the third bit (2^3=4) got shifted to the fourth bit (2^4=8).

answered on Stack Overflow May 2, 2012 by Nico Erfurth

User contributions licensed under CC BY-SA 3.0