i'm trying to learn some assembly. All i want to do is declare an external c function with an input and an output string as parameters, and modify it with assembly. From what i know, arrays are always passed by reference. Here is a c example:
extern int mod_array(char input[], char output[]);
char input[SIZE]={'0','1','1','0','1'};
char output[SIZE]={'x','x','x','x','x'};
mod_array(input, output);
So i was thinking that fetching the address and modify the memory space will work. Here is a piece of assembly
.data
label: .string "s"
.text
.global mod_array
mod_array:
pushl %ebp #setup
movl %esp, %ebp #setup
movl 12(%ebp), %edx #fetching the address of the output array
movl label, (%edx) #moving label to the pointed space (first char of array)
#error
popl %ebp #setup
ret
The assembler produce an error. "Too many reference for mov". Now i can't understand if the problem is the variable label that i used, maybe because it does not have the dimension of 1B or if this is a sintax problem. Am i using an addressing mode that doesn't exists?
Is correct to think that, if i'm able to modify the space of memory pointed in asssembly, then also c main will see the changes?
Thanks