Mercurial > hg > CbC > CbC_gcc
view CbC-examples/fact-rectype.c @ 90:99e7b6776dd1
implemeted __rectype expression. add CbC-exanples/fact-rectype.s
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 25 Dec 2011 04:04:42 +0900 |
parents | |
children |
line wrap: on
line source
#include <stdio.h> #define __environment _CbC_environment #define __return _CbC_return __code factorial(int n, int result, __rectype *print, __rectype *exit1, void *envp) { if(n<0) { print("#0008:err %dn",n); goto (*exit1)(0, envp); } if (n==0) goto (*print)(n,result,print,exit1, envp); else { result *= n; n--; goto factorial(n, result, print,exit1, envp); } } __code print(int n, int result, __rectype *print ,__rectype *exit1 ,void *envp); int main(int argc, char *argv[]) { int n; n = 10; goto factorial(n,1,print,__return,__environment); } __code print(int n, int result, __rectype *print ,__rectype *exit1,void *envp){ printf("#0032:%d = %d\n", n, result); goto (*exit1)(0,envp); }