My questions is a simple/hard one, whats a stack on an intel machine? I don't a need lesson on how to use one for I already know how, its just that I really don't know very much about them. Like how come you can automatically allocate memory on them by simply moving the stack pointer. Is this just the way its designed, the intel chip, increase or decrease the value in esp and increase or decrease memory available to the program. Can a user program create stacks as needed?
I guest what I,m looking for is a really detailed article on the stack for intel cpus

So if anyone knows of a good website please let me know

Thanks in advance...Gerard4143

P.S. I have read the 4 big Intel Manuals

Recommended Answers

All 5 Replies

It has nothing to do with Intel. Every OS must allocate and initialize memory for programs, no matter what chipset you are using. When the OS places your program into memory, it places the various parts in the proper places: Code goes in one place, Data goes in another, and the Stack in another. The OS then sets the computer's IP (code pointer), DP (data pointer), and SP (stack pointer) registers to address the proper memory locations.

On Intel x86, the stack grows towards low memory, and the SP points to the last used element.

So, to push a value (say, in ax) on the stack would be akin to dec esp mov [sp], ax (this is what push ax does internally)

Then to pop a value: mov ax, [sp] inc sp (this is what pop ax does internally)

This arrangement is not universal. Other architectures vary.
Hope this helps.

What I have problems understanding is when you subl $4, %esp (AT&T syntax sorry) and increase the program's memory how does the operating system know to validate this increases. I have a very simple understanding of this process but would like a more techincal understanding....Thanks Gerard

Ah, you're beyond me there. It is a feature of the microchip. The x86 Protected Mode is used to protect programs from accessing things they shouldn't. Earlier chips didn't have this feature, and that's why DOS programs could do whatever they wanted.

In other words, it is built into the hardware.

I know nothing more than that. Sorry.

I know nothing more than that. Sorry.

No problem...Thanks for the interest...Gerard4143

Can a user program create stacks as needed? In the DOS you can done this. I have this eperience with the debug.com . In windows dos VM , the you can show this under the debug.com . I spend two days for to find what's wrong with my program ? , the wrong is it writes to the Interrupted vector table .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.