This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Popping registers


>What is a stack? What does the compiler use it for? Why would messing
>with it be a bad idea? And no, I do not know assembly, and I haven't
>had computer science class yet. 

Well if you don't know what a stack is, then why are you asking how to
pop from it? :)

The stack is where the program allocates local storage and
pushes parameters and save/restores registers used by called functions
as well as save the return address when it calls another function so
the called function knows where to access the parameters and how to return to
the caller function.

Directly or indirectly modifying the stack pointer behind the back
of the compiler is *really* asking for trouble since modifications to
the stack pointer that are not known to the compiler will break the
ABI and cause you rprogram to "go off into the weeds" with no hope of
understanding why.  Richard is right; it is *definitely* something you
don't want to do in C.  If you have to abuse the stack, then roll up
your sleeves and write in assembler.

Perhaps the real question is to ask *why* you believe that you need to
pop a value from the stack(and thereby modify the stack pointer)?

Do some research on what a stack is and how its used in
programming(here Google is *definitely* your friend).

-- 
Peter Barada
peter@the-baradas.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]