title: Rotate left/right with number of moves using GCC assembly
body: <p>I have the following code to calculate rotate left/right in Visual Studio assembly.</p>
  
  <pre><code>template&lt;class T&gt;
  inline T rotr(T x, unsigned char moves){
      unsigned char temp;
      __asm{
          mov temp, CL
              mov CL, moves
              ror x, CL
              mov CL, temp
      };
      return x;
  }
  template&lt;class T&gt;
  inline T rotl(T x, unsigned char moves){
      unsigned char temp;
      __asm{
          mov temp, CL
              mov CL, moves
              rol x, CL
              mov CL, temp
      };
      return x;
  }
  </code></pre>
  
  <p>1- How can we write the equivalent asm code for gcc.</p>
  
  <p>2- Is there a better way to write it in Visual Studio assembly?</p>