Practical Applications for Swing Carry Left / Right

What are some practical uses for turning left and turning following the correct instructions?

In my assembly class, we cannot find a good example where this would be helpful.

+3


source to share


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


These instructions are most useful in the graphics driver. Imagine a 16-color VGA standard resolution and a number from 0 to 15 divided into 4 display planes.



0


source







All Articles