I’m just a beginner in Assembly language.
As I know, ESP and SS both refer to stack registers but not quite understand the differences between them.
I’m just a beginner in Assembly language. As I know, ESP and SS both
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
ESPregister is the 32-bit version of the 16-bitSPregister, but in the 32-bit architecture,SSis irrelevant. So, let’s talk about 16-bit first. A note about 32-bit is at the end of the post.In the 16-bit Intel x86 architecture:
SSis the stack-segment register. It identifies the block of memory that will be used for the stack.SPis the stack pointer register. It points to the precise location within the stack segment which is at any given moment the ‘top’ of the stack.The 16-bit Intel architecture had a clunky mechanism for implementing 20-bit wide addresses by means of 16-bit ‘segments’ plus 16-bit ‘offsets’, so the
SSregister would point to the stack segment, and theSPregister would hold the actual offset into the stack. We would say that the current stack location was atSS:SP.Naturally, you might wonder how come they were only able to have 20-bit wide addresses instead of 32-bit wide addresses, given that the segment register was 16-bit wide, and the offset register was another 16-bits wide. Well, this is part of why the architecture was clunky: the actual address represented by the
SS:SPpair was not calculated as(SS << 16) + SP, instead it was(SS << 4) + SP. This means that the segments had a very high degree of overlap: even though each segment was 65536 bytes long, its start was only 16 bytes away from the start of the previous segment. So, thesegment:offsetaddress0:0represented absolute address0, while the1:0address represented absolute address16. (Apparently they did not believe that anyone would ever need to address more than 20 bits of address space.)32-bit
In the 32-bit architecture, none of that matters, because the
ESPregister is large enough to be capable of addressing the entire 32-bit memory address space by itself, with no need for any segment register. So if you are using theESPregister you don’t have to worry about theSSregister at all.