开发者

getting the starting address of stack [duplicate]

开发者 https://www.devze.com 2023-03-06 05:58 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: executing assembly within a function in c++
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

精彩评论

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