Messages in this thread | | | Date | Sun, 27 Jun 1999 14:16:46 +0200 | From | Artur Skawina <> | Subject | Re: Question on asm constraints |
| |
Keith Owens wrote: > > The gcc info page for Extended Asm says > "Some instructions clobber specific hard registers. To describe > this, write a third colon after the input operands, followed by the > names of the clobbered hard registers (given as strings)" > and > "If you refer to a particular hardware register from the assembler > code, you will probably have to list the register after the third > colon to tell the compiler the register's value is modified". > > Some kernel asm-i386 constructs do this, others do not, they are not > very consistent. For example, both strtok and strstr explicitly hit > %eax but only strtok declares it in the third constraint.
string-486.h? these routines aren't currently used (see string.h), and certainly could be written in a better (ie more readable) way. It obviously doesn't make sense to mark a register as clobbered when you're returning a value in it - so strstr is ok wrt that. (it has other problems though, like having ecx/esi both as inputs and clobbers).
http://egcs.cygnus.com/faq.html#asmclobber
> strstr > constrains its result to "a" but is that enough? strrchr has an "a" > constraint and it explicitly lists "ax" as well.
if a register contains a result it obviously could have been modified - listing it also as a clobbered register is wrong.
> Why the differences?
asm constraints used to be documented differently is earlier gcc versions...
> Is "ax" optional as a third constraint when input or output is "a" or > should we always specify a third constraint of "ax", just to be on the > safe side?
when an input is modified, you have to declare it as an output too; with a scratch variable, if necessary. see string.h for examples
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |