|
There can only be one stack in the stack segment of the program. SS is located at the starting address (base address, low address) of the stack segment, and the bottom of the stack is at the end (high address) of the effective address of the stack segment. SP is initialized to the size of the stack segment, and SS:SP always points to the top of the stack. During initialization, SS:SP points to the highest address of the stack segment (at this time, both the bottom and top of the stack point to this memory address). As the element is pushed, SP keeps getting smaller, and then the top address of the stack represented by SS:SP gets smaller, not equal to the bottom address of the stack, but gradually approaching the starting address of the stack segment. When SP is 0, SS:SP represents The top address of the stack is equal to the start address of the stack segment represented by SS:0000, and then the stack is full. I guess the CPU also checks whether the stack overflows by judging SP<0. |
|