Practical Applications for Swing Carry Left / Right
2 answers
If you want to shift bits from one operand to the other:
SHL EAX, 1 ; move sign bit of EAX ...
RCL EDX ; into LSB of EDX
If you want to change bits in EAX:
MOV ECX, 32
loop: SHR EAX, 1
RCL EDX
DEC ECX
JNE LOOP
; EDX == EAX with bits reversed here
The real point is that these rotate instructions grab "bits" of data from other operands and allow them to be combined with existing data. You want your machine to provide a rich set of data processing primitives so that you can shuffle data at will.
Having said that when looking for my app with about 30,000 lines of source code, I only see 3 or 4 use cases. But then I am not using some of the other instructions in the Intel instruction set. Rare use does not mean uselessness.
Can you live without these instructions? Your processor is Turing-enabled, of course.
+4
source to share