| |

VerySource

 Forgot password?
 Register
Search
Author: qqion1988

Questions about the stack segment SS register.

[Copy link]

2

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

 Author| Post time: 2020-7-28 16:30:02
| Show all posts
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.
Reply

Use magic Report

2

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

 Author| Post time: 2020-7-28 19:45:01
| Show all posts
I found a question and its answer on the Internet, please refer to it.

1. If a stack starts from address 3250H:0000H, the offset address of its last word is 0100H, and the content of SP is 0052H, ask:
1 What is the top address of the stack?
2 What is the bottom address of the stack?
3 What is the content of SP after saving data 1234H and 5678H?

answer:
1 The highest address of the stack is called the bottom of the stack, and the stack indicator SP always points to the top of the stack.
Stack top address=(SS)×10H+(SP)=3250H×10H + 0052H=32552H
2 Stack bottom address = (SS)×10H + 0100H=32600H
3 The stack access in 8086CPU must be based on words. After the data 1234H and 5678H are stored, that is, after the two words are pushed onto the stack, SP is reduced by 4. The content of SP is: (SP)-number of words×2=0052H-2×2=004EH. The content of SS remains unchanged.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-1 00:45:01
| Show all posts
In the next beginners, the microcomputer principle supportsqqion1988. Recently, my classmates have asked the same question. I agree with Mr. M. Then, first open up the 64k maximum space in the memory and give the stack ss point to the low address. Sp always points to the top of the stack. Initialization should be put into the stack at the high address. Is in line with sp-2
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-5 22:15:01
| Show all posts
The above is so complicated, but the 21# example is easier to understand! ! ! ! ! !
Reply

Use magic Report

0

Threads

2

Posts

0.00

Credits

Newbie

Rank: 1

Credits
0.00

 China

Post time: 2020-11-26 22:23:37
| Show all posts
Owner, help you top the post
Reply

Use magic Report

0

Threads

2

Posts

0.00

Credits

Newbie

Rank: 1

Credits
0.00

 China

Post time: 2020-11-26 22:24:35
| Show all posts
The original poster, help you top the post,,,,
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