------- Comment #2 from etienne_lorrain at yahoo dot fr 2006-09-12 11:12
-------
> "X" (*str)
> We need a temporary here because *str can be modified inside the asm and we
> don't know that you want it in a memory or a register.
*str cannot be modified inside the asm because that is an input.
Even if it is modified, copy_in_dataseg is a "dead" variable, out of scope.
Considering its size (26 bytes), it cannot be in register.
> Anyways using "m"(*str) instead changes that and fixes your issue.
But that insert a seriously strange initialisation of %dl (or %edx with
GCC-3.4.6):
cygne:/home/etienne/projet# cat aa.s
.file "aa.c"
.text
.globl BOOT1_uninstall_mbr
.type BOOT1_uninstall_mbr, @function
BOOT1_uninstall_mbr:
pushl %edi
pushl %esi
pushl %ebx
subl $28, %esp
movl %esp, %eax
pushl $28
pushl $uninstall_mbr
pushl %eax
call memcpy
leal 8(%esp), %esi
movb 10(%esp), %dl
#APP
movw %es,%ax
pushl $31744
popw %bx
popw %es
pushw %ax
callw read_disk
popw %es
setc %dl # set dest to 1 if carry, else clear dest
#NO_APP
xorl %eax, %eax
testb %dl, %dl
setne %al
addl $28, %esp
popl %ebx
popl %esi
popl %edi
ret
.size BOOT1_uninstall_mbr, .-BOOT1_uninstall_mbr
.comm uninstall_mbr,28,4
.ident "GCC: (GNU) 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)"
.section .note.GNU-stack,"",@progbits
> Since "X" means any operand, this is the correct behavior of the compiler.
Maybe that is "m" which is strange, I never understood what is the added
instruction so did not used it. I was thinking "m" forced a memory referenced
with a symbol (so not in stack) - and I have seen temporary .data variables
generated for that - and the associated copy back to stack, maybe only when
used as asm outputs.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29029