最近一段時間在研究dbg方面的細節技術,最終也想排除困擾自己已久的一些寄存器概念。在寄存器中最重要的3個指針概念就是EIP(指令指針),EBP(frame pointer),和ESP(stack pointer)。其中,eip的概念很好理解,就是指向將要執行的指令,比如函數地址等。但ebp和esp理解起來經常會有些混淆。說實話到現在我還是沒有徹底理解,不過我好像記住了一句話:
The stack pointer always points to the top (or bottom, if you prefer)of the stack. The frame pointer always points to the frame. Stack operations (e.g., push, pop, call) do not modify the frame (in a properly operating system) or the frame pointer (ever).
大概理解起來就是esp指向是棧頂的地址,而ebp指向當前動作幀,比如當前執行的函數幀,這里面用幀來理解再確切不過了。
下面轉載一篇文章,有助于更深一步的加深理解。
http://lazyflai.blogspot.com/2008/07/cfunction-callstack-frame.html
另:我發現臺灣的一些bloger寫的技術水平要比大陸稍微高一些。早上找到兩篇有用的文章均是來自臺灣同胞。同一個世界,同一個中國。