Mercurial > hg > Members > kono > os9 > sbc09
changeset 104:096b3fc7aa66
fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 28 Dec 2018 17:43:55 +0900 |
parents | 844305752064 |
children | 6eef99bb4771 |
files | os9/mc09/crtos9.asm os9/mc09/makefile os9/mc09/mc.c os9/mc09/mc2.c os9/mc09/mclibos9.c |
diffstat | 5 files changed, 37 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/os9/mc09/crtos9.asm Thu Dec 27 20:16:34 2018 +0900 +++ b/os9/mc09/crtos9.asm Fri Dec 28 17:43:55 2018 +0900 @@ -27,8 +27,9 @@ _start _00000 LEAS -256,S ALLOCATE WORK AREA + leay _name,pcr + pshs x,y POINT TO CONTENT OF ARGUMENT VECTOR leay ,u - pshs d,x POINT TO CONTENT OF ARGUMENT VECTOR PSHS Y * clear globals on Y LDX #_GLOBALS @@ -234,4 +235,5 @@ * * * + emod _eom
--- a/os9/mc09/makefile Thu Dec 27 20:16:34 2018 +0900 +++ b/os9/mc09/makefile Fri Dec 28 17:43:55 2018 +0900 @@ -36,12 +36,12 @@ mc2.c: patch <diff_to_mc2 -o mc2.c -test-cp : test/cp.c - ./mc test/cp.c - $(AS09) crtos9.asm -l cp.lst -o cp +testcp : mc test/cp.c + ./mc -Mtestcp test/cp.c + $(AS09) crtos9.asm -l c.lst -o testcp clean: - rm -f mc c.out mc2.o lint + rm -f mc c.out mc2.o lint testcp install: mc cp mc $(DESTDIR)/mc
--- a/os9/mc09/mc.c Thu Dec 27 20:16:34 2018 +0900 +++ b/os9/mc09/mc.c Fri Dec 28 17:43:55 2018 +0900 @@ -183,10 +183,11 @@ {NMTBL *nptr; int i; char *ccout; -char *modname = "aout"; +char *modname; if(argc==1) exit(1); lsrc = chk = asmf = 0; ccout = "c.out"; + modname = "aout"; ac=argc; av=argv; for (ac2=1; (ac2 < ac) && (*av[ac2] == '-'); ++ac2) @@ -211,8 +212,8 @@ if (!chk) { if ( (obuf = fopen(ccout,"w")) == NULL ) error(FILERR); else { - printf("\tmod _eom,_name,_tylg,_atrv,_main,_GLOBALS\n"); /* os9 module header */ - printf("_name fcs /%s/\n",modname); + printf("\tmod _eom,_name,_tylg,_atrv,_start,_GLOBALS\n"); /* os9 module header */ + printf("_name fcs /%s/\n\tfcb 0\n",modname); } } init();
--- a/os9/mc09/mc2.c Thu Dec 27 20:16:34 2018 +0900 +++ b/os9/mc09/mc2.c Fri Dec 28 17:43:55 2018 +0900 @@ -205,8 +205,8 @@ if (!chk) { if ( (obuf = fopen(ccout,"w")) == NULL ) error(FILERR); else { - printf("\tmod _eom,_name,_tylg,_atrv,_main,_GLOBALS\n"); /* os9 module header */ - printf("_name fcs /%s/\n",modname); + printf("\tmod _eom,_name,_tylg,_atrv,_start,_GLOBALS\n"); /* os9 module header */ + printf("_name fcs /%s/\n\tfcb 0\n",modname); } } init();
--- a/os9/mc09/mclibos9.c Thu Dec 27 20:16:34 2018 +0900 +++ b/os9/mc09/mclibos9.c Fri Dec 28 17:43:55 2018 +0900 @@ -31,10 +31,11 @@ #define STDOUT (&_s0[1]) #define STDERR (&_s0[2]) -_main(args) +_main(args,prog) char *args; +char *prog; {int i; - char **argv,*p; + char **argv,*p,*q; int argc,n,quote,c; stdin = STDIN; stdin->fd = 0; stdout = STDOUT; stdout->fd = 1; @@ -44,34 +45,40 @@ /* create argv here */ argc = 0; argv = 0; - n = 0; - quote = 0; for( i = 0; i < 2 ; i++ ) { - if (i==1 && argc) { argv = (char**)malloc(sizeof(char*)*argc); } - p = args; - while((c = *p++)) { - if (i==1) argv[n] = args; + if (i==1) { + argv = (char**)malloc(sizeof(char*)*(argc+1)); + argv[0] = prog; + } + n = 1; + quote = 0; + q = p = args; + if (i==1) argv[n] = args; + while((c = *p++) && c!='\r') { if (c=='\'') { if (!quote) { - if (i==1) argv[n]++; + q--; quote = 1; - continue; } else { - if (i==1) p[-1]=0; + if (i==1) *q=0; quote = 0; } } else if (c=='\\') { p++; - continue; } else if (c==' ') { - if (quote) - continue; - if (i==1) p[-1]=0; + if (!quote) { + if (i==1) { + *q = 0; argv[n++] = q+1; + } + } } - n++; + if (i==1) *q = *p; + q++; p++; } - p[-1]=0; + if (i==1) *q = 0; + argc = n; } + argv[n]=0; main(argc,argv); }