From: Bernhard Urban Date: Sun, 16 May 2010 15:45:32 +0000 (+0200) Subject: codea: formatstring X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=uebersetzerbau-ss10.git;a=commitdiff_plain;h=15c44eb1542587dccbf94681216a85ba4e73add3 codea: formatstring --- diff --git a/codea/chelper.c b/codea/chelper.c index 2392092..af9cf4c 100644 --- a/codea/chelper.c +++ b/codea/chelper.c @@ -32,7 +32,7 @@ void move(char *src, char *dst) void moveimm(long imm, char *dst) { char buf[100]; - sprintf(buf, "$%li", imm); + sprintf(buf, "$%d", imm); printf("\tmovq %s, %%%s\n", buf, dst); } diff --git a/codea/code.bfe b/codea/code.bfe index fe02a95..5ec22a2 100644 --- a/codea/code.bfe +++ b/codea/code.bfe @@ -26,9 +26,9 @@ void gen_e_imm(struct treenode *bnode, char *instr) { /* man kann sich ein move der konstante bei der multiplikation ersparen */ if(strcmp(instr, "imulq") == 0) { - printf("\timulq $%li, %%%s, %%%s\n", KID_VAL(1), KID_REG(0), BN_REG); + printf("\timulq $%d, %%%s, %%%s\n", KID_VAL(1), KID_REG(0), BN_REG); } else { - printf("\t%s $%li, %%%s\n", instr, KID_VAL(1), KID_REG(0)); + printf("\t%s $%d, %%%s\n", instr, KID_VAL(1), KID_REG(0)); move(KID_REG(0), BN_REG); } } @@ -38,7 +38,7 @@ void gen_imm_eno(struct treenode *bnode, char *instr) KIDREG2PARM(1); /* man kann sich ein move der konstante bei der multiplikation ersparen */ if(strcmp(instr, "imulq") == 0) { - printf("\timulq $%li, %%%s, %%%s\n", KID_VAL(0), KID_REG(1), BN_REG); + printf("\timulq $%d, %%%s, %%%s\n", KID_VAL(0), KID_REG(1), BN_REG); } else { moveimm(KID_VAL(0), BN_REG); printf("\t%s %%%s, %%%s\n", instr, KID_REG(1), BN_REG); @@ -54,10 +54,10 @@ void gen_eqless(struct treenode *bnode, char *op, short e0, short e1) if(e0 && e1) { printf("\tcmp %%%s, %%%s\n", KID_REG(1), KID_REG(0)); } else if(e0 && !e1) { - printf("\tcmp $%li, %%%s\n", KID_VAL(1), KID_REG(0)); + printf("\tcmp $%d, %%%s\n", KID_VAL(1), KID_REG(0)); } else if(!e0 && e1) { if(strcmp("e", op) == 0) { - printf("\tcmp $%li, %%%s\n", KID_VAL(0), KID_REG(1)); + printf("\tcmp $%d, %%%s\n", KID_VAL(0), KID_REG(1)); } else { moveimm(KID_VAL(0), BN_REG); printf("\tcmp %%%s, %%%s\n", KID_REG(1), BN_REG); @@ -104,8 +104,8 @@ expr: O_EQ(imm,exprno) # 3 # gen_eqless(bnode, "e", 0, 1); expr: O_EQ(nexpr,O_NULL) # 0 # expr: O_EQ(exprno,O_NULL) # 3 # gen_eqless(bnode, "e", 1, 0); -expr: O_FIELD(exprno) # 1 # KIDREG2PARM(0); printf("\tmovq %li(%%%s), %%%s\n", bnode->soffset * 8, KID_REG(0), BN_REG); -expr: O_FIELD(imm) # 1 # printf("\tmovq %li, %%%s\n", KID_VAL(0) + (bnode->soffset * 8), BN_REG); +expr: O_FIELD(exprno) # 1 # KIDREG2PARM(0); printf("\tmovq %d(%%%s), %%%s\n", bnode->soffset * 8, KID_REG(0), BN_REG); +expr: O_FIELD(imm) # 1 # printf("\tmovq %d, %%%s\n", KID_VAL(0) + (bnode->soffset * 8), BN_REG); exprno: O_ID # 0 # /* brauchen wir nicht 'zwischenlagern', weil nur gelesen wird */