My BSOD
[quote]
4.2.2. Stack Alignment
The stack pointer for a stack segment should be aligned on 16-bit (word) or 32-bit (double-word)
boundaries, depending on the width of the stack segment. The D flag in the segment descriptor
for the current code segment sets the stack-segment width (see “Segment Descriptorsâ€
4.2.2. Stack Alignment
The stack pointer for a stack segment should be aligned on 16-bit (word) or 32-bit (double-word)
boundaries, depending on the width of the stack segment. The D flag in the segment descriptor
for the current code segment sets the stack-segment width (see “Segment Descriptorsâ€
Intel manuals say all!If a 16-bit value is pushed onto a 32-bit wide
stack, the value is automatically padded with zeros out to 32 bits.
Okay okay, I will read them more...
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
I'm confused.. Why to force 16-bit? The stack will become, logically, unaligned then...The "word" is there to force 16-bit
Never mind that, I heard MOV EAX, [ESP - X] should do the POP operation without screwing the stack. What I need to appoint for the X when I want to pop the last dword on the stack? 8? And for word value, 4 ?
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
the problem is, there is no "ordinary" push bx or pop bx, you have to use the 0x66 prefix (which turns it into a 16bit operation)Edwin wrote:Okay, that may be right, but there is no reason why an ordinary push bx or pop bx should screw up stack alignment.
56 00000042 6650 push word ax
60 0000004E 6650 push ax
exactly the same opcode, the word is just there to clarify things a bit
Hmm I tried it myself and it seems you're right Aali, it seems that successive 16-bit push and pops indeed screw up the alignment, but when I do a push ax and then a 32-bit push, stack alignment seems normal.
So I think that the CPU tries to align the stack to the size of the pushed or popped value. It's confusing because the Intel-manual is not clear about this issue (as far as i've seen).
So I think that the CPU tries to align the stack to the size of the pushed or popped value. It's confusing because the Intel-manual is not clear about this issue (as far as i've seen).