view CbC-examples/test05.c @ 27:f9b1a53df341

implemented indirect sibcall for ppc.
author kent@teto.cr.ie.u-ryukyu.ac.jp
date Tue, 10 Nov 2009 16:34:29 +0900
parents
children 5d30d517ebed
line wrap: on
line source

//#include<stdio.h>
#define dprint(f, args...) \
    printf("in %s: "f, __FUNCTION__, ## args)

__code caller (int a);
void f01 (int a);
void f02 (int a, float b);
__code cs01 (int a);
__code cs02 (int a, float b);
int main ();


int g=0;
void (*funcp)(int);
__code (*csp)(int);

__code caller(int a) {
    f01(a+2);
    f02(a+3, 13.2);
    funcp(a+4);
    goto csp(a+4);
    dprint("\n");
}

__code end() {
    dprint("\n");
    exit(0);
}

void f01(int a) {
    dprint("%d\n", a);
    g += a;
    return ;
}
void f02(int a, float b) {
    dprint("%d, %f\n", a, b);
    g -= a;
    g += b*0.3;
    return ;
}
__code cs01(int a) {
    dprint("%d\n", a);
    g += a;
    goto end() ;
}
__code cs02(int a, float b) {
    dprint("%d, %f\n", a, b);
    g -= a;
    g += b*0.3;
    goto end() ;
}

int main() {
    funcp = f01;
    csp = cs01;
    caller(10);
}