Why is the stack pointer always the same?
From: Derek Fountain (nospam_at_example.com)
Date: 08/24/04
- Next message: Grant Edwards: "Re: Why is the stack pointer always the same?"
- Previous message: Fredrik Tolf: "Re: Joystick Driver"
- Next in thread: Grant Edwards: "Re: Why is the stack pointer always the same?"
- Reply: Grant Edwards: "Re: Why is the stack pointer always the same?"
- Reply: Artie Gold: "Re: Why is the stack pointer always the same?"
- Reply: Kasper Dupont: "Re: Why is the stack pointer always the same?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 24 Aug 2004 10:38:57 +0800
Why is it that when starting a program, the stack pointer always starts
with the same value? That is, if I have this:
unsigned long get_sp(void) {
__asm__("movl %esp,%eax");
}
void main() {
printf("0x%x\n", get_sp());
}
and run it over and over, it always prints the same address?
In my ignorance I'd have thought that when a program is started up by
the shell, the stack would be placed somewhere according to some rules
which consider what memory is free etc. This obviously isn't the case.
What's going on?
- Next message: Grant Edwards: "Re: Why is the stack pointer always the same?"
- Previous message: Fredrik Tolf: "Re: Joystick Driver"
- Next in thread: Grant Edwards: "Re: Why is the stack pointer always the same?"
- Reply: Grant Edwards: "Re: Why is the stack pointer always the same?"
- Reply: Artie Gold: "Re: Why is the stack pointer always the same?"
- Reply: Kasper Dupont: "Re: Why is the stack pointer always the same?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|