05.02.2013 Views

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Shift <strong>and</strong> rotate operations<br />

The following types of shift <strong>and</strong> rotate operations are used in instructions:<br />

Logical Shift Left<br />

Logical Shift Right<br />

Arithmetic Shift Right<br />

Application Level Programmers’ Model<br />

(LSL) moves each bit of a bitstring left by a specified number of bits. Zeros are shifted in at<br />

the right end of the bitstring. Bits that are shifted off the left end of the bitstring are<br />

discarded, except that the last such bit can be produced as a carry output.<br />

(LSR) moves each bit of a bitstring right by a specified number of bits. Zeros are shifted in<br />

at the left end of the bitstring. Bits that are shifted off the right end of the bitstring are<br />

discarded, except that the last such bit can be produced as a carry output.<br />

(ASR) moves each bit of a bitstring right by a specified number of bits. Copies of the leftmost<br />

bit are shifted in at the left end of the bitstring. Bits that are shifted off the right end of the<br />

bitstring are discarded, except that the last such bit can be produced as a carry output.<br />

Rotate Right (ROR) moves each bit of a bitstring right by a specified number of bits. Each bit that is shifted<br />

off the right end of the bitstring is re-introduced at the left end. The last bit shifted off the<br />

right end of the bitstring can be produced as a carry output.<br />

Rotate Right with Extend<br />

(RRX) moves each bit of a bitstring right by one bit. The carry input is shifted in at the left<br />

end of the bitstring. The bit shifted off the right end of the bitstring can be produced as a<br />

carry output.<br />

Pseudocode details of shift <strong>and</strong> rotate operations<br />

These shift <strong>and</strong> rotate operations are supported in pseudocode by the following functions:<br />

// LSL_C()<br />

// =======<br />

(bits(N), bit) LSL_C(bits(N) x, integer shift)<br />

assert shift > 0;<br />

extended_x = x : Zeros(shift);<br />

result = extended_x;<br />

carry_out = extended_x;<br />

return (result, carry_out);<br />

// LSL()<br />

// =====<br />

bits(N) LSL(bits(N) x, integer shift)<br />

assert shift >= 0;<br />

if shift == 0 then<br />

result = x;<br />

else<br />

<strong>ARM</strong> DDI 0406B Copyright © 1996-1998, 2000, 2004-2008 <strong>ARM</strong> Limited. All rights reserved. A2-5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!