views:

15

answers:

0

Hi!

i'm just about to learn inline assembly.the GCC inline assembly cookbook http://www.ethernut.de/en/documents/arm-inline-asm.html says:

A strict rule is: Never ever write to an input operand.

can someone tell me whether - and if so why - this rule is true?

let's say i get the value of an input operand through some register. Am I not allowed to reuse this register within the same assembly block if i don't inted to declare it also as output operand?

example:

asm volatile("add %[value], %[value], %[value]   \n\t"
    "mov %[result], %[value]   \n\t"

       : [result]"=r" (y) 
       : [value]"r"   (x)
       : //no clober
);

I know the example doesn't make much sense - but is it invalid?

I ask because i'm writing some assembly function that takes many input operands, each taking a general purpose register. since there are only 12 GPR's available on my architecture, with each input operand i get less "free" registers to work with. so do I really have to declare the input registers also as output in order to use them to "work" with them inside the function (even though i don't need theyr value outside the inline-assembly body? If so - can someone explain why?

hope the question is clear

thanks!