dthain/basekernel

Fix Order of argc,argv

dthain opened this issue · 5 comments

Somehow, we got in the habit of putting argc and argv in the opposite order of the Unix convention.
Let's make it main(int argc, char *argv[]) for consistency.
This requires fixing the following things:
1 - The order of arguments in user programs.
2 - The order of arguments in library/user-start.c
3 - The order items are pushed on the stack in process_pass_arguments

@jmazanec15 this would be an easy one to pick off.

I will work on this.

So, in process_pass_arguments do we need to push argc onto the stack before we push the addresses of each element in argv?

To clarify, it's just the final two items: addr_of_addr_of_argv (char **argv) should be pushed before argc.

So, the final stack layout should be, from top to bottom:

argument 2 (a string)
argument 1 (a string)
argument 0 (a string)
argument array (an array of pointers to each argument)
argv (a pointer to the array of pointers)
argc (an integer)

Note that argv and argc are the formal parameters to main, but argv contains pointers to the contents of the arguments, which are on the stack above argv itself.

Oh ok that makes sense and fixes my problems.