Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Jul 2001 20:02:51 +0100
From:      j mckitrick <jcm@FreeBSD-uk.eu.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-chat@freebsd.org, Greg Lehey <grog@freebsd.org>
Subject:   Re: stack use preference
Message-ID:  <20010724200251.A72789@dogma.freebsd-uk.eu.org>
In-Reply-To: <XFMail.010724115418.jhb@FreeBSD.org>; from jhb@freebsd.org on Tue, Jul 24, 2001 at 11:54:18AM -0700
References:  <20010724022658.A63186@dogma.freebsd-uk.eu.org> <XFMail.010724115418.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
| Yes.  On x86, doing
| 
|         enter $8, $0    ; 8 bytes of local storage
| 
| is equivalent to:
| 
|         push %ebp
|         mov %esp, %ebp
|         sub $8, %esp
| 
| but most compilers that I've seen unroll 'enter' rather than using it directly.
| *shrug*

From what I have discovered, 'enter' uses more cycles than the corresponding
instructions, and yet 'leave' does not.

| 
| Thus, you could do:
| 
| foo:
|         enter $8, $0
|         mov 12(%ebp), %ebx ; get char * param
|         mov 8(%ebp), %eax ; get int param
|                         ; note that 4(%ebp) is the saved IP, not a param
|         ...
|         leave
|         ret
| 
| > main:
| >       push %eax       ; char *
| >       push %ebx       ; int
| >       call foo
| >       [...]
| 
| -- 
| 
| John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
| PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
| "Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


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?20010724200251.A72789>