hi
the intel "system programmer's guide" has got the following to say:
"If the size of a stack segment needs to be changed dynamically, the stack segment can be
an expand-down data segment (expansion-direction flag set). Here, dynamically changing the
segment limit causes stack space to be added to the bottom of the stack."
Does anybody know how I have to read this? The base address of the stack egment sure is the address of the low end of the stack space. So suppose I were to change the limit dinamically, does that mean the stack base (and with it the stack pointer) is automatically adjusted?
expand-down stack
-
- Member
- Posts: 199
- Joined: Fri Jul 13, 2007 6:37 am
- Location: Stuttgart/Germany
- Contact:
Re: expand-down stack
Actually, that's the trick. With normal segments limit controls what the highest valid address in the segment is, but with the expansion-direction flag set it determines the lower valid address. The base address becomes the upper limit of the physical memory you can access through the segment instead of the lower limit.sancho1980 wrote:hi
the intel "system programmer's guide" has got the following to say:
"If the size of a stack segment needs to be changed dynamically, the stack segment can be
an expand-down data segment (expansion-direction flag set). Here, dynamically changing the
segment limit causes stack space to be added to the bottom of the stack."
Does anybody know how I have to read this? The base address of the stack egment sure is the address of the low end of the stack space.
This means that lowering the limit will increase the space in an expand-down segment, adding extra addressable memory to the bottom of the segment.
(This is all IIRC from a slightly obscure section of the processor manual that I've never used myself, so you might want to reread the relevant part of the manual with this information in mind instead of assuming it's all entirely correct
![Smile :)](./images/smilies/icon_smile.gif)
Actually, segment bases and limits refer to virtual memory if paging is enabled.urxae wrote:The base address becomes the upper limit of the physical memory
@sancho1980: I recommend you use flat segmentation and paging if you like to be portable as the 64 bit machines don't like segmentation that much. You can easily protect a stack with non-present pages either side of it.
Regards,
John.
Argh, I know that. I have no idea why I made that mistakejnc100 wrote:Actually, segment bases and limits refer to virtual memory if paging is enabled.urxae wrote:The base address becomes the upper limit of the physical memory
![Embarassed :oops:](./images/smilies/icon_redface.gif)
(Maybe I haven't yet caught up on enough sleep since the ICFP contest)