From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4F144B53.6070906@gmail.com> Date: Mon, 16 Jan 2012 11:07:47 -0500 From: "Joel C. Salomon" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111229 Thunderbird/9.0 MIME-Version: 1.0 To: 9fans@9fans.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] assembly syntax in plan 9 Topicbox-Message-UUID: 5d23cb4c-ead7-11e9-9d60-3106f5b1d025 On 01/16/2012 08:08 AM, Charles Forsyth wrote: > Plan 9 doesn't use a base pointer, because everything can be addressed > relative to the stack pointer, and the loader keeps track of the SP > level. thus FP is a virtual register, that the loader implements by > replacing offsets relative to it by the current appropriate offset from > the hardware stack pointer register (whatever that might be on a given > platform). That's esp on the x86. the TEXT directive specifies the > space a function requires for its stack frame, and the loader then adds > appropriate code at start and end to provide it. 0(FP) is the first > argument, 4(FP) is the second, and so on. 0(SP) is the bottom of the > current frame, and 0(SP), 4(SP) etc are referenced to build the > arguments for outgoing calls (but that space must be accounted for in > the TEXT directive). This would make it difficult to implement C99's variable-length (actually, run-time-determined--length) arrays. The best compiler-only change I can think of would be to define a hidden variable `size_t __size_of_all_vlas`, and add code to adjust SP by that amount before & after each function call. [Or we could just skip C99, and make the compiler C11-compliant by pre-defining __STDC_NO_VLA__. =E2=98=BA] > (it's probably not very different in effect from -fno-frame-pointer or > whatever it is for gcc, which also doesn't use ebp except that is > implemented entirely by the compiler.) Google turns up , indicating that GCC had issues combining VLAs and -fomit-frame-pointer; I don't know how they managed the combination. --Joel