c - How can I move a int from xmm register to eax register? -


i have call assembly method calculate addition of 2 integers, using sse, c.

the simple c code is:

#include <stdio.h> #include <stdlib.h>  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;  } 

while nasm code is:

section .bss     risultato   resd    1  section .text  global add  add:     ;-----------------------------------------------     ;   start point of function     ;-----------------------------------------------      push ebp    ; salva il base pointer     mov ebp, esp    ; il base pointer punta al record di attivazione corrente     push ebx    ; salva 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 function     ;-----------------------------------------------      pop edi     ; ripristina 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 

but in way need pass risultato stored in memory. there way avoid , move directly result stored in xmm0 eax?

naturally need move result of addition in eax pass c method, because return value must in eax register.

thanks help. :)


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -