title: How can I move a int from xmm register to eax register?
body: <p>I have to call an assembly method to calculate an addition of two integers, using sse, from C.</p>
  
  <p>The simple C code is:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  extern int add(int a, int b);
  
  int main(){
  
      int a=5;
      int b=2;
      int n = add(a,b);
      printf("%d\n",n);
  
      return 0;
  
  }
  </code></pre>
  
  <hr>
  
  <p>While the nasm code is:</p>
  
  <pre><code>section .bss
      RISULTATO   resd    1
  
  section .text
  
  global add
  
  add:
      ;-----------------------------------------------
      ;   start point of the function
      ;-----------------------------------------------
  
      push ebp    ; salva il Base Pointer
      mov ebp, esp    ; il Base Pointer punta al Record di Attivazione corrente
      push ebx    ; salva i registri da preservare
      push esi
      push edi
  
      ;-----------------------------------------------
      ;   add implementation
      ;-----------------------------------------------
  
      movss xmm0, [ebp+8]
      movss xmm1, [ebp+12]
  
      addss xmm1, xmm0
      movss [RISULTATO], xmm1
  
      mov eax, [RISULTATO]
  
      ;-----------------------------------------------
      ;   exit point of the function
      ;-----------------------------------------------
  
      pop edi     ; ripristina i registri da preservare
      pop esi
      pop ebx
      mov esp,ebp ; ripristina lo Stack Pointer
      pop ebp     ; ripristina il Base Pointer
      ret     ; ritorna alla funzione chiamante
  </code></pre>
  
  <hr>
  
  <p>But in this way I need to pass from RISULTATO stored in memory.
  There is any way to avoid this and move directly the result stored in xmm0 to eax?</p>
  
  <p>Naturally I need to move the result of the addition in eax to pass it to my C method, because the return value must to be in eax register.</p>
  
  <p>Thanks for the help. :)</p>