Hello!
I wanted to create an alternative implementation of strcat. Instead of passing 2 strings by-ref and sticking one on the end of the other one, I want to create a new string that is returned, once the concatenation is done.
In C that would be easy as apple pie:
char *my_strcat( char *str1, char *str2 )
{
int i, j;
char *res = (char *) malloc( strlen(str1) + strlen(str2) + 1 );
for ( i = 0; str1[i]; res[i] = str1[i++] ) ;
j = i;
for ( i = 0; str2[i]; res[j++] = str2[i++] );
res[j] = '\0';
return res;
}
Is something like this also possible in assembly, without a call to malloc/HeapAlloc/whatsoever?
Thanks in advance, aVoX.