This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Forgetting return values


Jamie Prescott <jpresss@yahoo.com> writes:
> static inline int set_prop(char const *path, char const *name,
>                                           void const *data, int size)
> {
>         int error;
>
>         asm volatile ("int\t11\n\t"
>                       : "=a0" (error): "a0" (path), "a1" (name), "a2" (data),
>                         "a3" (size));
>
>         return error;
> }
>
> extern int calc(int);
>
> int proc(int i)
> {
>         int j = calc(i);
>
>         return set_prop(0, 0, &j, sizeof(int));
> }
...
>
> Why is the memory clobber required, and why GCC does not understand to
> sync the value to memory when passing the address to a function?

Because you never inform GCC that you will use the value at
address *NAME.  Try to use "m"(*name) rather than "a1"(name) in the asm.

Adam


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]