[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pgubook-readers] toupper and command line args
From: |
Aaron Miller |
Subject: |
[Pgubook-readers] toupper and command line args |
Date: |
Sun, 22 Feb 2004 18:26:26 -0800 |
User-agent: |
KMail/1.5.4 |
I'm really getting a lot out of this book.
I'm having some difficulty reconciling the explanation of how Linux passes in
command line params at the bottom of page 91 with the way the toupper example
actually works.
At the bottom of page 91, he explains that when a program begins, the number
of args is at 8(%esp), the name of the program at 12(%esp), and that the
arguments start at 16(%esp).
Well, when a program begins, aren't the stack pointer and the base pointer the
same? If this is the case, then why in toupper does he retrieve the first
argument from 8(%ebp)?
Running it through gdb, if I break it right after the first instruction in
_start, argc is at %esp (same as %ebp at this point), argv[0] is at 4(%esp),
arg[1] at 8(%esp) and so on...
But I keep thinking I'm missing something, because page 91 makes it clear that
the first arg should be at 16(%esp), not 8(%esp).
I'm probably being dense here, but could someone clarify this for me?
Thanks,
Aaron
- [Pgubook-readers] toupper and command line args,
Aaron Miller <=