X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=uebersetzerbau-ss10.git;a=blobdiff_plain;f=gesamt%2Fcode.bfe;h=9e85ee17abafb47722511d155aef96b151dd9301;hp=8e3dfde8eb1444485cf2824b265d089798c4236f;hb=2c41106ae4fd8e8b01f3e9c4ffe58f11263b318f;hpb=7b22a2a8269d60132324fdfa02e16cac946f5d4b diff --git a/gesamt/code.bfe b/gesamt/code.bfe index 8e3dfde..9e85ee1 100644 --- a/gesamt/code.bfe +++ b/gesamt/code.bfe @@ -164,7 +164,9 @@ void gen_subspecial(struct treenode *bnode, short e) KIDKIDREG2PARM(1,0); if(e) { - printf("\tsubq $%d, %%%s\n", KIDKID_VAL(1,0), BN_REG); + if(KIDKID_VAL(1,0) != 0) { + printf("\tsubq $%d, %%%s\n", KIDKID_VAL(1,0), BN_REG); + } } else { printf("\tsubq %%%s, %%%s\n", KIDKID_REG(1,0), BN_REG); } @@ -189,7 +191,21 @@ void make_call(struct treenode *bnode) for(j = bnode->paramges; j < bnode->paramges + bnode->vars; j++) { printf("\tpushq %%%s\n", param_reg(j)); } + /* TODO: schoener machen... */ + if(strcmp(BN_REG, "rax")!=0) { + printf("\tpushq %%rax\n"); + if(strcmp(BN_REG, "r10")!=0) { + printf("\tpushq %%r10\n"); + } + } printf("\tcall %s\n", bnode->name); + if(strcmp(BN_REG, "rax")!=0) { + move("rax", BN_REG); + if(strcmp(BN_REG, "r10")!=0) { + printf("\tpopq %%r10\n"); + } + printf("\tpopq %%rax\n"); + } /* vars poppen */ for(j = bnode->paramges + bnode->vars - 1; j >= bnode->paramges; j--) {