开发者

getting the starting address of stack [duplicate]

This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

executing assembly within a function in c++

开发者_如何转开发
long getesp() {  
__asm__("movl %esp,%eax");  
}  

void main() {  
printf("%08X\n",getesp()+4);  
}  

why is the esp printed is before the stack is set up?(before the pushl %ebp, movl %esp,%ebp) thanks in advance


My guess: there is no need for a frame, so none is allocated in getesp. The particulars depend on the compiler and compiler flags you are using.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜