Mercurial > hg > CbC > old > device
changeset 163:fc8514c9d685
*** empty log message ***
author | kono |
---|---|
date | Mon, 24 Nov 2003 00:52:18 +0900 |
parents | 0c604d2ff585 |
children | 1c2a9232ea93 |
files | mc-code-ia32.c mc-code-mips.c |
diffstat | 2 files changed, 60 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-ia32.c Mon Nov 24 00:21:59 2003 +0900 +++ b/mc-code-ia32.c Mon Nov 24 00:52:18 2003 +0900 @@ -135,7 +135,7 @@ static void use_register(int virt, int real, int move); static int virtual(int real); static void shift(char *op, int reg); -static void ld_indexx(int byte, int n, int xreg); +static void ld_indexx(int byte, int n, int xreg,int sign); static void data_mode(char *name); static int edx_setup(); static void edx_cleanup(); @@ -542,8 +542,9 @@ } void -code_crgvar(int e1,int creg){ - printf("\tmovsbl %s,%s\n",((NMTBL*)cadr(e1))->nm,register_name(creg,0)); +code_crgvar(int e1,int creg,int sign){ + printf("\t%s %s,%s\n",sign?"movsbl":"movbl", + ((NMTBL*)cadr(e1))->nm,register_name(creg,0)); regv[creg]=1; } @@ -570,8 +571,8 @@ void -code_crlvar(int e2,int reg) { - printf("\tmovsbl %d(%%ebp),%s\n",lvar(e2),register_name(reg,0)); +code_crlvar(int e2,int reg,int sign) { + printf("\t%s %d(%%ebp),%s\n",sign?"movsbl":"movbl",lvar(e2),register_name(reg,0)); regv[creg]=1; } @@ -647,10 +648,10 @@ void -code_cpostinc(int e1,int e2,int reg) { +code_cpostinc(int e1,int e2,int reg,int sign) { char *xrn; if (car(e2)==REGISTER) { - printf("\tmovbl (%s),%s\n",register_name(cadr(e2),0), + printf("\t%s (%s),%s\n",sign?"movsbl":"movbl",register_name(cadr(e2),0), register_name(reg,0)); printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0)); regv[reg]=1; @@ -659,47 +660,47 @@ g_expr(e2); emit_push(); xrn = register_name((e2=emit_pop(0)),1); - printf("\tmovsbl (%s),%s\n",xrn,register_name(creg,0)); + printf("\t%s (%s),%s\n",sign?"movsbl":"movbl",xrn,register_name(creg,0)); printf("\tincl (%s)\n",xrn); emit_pop_free(e2); } void -code_cpreinc(int e1,int e2,int reg) { +code_cpreinc(int e1,int e2,int reg,int sign) { if (car(e2)==REGISTER) { printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0)); - printf("\tmovsbl (%s),%s\n",register_name(cadr(e2),0), + printf("\t%s (%s),%s\n",sign?"movsbl":"movbl",register_name(cadr(e2),0), register_name(reg,0)); regv[reg]=1; return; } g_expr(e2); printf("\tincl (%s)\n",register_name(creg,0)); - printf("\tmovsbl (%s),%s\n",register_name(creg,0),register_name(creg,0)); + printf("\t%s (%s),%s\n",sign?"movsbl":"movbl",register_name(creg,0),register_name(creg,0)); } void -code_cpostdec(int e1,int e2,int reg) { +code_cpostdec(int e1,int e2,int reg,int sign) { if (car(e2)==REGISTER) { - printf("\tmovsbl (%s),%s\n",register_name(cadr(e2),0), + printf("\t%s (%s),%s\n",sign?"movsbl":"movbl",register_name(cadr(e2),0), register_name(reg,0)); printf("\tdecl %s\n",register_name(cadr(e2),0)); regv[reg]=1; return; } g_expr(e2); - printf("\tmovsbl (%s),%s\n",register_name(creg,0),register_name(creg,0)); + printf("\t%s (%s),%s\n",sign?"movsbl":"movbl",register_name(creg,0),register_name(creg,0)); printf("\tdecl (%s)\n",register_name(creg,0)); } void -code_cpredec(int e1,int e2,int reg) { +code_cpredec(int e1,int e2,int reg,int sign) { if (car(e2)==REGISTER) { printf("\tdecl %s\n",register_name(cadr(e2),0)); - printf("\tmovsbl (%s),%s\n",register_name(cadr(e2),0), + printf("\t%s (%s),%s\n",sign?"movsbl":"movbl",register_name(cadr(e2),0), register_name(reg,0)); regv[reg]=1; return; @@ -708,7 +709,7 @@ emit_push(); e2 = emit_pop(0); printf("\tdecl (%s)\n",register_name(e2,0)); - printf("\tmovsbl (%s),%s\n",register_name(e2,0),register_name(creg,0)); + printf("\t%s (%s),%s\n",sign?"movsbl":"movbl",register_name(e2,0),register_name(creg,0)); emit_pop_free(e2); } @@ -1098,14 +1099,18 @@ g_expr(e2); switch (car(e1)) { case FRINDIRECT: case DRINDIRECT: - printf("\t%s (%s)\n",fload(car(e1)==DRINDIRECT),register_name(creg,0)); - t=DOUBLE; - break; - case CRINDIRECT: case RINDIRECT: default: - op = ((byte = (car(e1) == CRINDIRECT)) ? "movsbl" : "movl"); + printf("\t%s (%s)\n",fload(car(e1)==DRINDIRECT),register_name(creg,0)); + t=DOUBLE; + return t; + break; + case CRINDIRECT: + byte = 1; op="movsbl";t=CHAR; + case CURINDIRECT: + byte = 1; op="movbl";t=UCHAR; + case RINDIRECT: default: + byte = 0; op="movl";t=INT; + } printf("\t%s (%s),%s\n",op,register_name(creg,0),register_name(creg,0)); - t=byte?CHAR:INT; - } return t; } @@ -1152,7 +1157,7 @@ void -code_assop(int op,int byte) { +code_assop(int op,int byte,int sign) { char *xrn; int xreg; int edx = edx_setup(); @@ -1160,7 +1165,7 @@ regv[xreg]=regs[xreg]=1; printf("\tmovl %s,%s # assop \n",register_name(creg,0),register_name(edx,0)); regv[edx]=1; - ld_indexx(byte,0,edx); + ld_indexx(byte,0,edx,sign); tosop(op,xreg); printf("\t%s %s,(%s)\n",byte ? "movb" : "movl",register_name(creg,byte),register_name(edx,0)); edx_cleanup(); @@ -1307,11 +1312,11 @@ } void -ld_indexx(int byte, int n, int xreg) +ld_indexx(int byte, int n, int xreg,int sign) { char *op; - op = byte ? "movsbl" : "movl"; + op = byte ? (sign?"movsbl":"movbl") : "movl"; if (n) printf("\t%s %d(%s),%s\n",op,n, register_name(xreg,0),register_name(creg,byte));
--- a/mc-code-mips.c Mon Nov 24 00:21:59 2003 +0900 +++ b/mc-code-mips.c Mon Nov 24 00:52:18 2003 +0900 @@ -11,7 +11,7 @@ #define RODATA_EMIT_MODE 2 static void data_mode(char *name); -static void ld_indexx(int byte, int n, int xreg); +static void ld_indexx(int byte, int n, int xreg,int sign); static void local_table(void); static void shift(char *op, int reg); static int struct_push(int e4,int t,int arg); @@ -819,8 +819,8 @@ } void -code_crgvar(int e1,int creg){ - printf("\tlb %s,%s\n",register_name(creg),((NMTBL*)cadr(e1))->nm); +code_crgvar(int e1,int creg,int sign){ + printf("\t%s %s,%s\n",sign?"lbu":"lb",register_name(creg),((NMTBL*)cadr(e1))->nm); regv[creg]=1; } @@ -842,8 +842,8 @@ void -code_crlvar(int e2,int reg) { - printf("\tlb %s,",register_name(reg)); +code_crlvar(int e2,int reg,int sign) { + printf("\t%s %s,",sign?"lbu":"lb",register_name(reg)); lvar(e2); regv[reg]=1; } @@ -940,11 +940,11 @@ void -code_cpostinc(int e1,int e2,int reg) { +code_cpostinc(int e1,int e2,int reg,int sign) { char *xrn,*crn,*nrn; int i,nreg,dreg; if (car(e2)==REGISTER) { - printf("\tlb %s,0(%s)\n",register_name(reg),register_name(cadr(e2))); + printf("\t%s %s,0(%s)\n",sign?"lbu":"lb",register_name(reg),register_name(cadr(e2))); printf("\taddu %s,%s,%d\n", register_name(cadr(e2)),register_name(cadr(e2)),caddr(e1)); regv[reg]=1; @@ -957,7 +957,7 @@ nreg=get_register(); if (!nreg) error(-1); nrn = register_name(nreg); printf("\tlw %s,0(%s)\n",xrn,crn); - printf("\tlb %s,0(%s)\n",nrn,xrn); + printf("\t%s %s,0(%s)\n",sign?"lbu":"lb",nrn,xrn); printf("\taddu %s,%s,%d\n", xrn,xrn,caddr(e1)); printf("\tsw %s,0(%s)\n",xrn,crn); i=creg;creg=nreg;nreg=i; @@ -968,13 +968,13 @@ void -code_cpreinc(int e1,int e2,int reg) { +code_cpreinc(int e1,int e2,int reg,int sign) { char *xrn,*crn,*nrn; int i,nreg,dreg; if (car(e2)==REGISTER) { printf("\taddu %s,%s,%d\n", register_name(cadr(e2)),register_name(cadr(e2)),caddr(e1)); - printf("\tlb %s,0(%s)\n",register_name(reg),register_name(cadr(e2))); + printf("\t%s %s,0(%s)\n",sign?"lbu":"lb",register_name(reg),register_name(cadr(e2))); regv[reg]=1; return; } @@ -986,7 +986,7 @@ nrn = register_name(nreg); printf("\tlw %s,0(%s)\n",xrn,crn); printf("\taddu %s,%s,%d\n", nrn,xrn,caddr(e1)); - printf("\tlb %s,0(%s)\n",nrn,xrn); + printf("\t%s %s,0(%s)\n",sign?"lbu":"lb",nrn,xrn); printf("\tsw %s,0(%s)\n",xrn,crn); i=creg;creg=nreg;nreg=i; free_register(nreg); @@ -996,13 +996,13 @@ void -code_cpostdec(int e1,int e2,int reg) { +code_cpostdec(int e1,int e2,int reg,int sign) { char *xrn,*crn,*nrn; int i,nreg,dreg; if (car(e2)==REGISTER) { crn=register_name(reg); xrn=register_name(cadr(e2)); - printf("\tlb %s,0(%s)\n",crn,xrn); + printf("\t%s %s,0(%s)\n",sign?"lbu":"lb",crn,xrn); printf("\taddu %s,%s,%d\n",xrn,xrn,caddr(e1)); regv[reg]=1; return; @@ -1014,7 +1014,7 @@ nreg=get_register(); if (!nreg) error(-1); nrn = register_name(nreg); printf("\tlw %s,0(%s)\n",xrn,crn); - printf("\tlb %s,0(%s)\n",nrn,xrn); + printf("\t%s %s,0(%s)\n",sign?"lbu":"lb",nrn,xrn); printf("\taddu %s,%s,%d\n",xrn,xrn,caddr(e1)); printf("\tsw %s,0(%s)\n",xrn,crn); i=creg;creg=nreg;nreg=i; @@ -1025,14 +1025,14 @@ void -code_cpredec(int e1,int e2,int reg) { +code_cpredec(int e1,int e2,int reg,int sign) { char *xrn,*crn,*nrn; int i,nreg,dreg; if (car(e2)==REGISTER) { crn=register_name(reg); xrn=register_name(cadr(e2)); printf("\taddu %s,%s,%d\n",xrn,xrn,caddr(e1)); - printf("\tlb %s,%d(%s)\n",crn,caddr(e1),xrn); + printf("\t%s %s,%d(%s)\n",sign?"lbu":"lb",crn,caddr(e1),xrn); regv[reg]=1; return; } @@ -1044,7 +1044,7 @@ nrn = register_name(nreg); printf("\tlw %s,0(%s)\n",xrn,crn); printf("\taddu %s,%s,%d\n",xrn,xrn,caddr(e1)); - printf("\tlb %s,%d(%s)\n",nrn,caddr(e1),xrn); + printf("\t%s %s,%d(%s)\n",sign?"lbu":"lb",nrn,caddr(e1),xrn); printf("\tsw %s,0(%s)\n",xrn,crn); i=creg;creg=nreg;nreg=i; free_register(nreg); @@ -1119,7 +1119,7 @@ void code_cmp_crgvar(int e1) { if (cmpreg==-1) cmpreg = get_register(); - code_crgvar(cadr(e1),cmpreg); + code_crgvar(cadr(e1),cmpreg,0); regv[cmpreg]=1; } @@ -1127,7 +1127,7 @@ void code_cmp_crlvar(int e2) { if (cmpreg==-1) cmpreg = get_register(); - code_crlvar(e2,cmpreg); + code_crlvar(e2,cmpreg,0); regv[cmpreg]=1; } @@ -1631,6 +1631,9 @@ case CRINDIRECT: printf("\tlb %s,%d(%s)\n",crn,offset,crn); return CHAR; + case CURINDIRECT: + printf("\tlbu %s,%d(%s)\n",crn,offset,crn); + return UCHAR; case RINDIRECT: printf("\tlw %s,%d(%s)\n",crn,offset,crn); return INT; @@ -1696,7 +1699,7 @@ void -code_assop(int op,int byte) { +code_assop(int op,int byte,int sign) { char *xrn,*crn,*drn; int xreg; int edx = get_register(); if(!edx) error(-1); @@ -1704,7 +1707,7 @@ regv[xreg]=regs[xreg]=1; printf("# assop\n\tmr %s,%s\n",register_name(edx),register_name(creg)); regv[edx]=1; - ld_indexx(byte,0,edx); + ld_indexx(byte,0,edx,sign); tosop(op,xreg); crn = register_name(creg); drn = register_name(edx); @@ -1805,15 +1808,14 @@ } void -ld_indexx(int byte, int n, int xreg) +ld_indexx(int byte, int n, int xreg,int sign) { char *crn = register_name(creg); if (byte) { - printf("\tlb %s,%d(%s)\n",register_name(creg),n, + printf("\t%s %s,%d(%s)\n",sign?"lbu":"lb",crn,n, register_name(xreg)); - printf("\textsb %s,%s\n",crn,crn); } else - printf("\tlw %s,%d(%s)\n",register_name(creg),n, + printf("\tlw %s,%d(%s)\n",crn,n, register_name(xreg)); }