• R/O
  • SSH

CbC: Zusammenfassung des Repository

micro-C base Continuation based C


Neueste Commits RSS

Rev. Zeit Autor Nachricht
a30e27ca0c68 2019-05-08 18:36:37 Shinji KONO tip Added tag current for changeset 7ad36407670e
7ad36407670e 2019-05-08 18:36:28 Shinji KONO current micro C based CbC
07fdf66a7547 2012-11-17 13:54:46 Shinji KONO merge
2a5be2433ef2 2012-11-17 13:53:35 Shinji KONO i64 modification
ad4c31417536 2011-09-24 02:11:52 Shinji KONO i64 parallel assignment
d3e503684b5d 2011-09-21 16:17:09 Shinji KONO minor modification
9fe274d29806 2009-12-18 07:59:49 convert-repo update tags
8fa191004ced 2007-11-08 19:49:58 shinji_kono parse-mode *** empty log message ***
3fb0511cb4f3 2006-11-21 10:48:13 shinji_kono alignment-attribute **FUNKY** *** empty log message ***
4aa276299cbe 2006-11-01 20:01:01 shinji_kono *** empty log message ***

Kürzlich bearbeitete Tags

Name Rev. Zeit Autor
release1 3d88fe068047 2006-02-07 16:04:38 shinji_kono
converter add863b666c5 2006-03-16 19:02:42 shinji_kono
gcc-find-include-path ce2364964f1e 2006-09-27 16:28:22 shinji_kono
intel-mac 8106ea9cf185 2006-10-11 18:45:41 shinji_kono
alignment-attribute **FUNKY** 3fb0511cb4f3 2006-11-21 10:48:13 shinji_kono
parse-mode 8fa191004ced 2007-11-08 19:49:58 shinji_kono
current 7ad36407670e 2019-05-08 18:36:28 Shinji KONO
tip a30e27ca0c68 2019-05-08 18:36:37 Shinji KONO

Zweige

Name Rev. Zeit Autor Nachricht
default a30e27ca0c68 2019-05-08 18:36:37 Shinji KONO Added tag current for chang...
kono 3d88fe068047 2006-02-07 16:04:38 shinji_kono Continuation based C

README

C with Continuation (CwC) and Continuation based C (CbC)

             Shinji Kono
             University of the Ryukyus

0. What is this.

We have gcc and LLVM version. You should use these.

This is a extension of C ( and a subset of C ). It has a 
programming unit which is called code segment.  Code
segment can be communicate with so called light weight continuation.


    #include <stdio.h>

    code factorial(int n,int result,int orig,
         code(*print)(),code(*exit1)(), void *exit1env)
    {
	if (n<0) {
	    printf("err %d!\n",n);
	    goto (*exit1)(0),exit1env;
	}
	if (n==0)
	    goto (*print)(n,result,orig,print,exit1,exit1env);
	else {
	    result *= n;
	    n--;
	    goto factorial(n,result,orig,print,exit1,exit1env);
	}
    }

    int main( int ac, char *av[])
    {
	int n;
	n = 10;
	goto factorial(n,1,n,print,return,environment);
    }

    code print(int n,int result,int orig,code(*print)(),(*exit1)(),void*exit1env)
    {
	printf("%d! = %d\n",orig, result);
	goto (*exit1)(0),exit1env;
    }

If you don't use function call, this language becomes subset of C.
It is called Continuation based C. Actually it can be a lower layer of
C language.  Normal C program can be compiled into CbC.

CbC is a kind of architecture independent assembler language.

1. Syntax

      code  code_segment_name(interfaces) {
         body;
      }

code is a type for code segment. A code segment has no return
statements. 

Interfaces are arguments. It can be struts. or unions. Some
part of interfaces are mapped into registers. No
references are allowed in register interface variables.

Goto statements transfer the control from a segment
to a segment.
      goto segment_name(interfaces);
If two code segments has a same interfaces, transfer cost is very
small. It us usually a single jump instruction.
If there are differences, some parallel assignment is performed.

2. Interaction between function and code segment.

In CwC, you can call C function at any time in code segments.
If you want to call code segment from C and want to do some
return, explicit handling of function environment.

	goto factorial(n,1,n,print,return,environment);

return and environment is a special variable which contains
return point. An environment variable is something like jumpbuf
in setjump, but it is a simple pointer. Unlike jumpbuf,
there is no way to allocate are for environment.
       void *environment;

A return variable is a continuation with environment of
original function. It's type is varied for called function.

       code (*return)(int return_value);

To go to the continuation, use goto with environment.

       goto (*exit1)(0),exit1env;

3. How to use

mc-powerpc, mc-ia32 is a compiler. It generates assembler
source code .s from C source code. 

     mc-powerpc source.c
     gcc source.s
generates a.out.
     mc-powerpc source.c
     gcc -c sources.s
generates sources.o

     -s comments in assembler source.
     -c check only.
     -v report memory usage
     -oname  output file names
     -Dname  define name
     -Dname=value  define name as value
     '-Dname(a)=a+1'  define macro function with args
     -Idir/   add library include directory. / is necessary.

Some examples can be fond in test directory.

3. Unimplemented lists

Mips version is not ready.

64bit long long is now supported
//    long long, long double, unsigned long long can be used as type,
//    but no operation (including assignment) are no allowed.
//    Long long value (0LL) can be used but it gives long value. 
//    Long is equal to an int and a pointer (32bit).

Only Mac OS X and Red hat Linux is supported.
Intel Mac is supported.

Inline directive is ignored and gives normal function definition.

Register float is supported in Power PC
//    Register float arguments does no accepts assignment operation such as
//	*=, /=, +=.

//No built-in alloca.

// No varargs.

Use stdarg

// Switch statements is implemented as series of compare and branch,
// no tables.

// Some operations such as concatenation are not implemented in macro
// processor.

Macro processor is a coroutine in this compiler, slightly different
from cpp.

No  -g support.

No runtime driver for CbC.

//  #include does not search, sources current directory.
 #include does search, sources current directory.

bit-field is supported, but no global initialization of bit-field.


/************************************************************************
** Copyright (C) 2006 Shinji Kono
** 連絡先: 琉球大学情報工学科 河野 真治  
** (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
**
**    このソースのいかなる複写,改変,修正も許諾します。ただし、
**    その際には、誰が貢献したを示すこの部分を残すこと。
**    再配布や雑誌の付録などの問い合わせも必要ありません。
**    営利利用も上記に反しない範囲で許可します。
**    バイナリの配布の際にはversion messageを保存することを条件とします。
**    このプログラムについては特に何の保証もしない、悪しからず。
**
**    Everyone is permitted to do anything on this program 
**    including copying, modifying, improving,
**    as long as you don't try to pretend that you wrote it.
**    i.e., the above copyright notice has to appear in all copies.  
**    Binary distribution requires original version messages.
**    You don't have to ask before copying, redistribution or publishing.
**    THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
***********************************************************************/

Show on old repository browser