title: shrl vs sarl .. x86 Assembly gnu
body: <p>I'm compiling my code with gcc and looking at the assembly, what is this code exactly doing? </p>
  
  <pre><code>shrl $20, %edx
  leal (%edx,%eax), %eax
  sarl 1, %eax 
  </code></pre>
  
  <p>Say that the variable X is at the edx register, and Y is at eax and both are (32-bit int). What is going on here??</p>
  
  <p>I know 'shrl $20, %edx' is shifting %eax right 20 bits, so is same as: eax/(2^20)
  and then sarl is the same so 'sarl 1, %eax' = eax/(2^1).
  Is that right, and if so what does leal do? </p>