This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
asm("") matter, mostly on i386
- To: gcc-bugs at gcc dot gnu dot org
- Subject: asm("") matter, mostly on i386
- From: Etienne LORRAIN <etienne_lorrain at yahoo dot fr>
- Date: Wed, 12 Jan 2000 13:01:19 +0100 (CET)
- Cc: etienne dot lorrain at ibm dot net
- Reply-To: etienne dot lorrain at ibm dot net
Hello,
Here is two problems, the first is only for i386:
---------------------
bash-2.02$ cat bug1.c
void fct (void)
{
asm ("" : : : "ebp");
}
bash-2.02$ xgcc -S bug1.c
bash-2.02$ cat bug1.s
.file "bug1.c"
.version "01.01"
gcc2_compiled.:
___gnu_compiled_c:
.text
.align 16
.globl _fct
.def _fct; .scl 2; .type 32; .endef
_fct:
pushl %ebp
movl %esp, %ebp
/APP
/NO_APP
L2:
movl %ebp, %esp ###### %ebp is reused even if clobbered !
popl %ebp
ret
bash-2.02$ xgcc -v
Using builtin specs.
gcc version 2.96 19991201 (experimental)
bash-2.02$
---------------------
I do not know if the problem is that "ebp" is accepted
on the clobber list or that there is a problem in its
save/restore. It does not work neither when -fomit-frame-pointer
is specified - but only for functions using the %ebp register
to store a variable (else %ebp is correctly pushed/poped).
It would be nice to be able to also use this "ebp" register in
input/output of asm("int $0x10" : "+B"(...) ) - but I would
be the only guy to use it - so it is OK to give an error
message.
The second thing is something I have already reported, but in
another form - i.e. the const'ness of an inline function:
---------------------
bash-2.02$ cat bug3.c
static unsigned inline peekl (unsigned addr)
{
unsigned val;
asm (" mov %%gs:%a1,%0 " : "=r" (val) : "r" (addr));
return val;
}
unsigned fct (unsigned addr)
{
unsigned val1, val2;
val1 = peekl (addr);
asm ( "" ::: "memory");
val2 = peekl (addr);
return val2 - val1;
}
bash-2.02$ xgcc -S -O -fomit-frame-pointer bug3.c
bash-2.02$ cat bug3.s
.file "bug3.c"
.version "01.01"
gcc2_compiled.:
___gnu_compiled_c:
.text
.align 16
.globl _fct
.def _fct; .scl 2; .type 32; .endef
_fct:
/APP
/NO_APP
movl $0, %eax
ret
bash-2.02$ xgcc -v
Using builtin specs.
gcc version 2.96 19991201 (experimental)
---------------------
I know that 'asm (" mov %%gs:%a1,%0 " :::)' could be declared
volatile - but look at what it does - it is not _volatile_ (for
instance if the returned value is ignored, it does not worth
inserting the assembly) it is just _NOT_ const - it depends
on "memory" (and it is not clobbering it). Declaring a function
"volatile" is not the opposite of declaring it "const" - and
it seems that "peekl()" has been optimised like a const function,
without having explicitely the const attribute - the asm() does
not have the const attribute neither.
Have a nice day,
Etienne.
___________________________________________________________
Do You Yahoo!?
Achetez, vendez! À votre prix! Sur http://encheres.yahoo.fr