public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Passing 64-bit function arguments to assembler
       [not found]   ` <5077E097.2070506@gmail.com>
@ 2012-10-12  9:26     ` Andrew Pinski
  0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2012-10-12  9:26 UTC (permalink / raw)
  To: Mischa Baars; +Cc: gcc-help

On Fri, Oct 12, 2012 at 2:19 AM, Mischa Baars <mjbaars1977@gmail.com> wrote:
> On 10/12/2012 11:01 AM, Andrew Pinski wrote:
>>
>> On Fri, Oct 12, 2012 at 1:55 AM, Mischa Baars <mjbaars1977@gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> Here's a possible bug in the compiler:
>>>
>>> As can be seen from the objdump output, 64-bit arguments are passed in
>>> 32-bit registers
>>>
>>> 000000000040049c <main>:
>>>    40049c:    55                       push   rbp
>>>    40049d:    48 89 e5                 mov    rbp,rsp
>>>    4004a0:    be 44 44 00 00           mov    esi,0x4444
>>
>> this is the same as
>> mov rsi, 0x4444
>>
>> As all instructions which act on the lower 32bit part of the register
>> are zero extended into the full 64bit register.
>
> I see, you are completely right!
>
>>
>>
>>>    4004a5:    bf 33 33 00 00           mov    edi,0x3333
>>
>> Likewise.
>>
>> Thanks,
>> Andrew Pinski
>>
>> PS this question is more relevant to the gcc-help mailing list than the
>> gcc one.
>>
>>>    4004aa:    e8 05 00 00 00           call   4004b4 <function>
>>>    4004af:    90                       nop
>>>    4004b0:    5d                       pop    rbp
>>>    4004b1:    c3                       ret
>>>    4004b2:    66 90                    xchg   ax,ax
>>>
>>> also the opcodes on line 4004AF and 4004B2 seem obsolete.
>
> And what are these lines doing here exactly?


The nop is generated by GCC but I have no idea why and since you are
compiling at -O0, it does not matter.
The xchg is being generated not by the assembler or GCC but rather by
the linker for alignment reasons.
Thanks,
Andrew


>>
>>
>>
>>> Best Regards,
>>> Mischa.
>
>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-12  9:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5077DB11.7080701@cyberfiber.org>
     [not found] ` <CA+=Sn1kBUoFeoJeEF997a9DgKEQ5fwuPQwvyphnK4JTTzDZNmQ@mail.gmail.com>
     [not found]   ` <5077E097.2070506@gmail.com>
2012-10-12  9:26     ` Passing 64-bit function arguments to assembler Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).