x86 堆栈指针指向哪里?堆栈、指针

2023-09-07 10:02:58 作者:老爸老爸我们去哪里呀~

例如如果我推了 ax 是 [SP] 指向我的 ax 值还是 ax 后面的单词?它也不同于实模式和保护模式吗?我问这个是因为汇编艺术书说明和解释了 sp 指向最后推送的数据,并且在此页面上 OSDev Wiki- 堆栈它在最后一次推送数据后指向空字.

For example if I pushed ax is [SP] points to my value of ax or the word after ax? Also is it differs from real mode to protected mode? I ask this because the Art of assembly book illustrates and explains as the sp points to last pushed data, and on this page OSDev Wiki - Stack it illustrated as it points to empty word after last pushed data.

推荐答案

维基百科说这里:

堆栈是通过隐式递减(推送)实现的,并且递增(弹出)堆栈指针.在 16 位模式下,此隐式堆栈指针寻址为 SS:[SP],在 32 位模式下为 SS:[ESP],在64 位模式是 [RSP].堆栈指针实际上指向最后一个存储的值,假设其大小将匹配处理器的操作模式(即 16、32 或 64 位)匹配 push/pop/call/ret 指令的默认宽度.

The stack is implemented with an implicitly decrementing (push) and incrementing (pop) stack pointer. In 16-bit mode, this implicit stack pointer is addressed as SS:[SP], in 32-bit mode it is SS:[ESP], and in 64-bit mode it is [RSP]. The stack pointer actually points to the last value that was stored, under the assumption that its size will match the operating mode of the processor (i.e., 16, 32, or 64 bits) to match the default width of the push/pop/call/ret instructions.

这也是我的回忆说它的工作方式.

This is the way my way-back memory says it works, too.