simple stack point question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone,

I know that this is embarassingly simple but I could not quite figure
out why it so. So I decided to ask you for some insight.

I wrote a small program to retrieve stack pointer but I could not
understand the results.
FYI, here is the program.


unsigned long get_esp()
{
    __asm__("movl %esp, %eax");
}

int main()
{
    printf("ESP: 0x%x\n", get_esp());
    int a;
    printf("ESP: 0x%x\n", get_esp());
    return 0;
}

result)
ESP: 0xbf9fb048
ESP: 0xbf9fb048

I thought that I should get different value for the 2nd printf because
I have 'int a' in between but when I run it I am getting the same
value for both printfs.
Can anyone give me some insight on this? I am simply trying to get
stack pointer here. I am sorry for simple question and I tried to
google this but I was not good enough to find an answer. Thank you
very much in advance.

Ilho <><
-- 
YES, JESUS LOVES YOU, TOO.
For God so loved the world that he gave his one and only Son, that
whoever believes in him shall not perish but have eternal life(John
3:16).

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux