Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jul 2001 18:33:31 +0100
From:      j mckitrick <jcm@FreeBSD-uk.eu.org>
To:        freebsd-chat@freebsd.org
Subject:   stack use preference
Message-ID:  <20010723183331.A55127@dogma.freebsd-uk.eu.org>

next in thread | raw e-mail | index | archive | help

For those of you who write or at one time wrote assembly language programs
for the x86 cpus, what is your preference for local variable on the stack?
Do you

(a) push the esp down, then move esp to ebp and allocate memory for local
vars above the esp?

(b) move esp to ebp first, then push the esp down

(c) real programmers don't need ebp for local vars.  They calculate offsets
from esp on the fly.  :-)

It seems (a) would be easier for humans, since all offsets, including
procedure parameters, would be positive.

However, compilers seem to generate type (b), so parameters are positive
offsets from ebp, and local vars are negative.

jcm
-- 
o-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-o
| ~~~~~~~~~~~~  Jonathon McKitrick  ~~~~~~~~~~~~~ |
| "I prefer the term 'Artificial Person' myself." |
o-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-o


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010723183331.A55127>