ako neko vidi gde gresim , neka mi kaze.
swap.s
.intel_syntax noprefix
.text
.global swap_strings
#funkcija swap_strings
#menja stringove s1 i s2
#koji se nalaze
#na adresama [ebp+8] i [ebp+12]
swap_strings:
enter 0,0
mov eax, [ebp+8]
mov eax, [eax]
mov ecx, [ebp+12]
xchg [ecx], eax
mov ecx, [ebp+8]
xchg [ecx], eax
leave
ret
i jos test.c
#include <string.h>
#include <malloc.h>
extern void swap_strings(char *s1, char *s2);
int main()
{
char *s1;
char *s2;
s1=strdup("prvi");
s2=strdup("drugi");
printf("%s , %s \n",s1,s2);
swap_strings(s1,s2);
printf("%s , %s \n",s1,s2);
return 0;
}
i komande za kompajliranje (pod linuksom)
as swap.s
gcc -c test.c
gcc -o test test.o swap.o
[Ovu poruku je menjao Sundance dana 28.01.2005. u 16:02 GMT+1]