-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrt0.c
More file actions
67 lines (58 loc) · 1.87 KB
/
crt0.c
File metadata and controls
67 lines (58 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/********************************************************************
Copyright 2010-2017 K.C. Wang, <kwang@eecs.wsu.edu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
********************************************************************/
/* crt0.c : main0(s) called from u.s, where s = oigianl command string
tokenlize s into char *argv[ ] and call main(argc, argv).
token() breaks up a string into argc of tokens, pointed by argv[]
*/
/* #include "uinclude.h" */
int argc;
char *argv[32];
void token(char *line)
{
char *cp;
cp = line;
argc = 0;
while (*cp != 0){
while (*cp == ' ') *cp++ = 0;
if (*cp != 0)
argv[argc++] = cp;
while (*cp != ' ' && *cp != 0) cp++;
if (*cp != 0)
*cp = 0;
else
break;
cp++;
}
argv[argc] = 0;
}
void showarg(int argc, char *argv[ ])
{
int i;
printf("argc=%d ", argc);
for (i=0; i<argc; i++)
//printf("argv[%d]=%s ", i, argv[i]);
printf("%s ", argv[i]);
prints("\n");
}
// BEFORE: r0 was trashed in goUmode(), so had to rely on r1->string
// NOW: r0 is NOT trashed in goUmode() ==> should be r0 alone
void main0(char *s)
{
if (s){
//printf("s=%s\n", s);
token(s);
}
//showarg(argc, argv);
main(argc, argv);
}