X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=gesamt_ppc%2Fchelper.c;h=2e736ea421618c08867b07b598b27cfdbbf2d615;hb=HEAD;hp=c8746eb3e941361754d3c73bc14274aba89d6c25;hpb=6ee8574eb8de603417fc0a55b6b9a809cb76b806;p=uebersetzerbau-ss10.git diff --git a/gesamt_ppc/chelper.c b/gesamt_ppc/chelper.c index c8746eb..2e736ea 100644 --- a/gesamt_ppc/chelper.c +++ b/gesamt_ppc/chelper.c @@ -23,14 +23,10 @@ void func_header(char *s, int vars, int parms, int call) need_stack = (vars || parms) && call; if(need_stack) { -#if 0 - printf("\tenter $%d, $0\n", 8*(vars + parms + 2 /* fuer rax und r10 */)); -#else /* save the link register */ - printf("\tmflr 0; stw 0,8(1)\n"); + printf("\tmflr 0; stw 0,-8(1)\n"); /* create the stack */ - printf("\tstwu 1, -64(1)\n"); -#endif + printf("\tstwu 1, -80(1)\n"); } } @@ -42,14 +38,10 @@ char *get_func_name(void) void func_footer(void) { if(need_stack) { -#if 0 - printf("\tleave\n"); -#else /* remove stack frame */ - printf("\taddi 1,1,64\n"); + printf("\taddi 1,1,80\n"); /* restore link register */ - printf("\tlwz 0,8(1); mtlr 0\n"); -#endif + printf("\tlwz 0,-8(1); mtlr 0\n"); } printf("\tblr\n\n\n"); } @@ -64,8 +56,15 @@ void move(char *src, char *dst) void moveimm(long imm, char *dst) { - /* TODO: 32 bits... */ - printf("\tli %s,%d\n", dst, imm); + if((imm > 65536-1) || (imm < -65536)) { + /* high word */ + printf("\tlis %s,%d@ha\n", dst, imm); + /* low word */ + printf("\taddi %s,%s,%d@l\n", dst, dst, imm); + } else { + /* just low word */ + printf("\tli %s,%d@l\n", dst, imm); + } } char *next_reg(char *s, int params) @@ -92,7 +91,7 @@ char *reg_64to8l(char *s) char *param_reg(int num) { - char *regs[] = {"3", "4", "5", "6", "7", "8", "9"}; + char *regs[] = {"3", "4", "5", "6", "7", "8", "9", "10"}; return regs[num]; }