After an hour of sweating it out, I finally figured out how to do it. I didn't push or pop it at all, although i got some problem with it, that only the function and exit could write to it. Other labels couldn't write values to it :S
I was the one that pushed eax to the stack. Since that didn't work, I just didn't do it again.
The more likely case of pushing eax onto the stack however, seems to me to be that the calling code had a value in eax it wanted to preserve, so before pushing on all the function parameters, it pushed eax to save the value during the function call. It would then do whatever it needs to with the return value that is in eax when the function is done, then pop the old eax off the stack for use.
So if i returned control back to main. How would I pop %eax, because I would be in the C code then.
This is what I got so far. appears to be working
int cmpString(char *s1, char *s2);
char string1="Hello World" ;
char string2="Hello World" ;
printf("The strings match!\n") ;
printf("The strings do not match!\n") ;
return 0 ;
/*c function to compare strings
int cmpString(char *s1, char *s2)
s1++ ;s2++ ;
Assembler code to compare string.
movl %esp, %ebp
pushl %esi #save contents of esi
pushl %edi #save contents of edi
pushl %ebx #save contents of ebx
movl 12(%ebp), %esi #point to s2
movl 8(%ebp), %edi#point to string1
cmpb $0, (%esi)
cmpb %bl, (%edi)
movl $1, %eax
movl $0, %eax