I assume you have some sort of dup_string
routine that duplicates a string in a new memory block. That dup routine must be aware that the source string has an unkown length, that will be only determined while the copying is being performed, something like:
char *dup_string (char *s)
{
char *d = realloc(strlen(s)+1);
memcpy (d, s, strlen(s)+1);
return d;
}
So you can use this function transparently by using it in your caller code and your calle epilog, like this...
/* Source code: your programming language */
str s;
s = "whatever...";
func (s);
Generated assembly code would be like this (example using IA32 code, and C calling convention):
[Caller: this block repeated for every string passed as parameter to a function]
push offset s
call dup_string ;string copy pointed by EAX
add esp,4 ;get rid of parameter
push eax
call func
add esp,4 ;get rid of parameter
...
...
[Callee]
push ebp
mov ebp,esp
mov esi,[ebp+8] ; ESI = pointer to string
...use string in ESI...
...
...
EPILOG
(this block repeated for every string passed as argument):
mov esi,[ebp+8] ;8 because in this example, it's the first argument.
call free /* standard free() function */
mov esp,ebp
ret