|
First of all, SS*16D represents the base address of the stack segment, no doubt. If this base address is the high address of the stack segment, this high address is also the bottom of the stack (high address). In this way, SS*16D represents the bottom of the stack, and SP points to the top of the stack. When the stack is empty, the bottom of the stack = the top of the stack, SP-> the top of the stack, at this time, it can only be 0 to ensure "top of the stack = bottom of the stack", that is, SS*16D=SS*16D+SP. What about SP if you push an element into the stack? Increase or decrease? Neither fit. If the SP increases, the stack will develop toward higher addresses; if SP decreases, there will be a problem. SP is already 0. Is it impossible to reduce it to a plural number? If SP is initialized to the stack size, SS:SP is positioned to the bottom of the stack, because SP is equal to the size of the stack during initialization, which is not 0. Obviously SS:SP is greater than SS:0000, then SS only points to the low address stack bottom of the stack segment Up.
************************************************** **************************
When initializing a stack, how can sp be 0? Think about the code below, and look at the picture
mov ax, stack
mov ss, ax
mov sp, 10h
After executing the above code, the result is like this
0x0000| |
0x0001| |
0x0002| |
0x0003| |
0x0004| |
0x0005| |
0x0006| |
0x0007| |
0x0008| |
0x0009| |
0x000A| |
0x000B| |
0x000C| |
0x000D| |
0x000E| |
0x000F|______|<-------- ss
0x0010 <-------- sp |
|