From: Frederic Marmond <fmarmond@eprocess.fr>
To: fmarmond@eprocess.fr
Cc: Vadiraj C S <vadiraj@mail.cyberneme.com>, linux-assembly@vger.kernel.org
Subject: Re: stack contents at function call
Date: Fri, 05 Mar 2004 08:26:48 +0100 [thread overview]
Message-ID: <40482BB8.5040201@eprocess.fr> (raw)
In-Reply-To: <40430572.1000702@eprocess.fr>
Hi,
Did you find the problem?
I would appreciate feed-backs, as I don't see what may differ from intel
and gcc...
If you find the explanation, it would be nice to share it!
And if you didn't find, just send me the generated assembly (see at the
end of my last reply) I may be in some help...
Fred
Frederic Marmond wrote:
> Vadiraj C S wrote:
>
>> Mr Fred
>>
>>
>>
>>> Convention for C on x86 (I guess you are on this arch) is to pass
>>> arguments to stack. So, if you respect this convention from
>>> assembly, the sequence is the same.
>>>
>>>
>>
>> Yes I'm in x86 arch..
>>
>>
>>>> Cos I noticed difference with gcc(GNU compiler) and icc (Intell
>>>> compiler)
>>>>
>>>>
>>>>
>>>
>>> Can you give example? Be more precise...
>>>
>>
>>
>>
>> void Func_call(unsigned long *a, unsigned shor int b, unsigned short
>> int c)
>> {
>>
>> asm volatile ("pushl %esi");
>> asm volatile ("pushl %edi");
>> asm volatile ("pushl %ebp");
>> asm volatile ("pushl %ebx");
>>
>> This below code works different in gcc and in icc
>> {
>> asm volatile ("movl 28(%esp),%esi");
>> asm volatile ("movw 32(%esp),%dx");
>>
>> asm volatile ("movl 36(%esp),%ebx");
>>
>> }
>>
>> Thought it should be, 16 bytes for the pushed values, and 4 bytes
>> for return address
>> so 24th byte should be the pointer to the first parameter a, GCC
>> points to the perfect with 28th being referrenced to the first
>> parameter. How is this...
>>
>>
> I agree it seems strange.
> But:
> - can you give the entire function?
> If you use any temporary data in your function, its memory will be
> reserved on the stack (and then, be inserted before your first "pushl
> %esi")
> - can you create a helloworld.c that contains this function, called in
> the main, and compile it with the '--save-temps' option?
> With gcc-3.x, it will create a helloworld.s file, that is the
> assembly generated file from your helloworld.c
> We will see better what append
>
>>
>>
>> and icc (intell compiler) it is what we expect it to be. esi is
>> having the b value...
>>
>> It was strange..
>>
>>
>> asm volatile ("movl %esi,%ebp");
>>
>> does ebp store any thing important, cos when this statement is
>> executed the parameter values get changed
>> while tracing from GDB. Please throw some light regarding ebp..
>>
>>
> The function of ebp is to keep track of the local data on stack.
> Generaly, you set ebp to esp when entering the function, and use it to
> reference your local data.
> Then, if you push/pop things (affect esp) the data will be always at
> the same place regarding ebp.
> for exemple:
> push %ebx
> push %edx
> call foo_function
> ...
> foo_function:
> mov %esp,%ebp
> 4(%ebp) => refer to pushed edx
> 4(%esp) => refer to pushed edx
> push %eax
> 4(%ebp) still refer to the pushed edx
> 4(%esp) doesn't refer to pushed edx anymore
>
>> Thanks for the support Fred
>>
>>
> You're welcome, I'm at work and have nothing to do for now...
> boring! ;)
>
> Fred
>
>>
>>
>>
>
>
>
next prev parent reply other threads:[~2004-03-05 7:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-01 7:48 stack contents at function call Vadiraj C S
2004-03-01 8:36 ` Frederic Marmond
2004-03-01 8:42 ` Vadiraj C S
2004-03-01 9:42 ` Frederic Marmond
2004-03-05 7:26 ` Frederic Marmond [this message]
[not found] ` <20040305135011.3ac14610.vadiraj@mail.cyberneme.com>
2004-03-05 9:00 ` Frederic Marmond
2004-03-01 9:40 ` peter willy krause
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40482BB8.5040201@eprocess.fr \
--to=fmarmond@eprocess.fr \
--cc=linux-assembly@vger.kernel.org \
--cc=vadiraj@mail.cyberneme.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.