lkml.org 
[lkml]   [1999]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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/

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.106 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site