changeset 0:e59ebf6fe2b0

Initial revision
author kinjo
date Sat, 26 Nov 2005 11:36:16 +0900
parents
children 285a00a15c1a bf65d90b8dc8
files Changes Makefile arg-c.c arg.c asm-studies.c call.c code-ptr-array.c dbg.c deep-nested-struct.c dumparg-struct.c dumparg.c first.c for.c func-ptr-array.c hello_mod.c move.c my-stdio.h separate.c separate_mod.c separate_sp.c struct-align.c struct-array.c struct-array2.c struct-c.c struct-mips.c struct-ptr-arg.c struct.c struct2.c
diffstat 28 files changed, 1186 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Changes	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,32 @@
+Tue Nov 22 09:37:16 JST 2005
+
+cbcはforをサポートするがあまり使わないかもしれない
+forの代わりに./for.cの記述になるんじゃなかろか
+
+一つ気になるのはcode segmentに入ってint iという
+インタフェースがあること。
+
+code
+for0(int i,code (*ret)(int), void *env)
+
+これはgoto codeのときに初期化するんか
+
+goto for0(0,return,environment);
+
+まぁ気分的にはこのforの中のint iみたいな感じか
+
+for(int i=0; i<10; i++);
+
+Fri Nov 25 10:45:01 JST 2005
+
+ps2 s-dandyのstruct teki(enemyの構造体)に対して、
+値参照や値代入を行うとsegment errorが起こった。
+
+その原因追求のためにstruct-array.cを追加した
+
+Sat Nov 26 10:55:03 JST 2005
+
+jal(mipsのジャンプ命令だろうか)により大域変数のポインタ破壊が原因のよう。
+code segmentではjalの代わりに特別なことをしないといけないよう。
+
+struct-array.cの問題は解決された
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,105 @@
+CC=gcc
+#MCC=./mcc
+MCC=mc-mips
+#MCC=mc-ia32
+TARGET=first hello_mod separate dumparg arg arg-c dumparg-struct struct struct2 arg-dbg deep-nested-struct code-ptr-array func-ptr-array struct-ptr-arg for struct-align struct-array struct-array2 struct-mips
+
+CFLAGS=-g -Wall
+
+#%.o: %.c
+#.SUFFIXES:  .c .o .s #.d
+.SUFFIXES:  .c .o
+
+.c.o:
+	$(MCC) -s $<
+	$(CC) $(CFLAGS) -o $@ -c $(<:.c=.s)
+
+CFLAGS=-g -Wall
+
+all: $(TARGET)
+
+struct-array2:struct-array2.o
+	$(CC) $(CFLAGS) -o $@ $^
+
+struct-array: struct-array.o
+	$(CC) -o $@ $^
+
+struct-align: struct-align.o
+	$(CC) -o $@ $^
+
+for: for.o
+	$(CC) -o $@ $^
+
+first: first.o
+	$(CC) -o $@ $^
+
+hello_mod.o:hello_mod.c
+	$(CC) -o $@ -c $<
+
+hello_mod: call.o hello_mod.o
+	$(CC) -o $@ $^
+
+separate_sp.o: separate_sp.c
+	$(CC) -o $@ -c $<
+
+separate: separate_sp.o separate.o
+	$(CC) -o $@ $^
+
+arg: arg.o
+	$(CC) -o $@ $^
+
+arg-c.o: arg-c.c
+	$(CC) $(CFLAGS) -o $@ -c $<
+
+arg-c: arg-c.o
+	$(CC) -o $@ $^
+
+dumparg: dumparg.o
+	$(CC) -o $@ $^
+
+dumparg-struct: dumparg-struct.o
+	$(CC) -o $@ $^
+
+struct: struct.o
+	$(CC) -o $@ $^
+
+struct2: struct2.o
+	$(CC) -o $@ $^
+
+struct-c.o: struct-c.c
+	$(CC) -o $@ -c $<
+
+struct-c: struct-c.o
+	$(CC) -o $@ $^
+
+asm-studies: asm-studies.o
+	$(CC) -o $@ $^
+
+arg-dbg.o: arg.c
+	$(CC) -DDEBUG -P -E -o $(@:.o=.d) $<
+	$(MCC) -o$(@:.o=.s) $(@:.o=.d)
+	$(CC) $(CFLAGS) -o $@ -c $(@:.o=.s)
+
+dbg.o:dbg.c
+	$(CC) $(CFLAGS) -o $@ -c $<
+
+arg-dbg: arg-dbg.o dbg.o
+	$(CC) -o $@ $^
+deep-nested-struct: deep-nested-struct.o
+	$(CC) -o $@ $^
+struct-ptr-arg: struct-ptr-arg.o
+	$(CC) -o $@ $^
+move:move.o
+	$(CC) -o $@ $^
+
+funcptr-ptr-array: funcptr-ptr-array.o
+	$(CC) -o $@ $^
+
+code-ptr-array:code-ptr-array.o
+	$(CC) -o $@ $^
+
+struct-mips: struct-mips.o
+	$(CC) -o $@ $^
+clean:
+	rm -f $(TARGET)
+	rm -f *.s *.o *.d *.i a.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/arg-c.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,112 @@
+extern int printf(char*,...);
+char* outfile;
+char* infile;
+int help;
+
+#define LONG_OPTION_NUM 2
+int match[LONG_OPTION_NUM];	// matching table
+char* optstr[LONG_OPTION_NUM]={	// option string
+    "help",
+    "file",
+};
+int score[LONG_OPTION_NUM]={4,4}; // length of option string
+
+int
+option(int argc, char** argv)
+{
+    int i, j, k;
+    char *p, *o;
+
+    for(i=1; i<argc; ){
+	p=argv[i];
+	if(*p=='-'){
+	i++;
+	    p++;
+	    if(*p=='-'){
+		p++;
+		for(j=0; j<LONG_OPTION_NUM; j++){
+		    match[j]=0;
+		}
+		for(k=0; *p!=0; p++, k++){
+		    for(j=0; j<LONG_OPTION_NUM; j++){
+			o=optstr[j];
+			if(*p==o[k]){
+			    match[j]++;
+			}
+		    }
+		}
+		for(j=0; j<LONG_OPTION_NUM; j++){
+		    if(match[j]==score[j]){
+			if(j==0){	// help
+			    help=1;
+			    return 0;
+			}else if(j==1){ // file
+			    if(outfile){
+				return 1;
+			    }else{
+				outfile=argv[i++];
+			    }
+			}else{	// unknown
+			    return 1;
+			}
+		    }
+		}
+	    } else {
+		if(*(p+1)=='\0'){
+		    if(*p=='h'){
+			help=1;
+			return 0;
+		    }else if(*p=='f'){
+			if(outfile){
+			    return 1;
+			}else{
+			    outfile=argv[i++];
+			}
+		    }
+		}else{
+		    return 1;
+		}
+	    }
+	}else{
+	    if(infile){
+		return 1;
+	    }else{
+		infile=argv[i];
+		i++;
+	    }
+	}
+    }
+    return 0;
+}
+// prints usage
+void
+usage()
+{
+    printf("Usage:porogram <option> <infile>\n");
+    printf("-h: help\n");
+    printf("-f: outfile\n");
+}
+int
+main(int argc,char** argv)
+{
+    if(option(argc,argv)){
+	printf("Invalid option\n");
+	usage();
+	return 1;
+    }
+    if(help){
+	usage();
+	return 0;
+    }
+    if(infile){
+	printf("infile: %s\n", infile);
+    } else{
+	printf("Invalid usage\n");
+	usage();
+	return 1;
+    }
+    if(outfile){
+	printf("outfile: %s\n", outfile);
+    }
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/arg.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,200 @@
+// option茹f若割
+// long option, 箴--help篏帥
+// long option--紮障
+// strcmp篏帥
+// c fileinclude
+
+extern int printf(char*,...);
+
+char* outfile;
+char* infile;
+int help;
+
+#define LONG_OPTION_NUM 2
+int match[LONG_OPTION_NUM];	// matching table
+char* optstr[LONG_OPTION_NUM]={	// option string
+    "help",
+    "file",
+};
+int score[LONG_OPTION_NUM]={4,4}; // length of option string
+
+#ifdef DEBUG
+extern void breakp(void *,void *);
+#define BREAKP(ret,env) breakp(ret,env)
+#else
+#define BREAKP(ret,env)
+#endif
+
+// evaluates matching table
+code
+opt5(int j, int i, int argc, char** argv, (*exit0)(int), void* env)
+{
+    if(j<LONG_OPTION_NUM){
+	printf("match(%d): %d\n", j, match[j]);
+	if(match[j]==score[j]){
+	    printf("detected opt: ");
+	    if(j==0){		// help
+		help=1;
+		printf("help\n");
+		goto exit0(0), env;
+	    }else if(j==1){	// file
+		printf("file\n");
+		printf("file: %s %s\n", outfile, argv[i]);
+		if(outfile){
+		    goto exit0(1), env;
+		}else{
+		    outfile=argv[i];
+		    i++;
+		    goto opt0(i, argc, argv, exit0, env);
+		}
+	    }else{
+		printf("unknown\n");
+		goto exit0(1), env;
+	    }
+	}
+	j++;
+	goto opt5(j, i, argc, argv, exit0, env);
+    }else{
+	goto exit0(1), env;
+    }
+}
+
+// matching test
+code
+opt4(int k, int j, char* p, int i, int argc, char** argv, (*exit0)(int), void* env)
+{
+    char* o;
+    if(*p!='\0'){
+    o=optstr[j];
+	if(j<LONG_OPTION_NUM){
+	    if(*p==o[k]){
+		match[j]++;
+	    }
+	    j++;
+	}else{
+	    k++;
+	    p++;
+	    j=0;
+	}
+	goto opt4(k, j, p, i, argc, argv, exit0, env);
+    }
+    goto opt5(0, i, argc, argv, exit0, env);
+}
+
+// initialize matching table
+code
+opt3(int j, char* p, int i, int argc, char** argv, (*exit0)(int), void* env)
+{
+    if(j<LONG_OPTION_NUM){
+	match[j]=0;
+	j++;
+	goto opt3(j, p, i, argc, argv, exit0, env);
+    }else{
+	goto opt4(0, 0, p, i, argc, argv, exit0, env);
+    }
+}
+
+// evaluates one hyphen options such like -f or -h.
+code
+opt2(char* p, int i, int argc, char** argv, (*exit0)(int), void* env)
+{
+    if(*p=='-'){
+	p++;
+	goto opt3(0, p, i, argc, argv, exit0, env);
+    } else if(*(p+1)=='\0'){
+	if(*p=='h'){
+	    help=1;
+	    goto exit0(0), env;
+	}else if(*p=='f'){
+	    if(argv[i]){
+		if(outfile){
+		    goto exit0(1), env;
+		}else{
+		    outfile=argv[i];
+		    i++;
+		    goto opt0(i, argc, argv, exit0, env);
+		}
+	    }else{
+		goto exit0(1), env;
+	    }
+	}
+    }
+    goto exit0(1), env;
+}
+
+// sets 'infile'
+code
+opt1(char* p, int i, int argc, char** argv, (*exit0)(int), void* env)
+{
+    if(infile){
+	printf("infile exists: infile=%s %s\n", infile, p);
+	goto exit0(1), env;
+    }else{
+	infile=p;
+	goto opt0(i, argc, argv, exit0, env);
+    }
+}
+
+code
+opt0(int i, int argc, char** argv, (*exit0)(int), void* env)
+{
+    char* p;
+    BREAKP(exit0,env);
+    if(i<argc){
+	p=argv[i];
+	i++;
+	if(*p=='-'){
+	    p++;
+	    goto opt2(p, i, argc, argv, exit0, env);
+	}else{
+	    goto opt1(p, i, argc, argv, exit0, env);
+	}
+	goto opt0(i, argc, argv, exit0, env);
+    }else{
+	goto exit0(0), env;
+    }
+}
+
+int
+option(int argc, char** argv)
+{
+    BREAKP(return, environment);
+    goto opt0(1, argc, argv, return, environment);
+    return 0;
+}
+
+// prints usage
+void
+usage()
+{
+    printf("Usage:porogram <option> <infile>\n");
+    printf("-h: help\n");
+    printf("-f: outfile\n");
+}
+
+#ifndef DEBUG
+int
+main(int argc,char** argv)
+{
+    if(option(argc,argv)){
+	printf("Invalid option\n");
+	usage();
+	return 1;
+    }
+    if(help){
+	usage();
+	return 0;
+    }
+    if(infile){
+	printf("infile: %s\n", infile);
+    } else{
+	printf("Invalid usage\n");
+	usage();
+	return 1;
+    }
+    if(outfile){
+	printf("outfile: %s\n", outfile);
+    }
+    return 0;
+}
+#endif // DEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/asm-studies.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,9 @@
+extern int printf(char*,...);
+int
+main()
+{
+    int i;
+    i=16;
+    printf("%d", i);
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/call.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,8 @@
+extern int hello(void);
+
+int
+main()
+{
+    hello();
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/code-ptr-array.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,30 @@
+extern int printf(char*,...);
+code
+aho0(int *i, code(*ret)(), void *env)
+{
+    printf("aho%d\n", *i);
+    (*i)++;
+    goto ret(),env;
+}
+void
+aho()
+{
+    static int i=0;
+    goto aho0(&i,return,environment);
+}
+code(*lis[5])()={
+    aho0,
+    aho0,
+    aho0,
+    aho0,
+    (void*)0,
+};
+int
+main()
+{
+    int i;
+    for(i=0;i<5;i++){
+	aho();
+    }
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbg.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,38 @@
+extern int option(int,char**);
+extern void usage();
+extern int printf(char*,...);
+
+extern int help;
+extern char* outfile;
+extern char* infile;
+
+void
+breakp(void *ret, void *env)
+{
+    return;
+}
+
+int
+main(int argc,char **argv)
+{
+    if(option(argc,argv)){
+	printf("Invalid option\n");
+	usage();
+	return 1;
+    }
+    if(help){
+	usage();
+	return 0;
+    }
+    if(infile){
+	printf("infile: %s\n", infile);
+    } else{
+	printf("Invalid usage\n");
+	usage();
+	return 1;
+    }
+    if(outfile){
+	printf("outfile: %s\n", outfile);
+    }
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deep-nested-struct.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,72 @@
+// to test a deep-nested struct
+// this example tests a 2 nested struct
+#define NULL ((void*)0)
+struct nest1{
+    int i;
+    int j;
+    char k;
+};
+struct nest0{
+    int huga;
+    long hoge;
+    float aho;
+    struct nest1 n1;
+};
+struct nest{
+    char *str;
+    char *p;
+    void *env;
+    code (*ret)(int);
+    struct nest0 n0;
+};
+code
+dmpn2(code(*ret)(int), void *env)
+{
+    goto ret(0), env;
+}
+code
+dmpn1(struct nest1 *test1, code(*ret)(int), void *env)
+{
+    printf("dmpn1: %d %d %d\n",
+	   test1->i,
+	   test1->j,
+	   test1->k);
+    goto dmpn2(ret,env);
+}
+code
+dmpn0(struct nest0 *test0, code(*ret)(), void *env)
+{
+    printf("dmpn0: %d %ld %f\n",
+	   test0->huga,
+	   test0->hoge,
+	   test0->aho);
+    goto dmpn1(&(test0->n1), ret, env);
+}
+code
+dmpn(struct nest *test)
+{
+    printf("dmpn: %x %x\n", test->str, test->p);
+    goto dmpn0(&(test->n0), test->ret, test->env);
+}
+void
+dmp(struct nest *n)
+{
+    n->ret=return;
+    n->env=environment;
+    goto dmpn(n);
+}
+int
+main()
+{
+    struct nest test;
+    test.str=NULL;
+    test.p=NULL;
+    test.n0.huga=1;
+    test.n0.hoge=2;
+    test.n0.aho=3.0;
+    test.n0.n1.i=10;
+    test.n0.n1.j=20;
+    test.n0.n1.k=30;
+//    dmp(&test);
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dumparg-struct.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,59 @@
+extern int printf(char*,...);
+struct opt {
+    char* p;
+    int i;
+    int argc;
+    char** argv;
+} option;
+
+#if 0
+code
+opt1(struct opt o, code (*exit0)(int), void* env)
+{
+    printf("opt1: %x\n", (unsigned long)o.p);
+    if(*(o.p)=='\0'){
+	printf("\n");
+	goto opt0(o, exit0, env);
+    } else{
+	printf("%c", *(o.p));
+	o.p++;
+	goto opt1(o, exit0, env);
+    }
+}
+#endif
+
+code
+opt0(struct opt o, code (*exit0)(int), void* env)
+{
+    printf("opt0\n");
+    
+    if(o.i<o.argc){
+//	o.p=o.argv[o.i];
+//	printf("%s %d\n", *(o.argv), o.i);
+	printf("%x\n", (unsigned long)(o.argv[o.i]));
+	o.i++;
+	goto opt0(o,exit0,env);
+//	goto opt1(o, exit0, env);
+    }
+    goto exit0(0), env;
+}
+int
+main()
+{
+    int i;
+    char* arg[3]={
+	"program",
+	"--file",
+	"ahoaho",
+    };
+    option.i=0;
+    option.argc=3;
+    option.argv=arg;
+#if 1
+    for(i=0; i<3; i++){
+	printf("%x\n", (unsigned long)option.argv[i]);
+    }
+#endif
+    goto opt0(option, return, environment);
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dumparg.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,31 @@
+extern int printf(char*,...);
+code
+opt1(char* p, int i, int argc, char** argv, (*exit0)(int), void* env)
+{
+    if(*p=='\0'){
+	printf("\n");
+	goto opt0(i, argc, argv, exit0, env);
+    } else{
+	printf("%c", *p);
+	p++;
+	goto opt1(p, i, argc, argv, exit0, env);
+    }
+}
+code
+opt0(int i, int argc, char** argv, (*exit0)(int), void* env)
+{
+    char* p;
+    if(i<argc){
+	p=argv[i];
+	i++;
+	goto opt1(p, i, argc, argv, exit0, env);
+    }
+    goto exit0(0), env;
+}
+int
+main()
+{
+    char* arg[3]={"program","--file","ahoaho"};
+    goto opt0(1, 3, arg, return, environment);
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/first.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,29 @@
+//#include <stdio.h>
+
+code
+code2(code (*exit0)(int), void *env)
+{
+    printf("aho\n");
+    goto exit0(0), env;
+}
+
+code
+code1(code *(exit0)(int), void *env)
+{
+    printf("hello\n");
+    goto code2(exit0, env);
+}
+
+void
+aho()
+{
+    goto code1(return,environment);    
+}
+
+int
+main()
+{
+    aho();
+    printf("finish\n");
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/for.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,19 @@
+#include"my-stdio.h"
+#define FOR_MAX 10
+
+code
+for0(int i,code (*ret)(int), void *env)
+{
+    if(i<FOR_MAX){
+	i++;
+	printf("hello\n");
+	goto for0(i,ret,env);
+    }
+    goto ret(0),env;
+}
+
+int
+main()
+{
+    goto for0(0,return,environment);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/func-ptr-array.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,27 @@
+#include<stdio.h>
+int
+aho()
+{
+    static int count=0;
+    printf("aho%d\n", count++);
+    return(0);
+}
+int (*lis[])()={
+    aho,
+    aho,
+    aho,
+    aho,
+    aho,
+    aho,
+    aho,
+    (void*)0,
+};
+int
+main()
+{
+    int i;
+    for(i=0;lis[i]!=(void*)0;i++){
+	lis[i]();
+    }
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hello_mod.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,7 @@
+#include<stdio.h>
+
+int
+hello()
+{
+    printf("hello\n");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/move.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,68 @@
+extern printf(char*,...);
+struct enemy {
+    code(*ret)(int);
+    void *env;
+};
+code
+my_exit(struct enemy *interface)
+{
+    goto interface->ret(0),interface->env;
+}
+code
+enemygo1(struct enemy *interface)
+{
+    printf("enemygo1\n");
+    goto my_exit(interface);
+}
+code
+enemygo2(struct enemy *interface)
+{
+    printf("enemygo1\n");
+    goto my_exit(interface);
+}
+code
+enemygo3(struct enemy *interface)
+{
+    printf("enemygo1\n");
+    goto my_exit(interface);
+}
+code
+enemygo4(struct enemy *interface)
+{
+    printf("enemygo1\n");
+    goto my_exit(interface);
+}
+#if 0
+code (*go)(struct enemy *) list[4]={
+    enemygo1,
+    enemygo2,
+    enemygo3,
+    enemygo4
+};
+#endif
+
+//code (*)(struct endif *) *lis=enemygo1;
+code (*lis)(struct enemy *)[]={enemygo1};
+
+code
+enemygo(int behav,struct enemy *interface)
+{
+    if(behav==1){
+	goto enemygo1(interface);
+    }else if(behav==2){
+	goto enemygo1(interface);
+    }else if(behav==3){
+	goto enemygo1(interface);
+    }else if(behav==4){
+	goto enemygo1(interface);
+    }
+    goto my_exit(interface);
+}
+int
+main()
+{
+    struct enemy interface;
+    interface.ret=return;
+    interface.env=environment;
+    goto enemygo(1,&interface);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/my-stdio.h	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,1 @@
+extern int printf(char *,...);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/separate.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,31 @@
+/*
+  NULLstdlibу臂. stdlibc吾с
+  cbc茯粋昭紊潟潟ゃ若
+ */
+#define NULL ((void*)0)
+
+code
+s0(char** w, char *p, int i, (*exit0)(char**, char*), void* env)
+{
+    if (*p=='\0') {
+	w[i] = NULL;
+	goto exit0(w, p), env;
+	
+    } else if (*p==' ') {
+	*p='\0';
+	w[i++] = ++p;
+	goto s0(w, p, i, exit0, env);
+    } else {
+	p++;
+    }
+    goto s0(w, p, i, exit0, env);
+}
+
+void
+separate(char** w, char *buf)
+{
+    /*
+      翫return, environment劫ャ紊
+     */
+    goto s0(w, buf, 0, return, environment);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/separate_mod.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,4 @@
+void
+separate(char* w, char* buf)
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/separate_sp.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,36 @@
+/*
+  Separates a line by a space. separate() is defined in separate.c.
+
+  ccbcmodule linkゃ茯帥鴻. separate_sp.ccф吾
+  separate.ccbc篏帥separate()絎臂
+ */
+
+#include<stdio.h>
+#include<string.h>
+
+#define MAX_WORD 100
+#define BUF_SIZ 256
+
+static char *w[MAX_WORD];
+
+extern void separate(char** w, char *buf);
+
+int
+main()
+{
+    int i;
+    const char *str = "hoge huga aho aho2";
+
+    char buf[BUF_SIZ];
+    char *p=buf;
+
+    strncpy(buf, str, BUF_SIZ);
+
+    separate(w, buf);
+
+    for(i=0; w[i]!=NULL; i++) {
+	printf("%s\n", w[i]);
+    }
+    return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/struct-align.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,31 @@
+/* to test the struct alignment */
+#include"my-stdio.h"
+
+struct test{
+    int a;
+    int b;
+    int c;
+    float d;
+} foo;
+
+code
+print_foo(code(*ret)(int),void *env)
+{
+    printf("a=%d b=%d c=%d d=%f\n",foo.a,foo.b,foo.c,foo.d);
+    goto ret(0),env;
+}
+code
+init_foo(code(*ret)(int),void *env)
+{
+    foo.a=1;
+    foo.b=2;
+    foo.c=3;
+    foo.d=4;
+    goto print_foo(ret,env);
+}
+int
+main()
+{
+    goto init_foo(return,environment);
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/struct-array.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,59 @@
+#include"my-stdio.h"
+
+#define OBJECT_MAXNUM 10
+
+#define _BUG
+
+#ifdef _BUG
+struct {
+    float j;			// bug
+    int i;
+    int k;
+    int h;
+} a[OBJECT_MAXNUM];
+
+#else
+
+struct {
+    int i;
+    int j;
+    int k;
+    int h;
+} a[OBJECT_MAXNUM];
+#endif // _BUG
+
+code
+print_a(int i,code(*ret)(int),void *env)
+{
+    if(i<OBJECT_MAXNUM){
+#ifdef _BUG
+	printf("a[%d]: i=%d j=%f k=%d h=%d\n", i, a[i].i,a[i].j,a[i].k,a[i].h);
+#else
+	printf("a[%d]: i=%d j=%d k=%d h=%d\n", i, a[i].i,a[i].j,a[i].k,a[i].h);
+#endif
+	i++;
+	goto print_a(i,ret,env);
+    }
+    goto ret(0),env;
+}
+
+code
+init_a(int i,code(*ret)(int),void *env)
+{
+    if(i<OBJECT_MAXNUM){
+	a[i].i=1;
+	a[i].j=2;
+	a[i].k=3;
+	a[i].h=4;
+	i++;
+	goto init_a(i,ret,env);
+    }
+    goto print_a(0,ret,env);
+}
+
+int
+main()
+{
+    goto init_a(0,return,environment);
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/struct-array2.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,49 @@
+#include"my-stdio.h"
+
+#define OBJECT_MAXNUM 10
+
+struct test {
+    int i;
+    float j;
+    int k;
+    int h;
+} a[OBJECT_MAXNUM];
+
+code
+print_a(struct test *b,int q,code(*ret)(int),void *env)
+{
+    if(q<OBJECT_MAXNUM){
+	printf("a[%d]: i=%f j=%d k=%d h=%d\n",
+	       q, b[q].i,b[q].j,b[q].k,b[q].h);
+	q++;
+	goto print_a(b,q,ret,env);
+    }
+    goto ret(0),env;
+}
+
+code
+init_a(struct test *b,int q,code(*ret)(int),void *env)
+{
+    if(q<OBJECT_MAXNUM){
+	b[q].i=1;
+	b[q].j=2;
+	b[q].k=3;
+	b[q].h=4;
+	q++;
+	goto init_a(b,q,ret,env);
+    }
+    goto print_a(b,0,ret,env);
+}
+
+int
+aho()
+{
+    goto init_a(a,0,return,environment);
+}
+
+int
+main()
+{
+    aho();
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/struct-c.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,17 @@
+extern int printf(char*,...);
+struct obj {
+    int i;
+    char **arg;
+};
+int
+main()
+{
+    struct obj o;
+    char *str[3]={"aho", "huga", "hoge"};
+    o.i=0;
+    o.arg=str;
+    for(o.i=0; o.i<3; o.i++){
+	printf("%x\n", (unsigned long)o.arg[o.i]);
+    }
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/struct-mips.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,30 @@
+struct huga0 {
+    char c;
+    short s;
+    int i;
+    long l;
+    float f;
+};
+struct huga {
+    char c;
+    short s;
+    int i;
+    long l;
+    float f;
+    struct huga0 hh;
+};
+int main()
+{
+    struct huga h;
+    h.c = 10;
+    h.s = 20;
+    h.i = 30;
+    h.l = 40;
+    h.f = 50;
+    h.hh.c = 10;
+    h.hh.s = 20;
+    h.hh.i = 30;
+    h.hh.l = 40;
+    h.hh.f = 50;
+    return (0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/struct-ptr-arg.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,27 @@
+extern int printf(char*,...);
+struct interface {
+    int i;
+    int num;
+    char **arg;
+    code (*ret)();
+    void *env;
+};
+void
+huga(struct interface *intf)
+{
+    printf("%x\n", (unsigned long)intf);
+}
+int
+main()
+{
+    struct interface a;
+    struct interface *b=&a;
+    printf("%x\n", (unsigned long)b);
+    b->i=1;
+    b->num=2;
+    b->arg=(void*)3;
+    b->ret=return;
+    b->env=environment;
+    huga(b);
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/struct.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,34 @@
+// to test the code segment interface unsing struct pointer
+extern int printf(char*,...);
+struct interface {
+    int num; char **arg; code (*ret)(); void *env;
+};
+code
+aho1(struct interface *intf)
+{
+    goto intf->ret(),intf->env;
+}
+code
+aho0(struct interface *intf, int i)
+{
+    if(i < intf->num){
+	printf("%s (%x)\n",intf->arg[i],(unsigned long)intf->arg[i]);
+	i++;
+	goto aho0(intf, i);
+    }
+    goto aho1(intf);
+}
+void
+aho(struct interface *intf)
+{
+    goto aho0(intf, 0);
+}
+int
+main()
+{
+    struct interface intf;
+    char *str[3]={"aho", "huga", "hoge"};
+    intf.num=3; intf.arg=str; intf.ret=return; intf.env=environment;
+    aho(intf);
+//    goto aho0(intf,0);		// will cause a serious error
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/struct2.c	Sat Nov 26 11:36:16 2005 +0900
@@ -0,0 +1,21 @@
+extern int printf(char*,...);
+struct enemy{
+    float x;			// x location
+    float y;			// y location
+    int charno;			// image number
+    int ap;			// armor point
+};
+void
+print_param(struct enemy *e)
+{
+    printf("charno:%d   x,y:%f,%f   hp:%d\n",
+	   e->charno,e->x,e->y,e->ap);
+}
+int
+main()
+{
+    struct enemy e;
+    e.charno=5; e.x=50.0; e.y=30.0; e.ap=100;
+    print_param(&e);
+    return(0);
+}