flat assembler
Message board for the users of flat assembler.

Index > Main > 32-bit code, 16-bit stack behaviour

Author
Thread Post new topic Reply to topic
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen
Let's imagine (weird) protected mode environment setting with stack's segment address attribute 16 bits (this is possible because of B flag in stack descriptor) and code segment's address and operand size 32 bits (D flag in code descriptor).

What happens when opcode 0x50 (PUSH AX/EAX) is executed? Is the following pseudocode correct?
Code:
sub sp, 2
mov [sp], eax
    

In other words, is it correct that high word of EAX rewrites the word stored on the stack last time (before the operation was executed)?
Post 10 Feb 2009, 17:14
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen
I was wrong, the stack pointer is decremented according to current operand-size attribute of the code segment (as the manual says). Now it makes sense - nothing is destroyed.
Code:
sub sp, 4
mov [sp], eax    
Post 10 Feb 2009, 17:31
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.