Discussion:
Stack Frame Top in X86_64
(too old to reply)
pallav singh
2014-03-09 18:26:47 UTC
Permalink
Hi All,

%rsp ( stack pointer ) is used to index the stack frame ( in Optimized Code in X86_64 with -O3 option ).

Whats the register which hold the lowest address (top of frame), defining the boundry of stack frame.

In typical x86 we have frame pointers having highest address and stack pointer have lowest address.

Thanks
Pallav Singh
George Neuner
2014-03-10 05:42:07 UTC
Permalink
On Sun, 9 Mar 2014 11:26:47 -0700 (PDT), pallav singh
Post by pallav singh
%rsp ( stack pointer ) is used to index the stack frame ( in
Optimized Code in X86_64 with -O3 option ).
Whats the register which hold the lowest address (top of frame),
defining the boundry of stack frame.
There may not be one. For a language which lacks nested functions, or
if there are closures which are heap allocated or nested functions
that can be closure converted, implementing the stack does not require
dedicating a separate frame register.
Post by pallav singh
In typical x86 we have frame pointers having highest address and
stack pointer have lowest address.
No. By convention, if a frame pointer is used, BP/EBP/RBP points to
saved register state in the *middle* of the stack frame between the
arguments pushed by the caller (if any) and the local variables of the
callee (if any). The exact position within the frame is function
dependent: determined by the calling convention (stdcall, fastcall,
cdecl, etc.) and by what caller state needs to be preserved. Within
the callee, stack arguments (above BP) are referenced by positive
offsets and stack locals (below BP) by negative offsets.
Post by pallav singh
Thanks
Pallav Singh
Recent questions [here and elsewhere] suggest you might benefit from a
tutorial on x86 architecture and assembly programming ... the
processor documentation from Intel and AMD is not terribly easy to
read. Nor can you learn much from reading about GCC's internals
unless you already know your target CPU quite well.

You might do better to take some of your GCC specific questions to the
GCC mailing list, or to comp.lang.asm.x86 or comp.arch.embedded. Those
groups in particular are frequented by people who know GCC's
intricacies very well.

George

Loading...