From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] pointer to the last TOS From: "Russ Cox" Date: Thu, 2 Mar 2006 10:24:25 -0500 In-Reply-To: <599f06db0603020657u19643c27nad00cbf2998bf877@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 09d9f534-ead1-11e9-9d60-3106f5b1d025 > 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