Stack mechanism of cpu

The 8086 CPU provides stack in and stack out operations, push [stack in] pop [stack out], push ax, that is, the data of ax is sent to the top of the stack, pop ax, and the data is taken from the top of the stack and sent to ax. For these two operations, stack in and stack out are performed in words. There are two registers in the 8086 CPU, segment register SS and register SP. At any time, SS: SP points to the top element of the stack.

The execution of push ax is divided into the following two steps

1. SP=SP-2 SS: SP points to the current new stack top

2. Send the contents in ax to the memory unit pointed to by SS: SP

Pop ax execution process

1. Send the content pointed by SS: SP to ax

2. SP=SP+2, pointing to the new stack top

[Question] How to use 10000H-1000F as stack space

mov ax,1000H

mov ss,ax

mov sp,0010

The key point here is that if you use a section of space as the stack space, you can only set the initial position of the top of the stack. However, when you use a section of space as the stack space, you need to pay attention to the specific position when programming.

The article comes from the reading comprehension of Wang Shuang's assembly language

Stack mechanism of cpu 》Have an idea

Post reply

Your email address will not be disclosed. Required items have been used * tagging

This site uses Akismet to reduce spam comments. Learn how we handle your comment data