From: "Russ Cox" <rsc@swtch.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] pointer to the last TOS
Date: Thu, 2 Mar 2006 10:24:25 -0500 [thread overview]
Message-ID: <b6595fdb69e8735f753434ec5e814950@swtch.com> (raw)
In-Reply-To: <599f06db0603020657u19643c27nad00cbf2998bf877@mail.gmail.com>
> I have been doing some experiments and reading some code and I have arrived
> to the (possibly wrong) conclusion that in the stack there is no pointer to the
> TOS before a function was called (I am using 8c)
> If this is true, how is the state of the stack
> recovered after return?. Can anyone point me to a place where I can read
> some documentation or something to solve this kind of doubt.
In the Plan 9 C compiler each stack frame has a constant size.
The beginning of a function does SUBL $XXX, SP
and then the end of a function does ADDL $XXX, SP
to restore the stack pointer before returning.
If you compile and then disassemble using acid
you will see the instructions. They don't appear in the
8c -S output explicitly. Instead the TEXT line specifies
the frame size (TEXT f(SB), 0, $XXX) and the linker
inserts the necessary instructions.
Russ
prev parent reply other threads:[~2006-03-02 15:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-02 14:57 Gorka guardiola
2006-03-02 15:23 ` Brantley Coile
2006-03-02 15:34 ` Gorka guardiola
2006-03-03 1:54 ` geoff
2006-03-02 15:24 ` Russ Cox [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b6595fdb69e8735f753434ec5e814950@swtch.com \
--to=rsc@swtch.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).