David, can you look at this?
#include <fcntl.h>
int foo() {
open("file", O_RDONLY);
return 0;
}
int main() {
int x;
x = foo();
return 0;
}
results in:
foo:
pushl %ebp
movl %esp,%ebp
subl $8,%esp
addl $-8,%esp
pushl $0
pushl $.LC0
call open
xorl %eax,%eax
leave
ret
why the subl then addl?
~ % gcc -v
Using builtin specs.
gcc version 2.95.2 19991024 (release)
~ % uname -a
4.2-STABLE FreeBSD 4.2-STABLE #1: Wed Dec 6 02:49:24 PST 2000
* Drew Eckhardt <[EMAIL PROTECTED]> [001213 14:21] wrote:
> In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] write
> s:
> >> subl $8,%esp
> >> addl $-8,%esp
>
> >> What is the purpose of the subl and addl
> >> instructions? On Linux, they are simply
> >> unexistent..
> >
> >FreeBSD passes syscall args on the stack, Linux uses registers.
>
> The 'C' compiler doesn't know open is a syscall, and treats it like
> any other code.
>
> The pushls put the arguments on the stack.
>
> The subl/addl are there because your version of GCC is broken.
--
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message