main(argc,argv)
19-Jun-93 06:48:35
Sb: #35426-main(argc,argv)
Fm: Steve Goddard 100014,674
To: Bart Mathias 72017,1005
Major Question 1:
AS you have found out, the docs are biased towards C programmers. I don't
use Astart.obj myself, but being a C programmer, can explain what the main()
stuff means.
AStart.obj fronts your program, and does some magic that sets up the overall
environment (stack, etc), then formats the command line arguments, and calls
your code. I think it does a jsr _main?
When your code runs, it will have access to 2 variables, which will both be
on the stack (although you may coincidentally find them in registers also). On
the top of the stack will be a long integer, containing the number of CLI
parameters typed. Typing the name of the program counts as 1, additional params
are 2,3,.. etc. A program launched from WB will have 0 in here. The next long
is an address. It is the addr of the following structure:
addr –> Address1
Address2
Address3
0
The number of addresses pointed to varies, and there can be none (so addr
would point to the 0) So dereferencing the Addr will give another address
(Address1). Adding 4 and dereferencing will give Address2, etc until you find
all zeroes. Each of these addresses points to a string of characters
(terminated with a 0 byte). Each string is a single command line parameter, and
the number of them is the same as the first param on the stack.
Steve the G. [BEDFORDSHIRE, UK]