| |

VerySource

 Forgot password?
 Register
Search
View: 2065|Reply: 4

Deep dive into the stack ...

[Copy link]

2

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-2-15 21:00:02
| Show all posts |Read mode
1. What is the correspondence between stack segments and stacks?
A 64K stack segment corresponds to a 64K stack. Is this true? Or can a 64K stack segment correspond to multiple smaller stacks?
2. So how to address the stack through SS: SP?
3. What is the relationship between the stack segment base address and the top and bottom of the stack?
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-17 08:45:02
| Show all posts
Generally speaking, if it is not initialized, ss is loaded into the base address of the stack segment, and sp is initialized to point to the end of the segment minus one byte. At this time, the end of the segment is the bottom of the stack, and the byte pointed to by sp For the top of the stack.
Personally inferred, I also want to know the specific implementation methods of various compilers
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-7 17:30:01
| Show all posts
Personal understanding:
A stack segment corresponds to a stack, and a task has only one stack segment at the same time.
SS stores the selector of the stack segment. The selector specifies the length of the stack, the growth direction and the limit length. SP stores the bottom of the stack segment. At the beginning, the bottom address <= top address, if there is no data in the stack, then the bottom address = top address, otherwise the bottom <top address
Reply

Use magic Report

2

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

 Author| Post time: 2020-5-25 11:30:01
| Show all posts
After a night of thought and reference, the problem was finally solved ...

> 1. What is the correspondence between stack segment and stack?
A 64K stack segment corresponds to a 64K stack, is this the case? Or is a 64K stack segment corresponding to multiple stacks smaller than it?

The stack segment corresponds exactly to the stack, and the size of the stack and the stack segment are equal.

> 2. So how to address the stack through SS: SP?

SS * 16 + SP

> 3. What is the relationship between the base address of the stack segment and the top and bottom of the stack?

The base address obtained after SS * 16 is the top of the stack, and SP points to the bottom of the stack.

                     Thanks:
Thank youkaishibaandamiu888friends for their enthusiastic participation.
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-7-24 21:30:02
| Show all posts
Your understanding is in real mode. In protected mode, you need to use selectors.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list