汇编堆栈对齐方式(或PUSH更好错位的例子) [英] Assembler Stack Alignment (or better misaligned example with PUSH)
问题描述
那么首先我理解(或者我认为我的理解)对齐的堆栈的问题。
Well first I understand (or a I think that I understand) the problems of misaligned stack.
但我知道(如定义)的推着16位值32位宽堆栈可能导致堆栈对齐。
But I know (like a definition) that pushing a 16bit value to 32bit wide stack could cause a stack misaligned.
但我不明白的东西,是如何可以happend ...因为 PUSH
和 POP
检查在该段描述D标志(所以1递增/递减32位是0 16位)。
But the thing I dont understand, is how this could happend...since PUSH
and POP
check the D flag at the segment descriptor (so is 1 increments/decrements 32bits and is 0 16bits).
假设D标志= 1,应 PUSH AX
做一个32位的递减?所以它像我小姐在堆栈中16位?
Suppose that D flag=1, should PUSH AX
do a 32bits decrement? so its like I "miss" 16bits in the stack?
我不知道我理解这个问题。
I am not sure that I understand this problem
推荐答案
虽然这两个推
和弹出
检查D-位在段描述来确定默认操作数大小(即16或32/64位),它可以用一个操作数大小覆盖 0x66
覆盖。
While both push
and pop
check the D-bit in the segment descriptor to determine the default operand size (i.e. 16 or 32/64 bits), it can be overridden with an operand size override 0x66
.
如果对D-位是0,则:
If the D-bit is 0, then:
ff /6
推16位压入堆栈
pushes 16 bits onto the stack
和
66 ff /6
推32位(或64,如果它是一个64位段)。
pushes 32 bits (or 64 if it's a 64-bit segment).
如果为D-位是1,则正好相反。
If the D-bit is 1, then the opposite is true.
在任何情况下, ESP
(或 RSP
或只是 SP
,这取决于地址大小)递增或2(对于16位操作递减),4(32位操作)或8(64位操作)。
In any case, ESP
(or RSP
or just SP
, depending on the address size) is incremented or decremented by 2 (for 16 bit operations), 4 (for 32 bit operations) or 8 (for 64 bit operations).
这篇关于汇编堆栈对齐方式(或PUSH更好错位的例子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!