This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
GCC 3.2/x86 Question
- From: Jens Thomsen <MisfitsPlan9 at access-4-free dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 06 Jul 2003 17:05:59 -0600
- Subject: GCC 3.2/x86 Question
Hi All,
I have two relatively simple questions. First I am using some inline
assembly
that captures the current value of %esp and then calls a funtion which
takes %esp
as it only arg then spits out the difference between the two. Now, this
should give
me the amount of stack 'usage' for the function including stack
variables and args,
right. Well, the number seem a little funny, and not know that much
about assembly
I can't really surmise whether gcc is really just allocating more than
enough stack or
I screwed up. So the question is does the code below give the actual
stack usage?
void
somefunc(int esp)
{
int esp1;
asm ("movl %%esp, %0;" :"=m"(esp1));
printf("%d\n", esp - esp1);
}
int
main(void)
{
int esp;
asm ("movl %%esp, %0;" :"=m"(esp));
somefunc(esp);
}
Second question. From looking at some of the docs and testing a small chunk of code (see below), I can't seem to get the value of EIP or IP
(Instruction Pointer) from inline assembly. Does anyone know how to do this?
asm ("movl %%eip, %0;" :"=m"(eip));
Thanks in advance,
Jens Thomsen
--
Jens Thomsen
Deep Magic Consulting