changeset 248:b4a57dd14801

no compile error (mips)
author kono
date Tue, 11 May 2004 02:26:10 +0900
parents 0252050601bd
children 8313c965c0e2
files mc-code-mips.c mc.h
diffstat 2 files changed, 127 insertions(+), 103 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-mips.c	Tue May 11 01:41:14 2004 +0900
+++ b/mc-code-mips.c	Tue May 11 02:26:10 2004 +0900
@@ -28,9 +28,13 @@
 static int data_alignment = 0;
 
 static int code_disp_label;
-static int code_setup;
+static int disp_label;
 static int r1_offset_label;
 static int lvar_offset_label;
+static int cprestore_label;
+static int    max_func_args = 0;
+static int    max_func_iargs = 0;
+
 
 static int reg_save;
 static int freg_save;
@@ -93,6 +97,19 @@
 #define RET_LREGISTER_H 3    /* high word */
 #define RET_LREGISTER_L 4    /* low word */
 #define RET_LREGISTER LREG_OFFSET
+#define RET_DREGISTER LREG_OFFSET
+#define LREGISTER_OPERAND  LREG_OFFSET-1
+#define LREGISTER_OPERAND_H  4    /* high word */
+#define LREGISTER_OPERAND_L  5    /* low word */
+#define LREGISTER_OPERAND_1  LREG_OFFSET-2
+#define LREGISTER_OPERAND_1_H  6    /* high word */
+#define LREGISTER_OPERAND_1_L  7    /* low word */
+#define DREGISTER_OPERAND  LREG_OFFSET-1
+#define DREGISTER_OPERAND_H  4    /* high word */
+#define DREGISTER_OPERAND_L  5    /* low word */
+#define DREGISTER_OPERAND_1  LREG_OFFSET-2
+#define DREGISTER_OPERAND_1_H  6    /* high word */
+#define DREGISTER_OPERAND_1_L  7    /* low word */
 
 int MAX_INPUT_REGISTER_VAR = 7-MIN_TMP_REG;
 int MAX_CODE_INPUT_REGISTER_VAR = 7-MIN_TMP_REG;
@@ -101,18 +118,19 @@
 int MAX_CODE_INPUT_DREGISTER_VAR = 14-MIN_TMP_FREG;
 int MAX_CODE_INPUT_FREGISTER_VAR = 14-MIN_TMP_FREG;
 
-static int powerpc_regs[REAL_MAX_REGISTER+REAL_MAX_FREGISTER+
+static int mips_regs[REAL_MAX_REGISTER+REAL_MAX_FREGISTER+
    REAL_MAX_LREGISTER];
 static int regv_h0[REAL_MAX_LREGISTER];
 static int regv_l0[REAL_MAX_LREGISTER];
 #define regv_h(i)  regv_h0[(i)-LREG_OFFSET]
 #define regv_l(i)  regv_l0[(i)-LREG_OFFSET]
 
-static int *regs  = powerpc_regs;
+static int *regs  = mips_regs;
 
 #define CREG_REGISTER  (MAX_TMP_REG)
 #define FREG_FREGISTER (MAX_TMP_FREG+FREG_OFFSET)
 #define LREG_LREGISTER (MAX_TMP_REG+LREG_OFFSET)
+#define CMP_C1T (-1)
 
 
 static int max_reg_var, max_freg_var;
@@ -179,6 +197,8 @@
     creg = i;
     return i;
 }
+
+static void lmove(int to,int from);
 #endif
 
 
@@ -197,6 +217,10 @@
     creg = i;
     return i;
 }
+
+#define USING_DREG 5
+#define INPUT_DREG 6
+
 static
 int use_double0() { 
     int i = creg;
@@ -218,13 +242,8 @@
 
 
 #if FLOAT_CODE
-static
-NMTBL float_zero = {"_float_zero",STATIC,FLOAT,0};
-static
-NMTBL float_one = {"_float_one",STATIC,FLOAT,0};
-
-
-static char * fload(int d);
+
+
 static int code_d1(double d);
 static int code_d2(double d);
 #endif
@@ -381,8 +400,10 @@
     regv_h(RET_LREGISTER) = RET_LREGISTER_H;
 }
 
+
 void
 gexpr_code_init(void){
+    cmpreg = CMP_C1T ;
 }
 
 void
@@ -664,7 +685,7 @@
     if (d) {
       j = get_input_lregister_var(i,n,is_code);
       if (car(j)==LREGISTER) {
-	if (regs[cadr(j)]=INPUT_REG) regs[cadr(j)]=INPUT_DREG;
+	if (regs[cadr(j)]==INPUT_REG) regs[cadr(j)]=INPUT_DREG;
 	car(j) = DREGISTER;
       }
       return j;
@@ -873,7 +894,7 @@
 {
     int i;
     if (d) {
-        i = get_lregister_var(n,d);
+        i = get_lregister_var(n);
 	if (car(i)==LREGISTER) {
 	    car(i) = DREGISTER;
 	    regs[i] = USING_DREG;
@@ -919,8 +940,6 @@
     return xreg;
 }
 
-static int code_base;
-
 #define MAX_PTR_CACHE 10
 
 int ptr_cache=0;
@@ -1246,7 +1265,7 @@
     use_int(reg);
     crn = register_name(reg);
     r = get_ptr_cache((NMTBL*)cadr(e1));
-    printf("\t%s %s,0(%s)\n",cload(sz,sign),crn,register_name(r));
+    printf("\t%s %s,0(%s)\n",cload(sz,0),crn,register_name(r));
     cext(0,sz,r);
     cmpreg = reg;
     // printf("\tcmpwi cr0,%s,0\n",crn);
@@ -1259,7 +1278,7 @@
     use_int(reg);
     crn = register_name(reg);
     lvar_intro(e2);
-    printf("\t%s %s,",cload(sz,sign),crn);
+    printf("\t%s %s,",cload(sz,0),crn);
     lvar(e2);
     cext(0,sz,reg);
     code_cmp_register(reg);
@@ -1293,7 +1312,7 @@
 void
 code_cmp_register(int e2) {
     use_int(e2);
-    cmpreg = reg;  // used by jcond,  beq $reg,$0,L_xx
+    cmpreg = e2;  // used by jcond,  beq $reg,$0,L_xx
 }
 
 
@@ -1661,9 +1680,9 @@
 		lreg = 0;
 	    } else if (regv_h(lreg)==reg) {
 		regs[lreg]=0;
-		if (regv_h(lreg)>reg&&
+		if (regv_h(lreg)>reg && (
 		    (regs[regv_l(lreg)]==USING_DREG) ||
-		    (regs[regv_l(lreg)]==USING_DREG) )
+		    (regs[regv_l(lreg)]==USING_DREG) ))
 		  {
 		    free_register(regv_l(lreg));
 		}
@@ -1689,7 +1708,7 @@
 int
 function(int e1)
 {
-    int e2,e3,e4,e5,nargs,t,r0,r1;
+    int e2,e3,e4,nargs,t,r0;
     int arg,reg_arg,freg_arg,arg_assign;
     int dots;
     int reg_arg_list=0,ret_type,special_lvar;
@@ -1761,7 +1780,7 @@
 		arg_assign = list2(
 		    assign_expr0(r0=
 				 (t==DOUBLE?
-				  get_input_dregister_var(reg_arg,0,0):
+				  get_input_dregister_var(reg_arg,0,0,1):
 				  get_input_lregister_var(reg_arg,0,0)
 				  ),
 			arg,t,t),
@@ -1933,7 +1952,7 @@
     if (!is_int_reg(creg)) error(-1);
     crn=register_name(creg);
     use_float(d,reg);
-    printf("\t%s %s,%d(%s)\n",fload(d),
+    printf("\tl.s %s,%d(%s)\n",
 	fregister_name(reg),offset,crn);
     return FLOAT;
 }
@@ -2049,7 +2068,7 @@
 tosop(int op,int creg,int oreg)
 {
     int dx = -1;
-    char *orn,*crn,*drn;
+    char *orn,*crn;
     // creg = creg op oreg
 
     use_int(creg);
@@ -2130,7 +2149,7 @@
 code_const_op_p(int op,int v)
 {
     if (car(v)!=CONST) return 0;
-    if (op==BAND||op==DIV||op==UDIV||op==MOD||op==UMOD||op==XOR||op==MUL||op==UMUL) return 0;
+    if (op==BAND||op==DIV||op==UDIV||op==MOD||op==UMOD||op==EOR||op==MUL||op==UMUL) return 0;
     v = cadr(v);
     return (-32766<v&&v<32767);
 }
@@ -2214,6 +2233,7 @@
 {
     /* this is called once per file */
     char *p=cheapp;
+    char *s;
     printf("\t.file \"%s\"\n",filename);
     printf(".abicalls\n");
     printf(".text\n");
@@ -2244,10 +2264,11 @@
     } else {
          op = t==INT?CMP:UCMP;
 	 g_expr(list3(op,cadr(e1),caddr(e1)));
-	 printf("\tb%s %s,%0,L_%d\n",s,register_name(cmpreg),l1);
+	 printf("\tb%s %s,$0,L_%d\n",s,register_name(cmpreg),l1);
     }
 }
 
+#define CMP_C1T (-1)
 
 void
 jcond(int l, char cond)
@@ -2331,7 +2352,6 @@
 
     r1_offset_label = fwdlabel();
     lvar_offset_label = fwdlabel();
-    disp_label = fwdlabel();
     mask_label = fwdlabel();
     mask1_label = fwdlabel();
     fmask_label = fwdlabel();
@@ -2412,7 +2432,7 @@
 		printf("\tmov.s %s,%s\n",register_name(RET_FREGISTER),
 			register_name(freg));
 	} else if (cadr(fnptr->ty)==DOUBLE) {
-	    move_dreg(RET_DREGISTER,dreg);
+	    set_dreg(RET_DREGISTER,1);
 	} else if (cadr(fnptr->ty)>0&&(
 	    car(cadr(fnptr->ty))==STRUCT ||
 	    car(cadr(fnptr->ty))==UNION)) {
@@ -2605,7 +2625,7 @@
 global_table(void)
 {
     NMTBL *n;
-    int init; char *extrn;
+    int init;
     init=0;
     for(n=ntable;n < &ntable[GSYMS];n++) {
 	if ((n->sc == GVAR) && n->dsp != -1) {
@@ -2685,6 +2705,8 @@
 void
 code_cmp_dregister(int e2,int d)
 {
+    char *grn,*frn;
+    int greg;
     if (d) {
         code_save_stacks();
 	clear_ptr_cache();
@@ -2706,7 +2728,7 @@
 {
     use_float(d,freg);
     if (d) {
-        code_lregister(e2,freg,0); set_bouble(freg); return;
+        code_lregister(e2,freg); set_double(freg); return;
     }
     if (freg!=e2) {
         if (is_int_reg(e2)) error(-1);
@@ -2720,7 +2742,7 @@
     int r;
     use_float(d,freg);
     if (d) {
-         code_lassign_gvar(e2,freg,0);  set_double(freg); return;
+         code_lassign_gvar(e2,freg);  set_double(freg); return;
     }
     r = get_ptr_cache((NMTBL*)cadr(e2));
     printf("\ts.s %s,0(%s)\n",fregister_name(freg),register_name(r));
@@ -2731,7 +2753,7 @@
 { 
     use_float(d,freg);
     if (d) {
-        code_lassign_lvar(e2,freg,0); set_double(freg); return;
+        code_lassign_lvar(e2,freg); set_double(freg); return;
     }
     lvar_intro(e2);
     printf("\ts.s %s,",fregister_name(freg));
@@ -2743,16 +2765,16 @@
 { 
     use_float(d,freg);
     if (d) {
-        code_lassign(e2,freg,0); set_double(freg); return;
+        code_lassign(e2,freg); set_double(freg); return;
     }
-    printf("\ts.s %s,0(%s)\n",fstore(d),fregister_name(freg),register_name(e2));
+    printf("\ts.s %s,0(%s)\n",fregister_name(freg),register_name(e2));
 }
 
 void
 code_dassign_dregister(int e2,int d,int freg) {
     use_float(d,freg);
     if (d) {
-        code_lassign_lregister(e2,0,freg); set_double(freg); return;
+        code_lassign_lregister(e2,freg); set_double(freg); return;
     }
     if (e2!=freg) {
 	printf("\tmov.s %s,%s\n",fregister_name(e2),fregister_name(freg));
@@ -2787,15 +2809,14 @@
 
 code_dconst(int e2,int freg,int d)
 { 
-    int lb;
     double value = dcadr(e2);
     int r;
-    char *rrn,*frn;
+    char *frn;
 
     use_float(d,freg);
     if (d) {
-	printf("\t.li %s,%g\n",lregister_name_high(freg),code_d2(value));
-	printf("\t.li %s,%g\n",lregister_name_low(freg),code_d1(value));
+	printf("\t.li %s,0x%x\n",lregister_name_high(freg),code_d2(value));
+	printf("\t.li %s,0x%x\n",lregister_name_low(freg),code_d1(value));
 	free_register(r);
     } else {
         frn = fregister_name(freg);
@@ -2824,48 +2845,48 @@
 void
 code_d2i(int reg)
 { 
-    use_float(reg,1);
+    use_float(1,reg);
     code_save_stacks();
     clear_ptr_cache();
     set_dreg(RET_DREGISTER,1);
     extern_conv("dptoli");
-    set_creg(RET_REGISTER,0);
+    set_ireg(RET_REGISTER,0);
     return;
 }
 
 void
 code_i2d(int reg)
 { 
-    set_creg(RET_REGISTER,1);
+    set_ireg(RET_REGISTER,1);
     code_save_stacks();
     clear_ptr_cache();
     extern_conv("litodp");
     set_dreg(RET_DREGISTER,0);
-    use_float(reg,1);
+    use_float(1,reg);
     return;
 }
 
 void
 code_d2u(int reg)
 { 
-    use_float(reg,1);
+    use_float(1,reg);
     code_save_stacks();
     clear_ptr_cache();
     set_dreg(RET_DREGISTER,1);
     extern_conv("dptoul");
-    set_creg(RET_REGISTER,0);
+    set_ireg(RET_REGISTER,0);
     return;
 }
 
 void
 code_u2d(int reg)
 { 
-    set_creg(RET_REGISTER,1);
+    set_ireg(RET_REGISTER,1);
     code_save_stacks();
     clear_ptr_cache();
     extern_conv("ultodp");
     set_dreg(RET_DREGISTER,0);
-    use_float(reg,1);
+    use_float(1,reg);
     return;
 }
 
@@ -2876,7 +2897,7 @@
     clear_ptr_cache();
     extern_conv("dptofp");
     set_freg(RET_FREGISTER,0);
-    use_float(reg,0);
+    use_float(0,reg);
     return;
 }
 
@@ -2887,7 +2908,7 @@
     clear_ptr_cache();
     extern_conv("fptodp");
     set_dreg(RET_DREGISTER,0);
-    use_float(reg,1);
+    use_float(1,reg);
     return;
 }
 
@@ -2901,12 +2922,12 @@
 void
 code_f2u(int reg) {
     int freg0 = freg;
-    int_freg1 = get_dregister(0);
-    int_freg2 = get_dregister(0);
-    int_ireg1 = get_register();
-    char *fr0 = dregister_name(freg0);
-    char *fr1 = dregister_name(freg1);
-    char *fr2 = dregister_name(freg2);
+    int freg1 = get_dregister(0);
+    int freg2 = get_dregister(0);
+    int ireg1 = get_register();
+    char *fr0 = fregister_name(freg0);
+    char *fr1 = fregister_name(freg1);
+    char *fr2 = fregister_name(freg2);
     char *r1 = register_name(ireg1);
     char *r0;
     int lb1,lb2;
@@ -2930,38 +2951,38 @@
     fwddef(lb2);
     free_register(freg1);
     free_register(freg2);
-    free_register(reg1);
+    free_register(ireg1);
 }
 
 void
 code_i2f(int reg) {
      int n = new_lvar(SIZE_OF_FLOAT);
-     code_assign_lvar(n,ireg);
-     use_float(reg,0);
-     code_drlvar(n,reg);
+     code_assign_lvar(n,ireg,SIZE_OF_INT);
+     use_float(0,reg);
+     code_drlvar(n,reg,0);
      printf("\tcvt.s.w %s,%s\n",register_name(freg),register_name(freg));
 }
 
 void
 code_u2f(int reg) {
      int n = new_lvar(SIZE_OF_FLOAT);
-     int reg0;
-     int lb1;
-     char *frn;
-     code_assign_lvar(n,ireg);
+     int reg0,reg1;
+     int lb1,lb2;
+     char *frn,*r0,*r1;
+     code_assign_lvar(n,ireg,SIZE_OF_INT);
      printf("\tbltz    %s,L_%d\n",r0=register_name(ireg),lb1=fwdlabel());
-     use_float(reg,0);
+     use_float(0,reg);
      code_drlvar(n,reg,0);
-     reg0 = get_register();
-     reg1 = get_register();
-     frn = dregister_name(reg);
+     r0= register_name(reg0 = get_register());
+     r1= register_name(reg1 = get_register());
+     frn = fregister_name(reg);
      printf("\tcvt.s.w %s,%s\n",frn,frn);
      printf("\tj       L_%d\n",lb2=fwdlabel());
     printf("\t.p2align 2\n");
     fwddef(lb1);
     printf("\tandi    %s,%s,0x1\n",r1,r0);
     printf("\tsrl     %s,%s,1\n",r0,r0);
-    printf("\tor      %s,%s,%s\n",r1,r0);
+    printf("\tor      %s,%s,%s\n",r1,r1,r0);
     printf("\tmtc1    %s,%s\n",r1,frn);
     printf("\tcvt.s.w %s,%s\n",frn,frn);
     printf("\tadd.s   %s,%s,%s\n",frn,frn,frn);
@@ -2975,7 +2996,7 @@
 { 
     int r;
     if (d) {
-         code_lrgvar(e2,0,freg);
+         code_lrgvar(e2,freg);
          set_double(freg);
 	 return;
     }
@@ -2989,7 +3010,7 @@
 code_drlvar(int e2,int d,int freg)
 { 
     if (d) {
-         code_lrlvar(e2,0,freg);
+         code_lrlvar(e2,freg);
          set_double(freg);
 	 return;
     }
@@ -3020,7 +3041,7 @@
     } else {
         code_drgvar(e2,d,USE_CREG);
 	frn = fregister_name(freg);
-	fr1=dregister_name(g = get_dregister(0));
+	fr1=fregister_name(g = get_dregister(0));
 	printf("\tmtc1   $0,%s\n",fr1);
         printf("\tfc.eq.s %s,%s\n",frn,fr1);
 	cmpreg = CMP_C1T;
@@ -3047,7 +3068,7 @@
     } else {
         code_drlvar(e2,d,USE_CREG);
 	frn = fregister_name(freg);
-	fr1=dregister_name(g = get_dregister(0));
+	fr1=fregister_name(g = get_dregister(0));
 	printf("\tmtc1   $0,%s\n",fr1);
         printf("\tfc.eq.s %s,%s\n",frn,fr1);
 	cmpreg = CMP_C1T;
@@ -3055,14 +3076,14 @@
     }
 }
 
-static
+static void
 longlong_lib(char *opc,int reg,int e1)
 {
     use_longlong(reg);
     code_save_stacks();
     clear_ptr_cache();
-    if (reg!=REG_LREGISTER) {
-      lmove(REG_LREGISTER,reg);
+    if (reg!=LREGISTER_OPERAND) {
+      lmove(LREGISTER_OPERAND,reg);
     }
     if (e1!=-1) {
       if (regv_h(e1)!=6) {
@@ -3078,11 +3099,11 @@
     if (max_func_iargs<16) max_func_iargs=16;
 }
 
-static
+static void
 double_lib(char *opc,int reg,int e1)
 {
     longlong_lib(opc,reg,e1);
-    regv[reg]=USING_DREG;
+    set_double(reg);
 }
 
 void
@@ -3090,6 +3111,7 @@
 { 
     char *opn="";
     char *opc="";
+    char *grn,*frn;
     int d;
     int cmp;
 
@@ -3192,7 +3214,7 @@
 }   
 
 static void
-double_lib_c(char *opc,double value);
+double_lib_c(char *opc,double value)
 {
       extern_define(opc,0,FUNCTION,1);
       if (max_func_iargs<16) max_func_iargs=16;
@@ -3204,9 +3226,9 @@
 code_dpreinc(int e1,int e2,int d,int reg) {
     char *frn;
     char *crn;
-    int  g;
-    char *grn,*drn;
-    int r;
+    char *xrn;
+    int  g,xreg;
+    char *grn;
     int dir=caddr(e1);
 
     if (!d) {
@@ -3252,7 +3274,7 @@
       code_save_stacks();
       clear_ptr_cache();
       set_dreg(RET_DREGISTER,0);
-      xreg = emit_pop_regvar(0);
+      xreg = emit_dpop_regvar(0);
       xrn = register_name(xreg);
       printf("\tlw $4,%d(%s)\n",SIZE_OF_INT,xrn);
       printf("\tlw $5,0(%s)\n",xrn);
@@ -3263,7 +3285,7 @@
 	printf("\tlw %s,0(%s)\n",lregister_name_low(reg),xrn);
       }
       printf("\tsw $2,%d(%s)\n",SIZE_OF_INT,xrn);
-      printf("\tsw %3,0(%s)\n",xrn);
+      printf("\tsw $3,0(%s)\n",xrn);
       emit_pop_free(xreg);
     }
 }
@@ -3272,8 +3294,8 @@
 code_dpostinc(int e1,int e2,int d,int reg) {
     char *frn;
     char *crn;
-    int  g;
-    char *grn,*drn;
+    int  g,xreg;
+    char *grn,*xrn;
     int dir=caddr(e1);
 
     if (!d) {
@@ -3295,9 +3317,9 @@
 	printf("\t%s %s,%s,%s\n",(dir>0)?"add.s":"sub.s",frn,crn,grn);
 	printf("\tmov.s %s,%s\n",frn,crn);
     } else {
-	printf("\tl.s %s,0(%s)\n",fload(d),frn,crn);
+	printf("\tl.s %s,0(%s)\n",frn,crn);
 	printf("\t%s %s,%s,%s\n",(dir>0)?"add.s":"sub.s",grn,frn,grn);
-	printf("\ts.s %s,0(%s)\n",fstore(d),grn,crn);
+	printf("\ts.s %s,0(%s)\n",grn,crn);
     }
     free_register(g);
     } else {
@@ -3321,13 +3343,13 @@
       code_save_stacks();
       clear_ptr_cache();
       set_dreg(RET_LREGISTER,0);
-      xreg = emit_pop_regvar(0);
+      xreg = emit_dpop_regvar(0);
       xrn = register_name(xreg);
       printf("\tlw $4,%d(%s)\n",SIZE_OF_INT,xrn);
       printf("\tlw $5,0(%s)\n",xrn);
       double_lib_c(dir>0?"dpadd":"dpsub",1.0);
       printf("\tsw $2,%d(%s)\n",SIZE_OF_INT,xrn);
-      printf("\tsw %3,0(%s)\n",xrn);
+      printf("\tsw $3,0(%s)\n",xrn);
       emit_pop_free(xreg);
       if (use) {
 	printf("\tlw %s,%d(%s)\n",lregister_name_high(reg),SIZE_OF_INT,xrn);
@@ -3339,7 +3361,6 @@
 void
 drexpr(int e1, int e2,int l1, int op,int cond)
 {
-    int dop;
     if (!cond) {
 	switch(op) {
 	    case FOP+GT:
@@ -3360,7 +3381,6 @@
 		op=DOP+EQ; break;
 	}
     }
-    dop>FOP?FOP:DOP;
     switch(op) {
     case FOP+GT: op=FOP+CMP; break;
     case DOP+GT: op=DOP+CMP; break;
@@ -3398,17 +3418,18 @@
     return xreg;
 }
 
+static
 int emit_dpop_regvar(int d)
 { 
     int xreg,reg;
     xreg=pop_fregister();
-    reg = cadr(get_dregister_var(d));
+    reg = cadr(get_dregister_var(0,d));
     if (xreg<= -REG_LVAR_OFFSET) {
         code_drlvar(REG_LVAR_OFFSET+xreg,1,reg);
 	free_lvar(REG_LVAR_OFFSET+xreg);
 	xreg=reg;
     } else {
-        code_dassign_register(reg,d,xreg);
+        code_dassign_dregister(reg,d,xreg);
     }
     return xreg;
 }
@@ -3672,7 +3693,7 @@
     printf("\tsubu %s,$0,%s\n",dl,rl);
     printf("\tsubu %s,$0,%s\n",dh,rh);
     printf("\tsltu %s,$0,%s\n",rl,dl);
-    printf("\tsubu %s,%s,%s\n",dh,dh);
+    printf("\tsubu %s,%s,%s\n",dh,dh,rl);
     free_register(lreg);
     set_lreg(dreg,0);
 }
@@ -3731,7 +3752,7 @@
     printf("\tbeq     %s,$0,2f\n",dh);
     printf("\tsll     %s,%s,%s\n",oh,ch,ol);
     printf("\t.set    reorder\n");
-    printf("\tsubu    %s,%s,%s\n",dh,ol);
+    printf("\tsubu    %s,$0,%s\n",dh,ol);
     printf("\tsrl     %s,%s,%s\n",dh,cl,dh);
     printf("\tor      %s,%s,%s\n",oh,oh,dh);
     printf("\t2:\n");
@@ -3863,6 +3884,7 @@
     int dx = -1;
     char *orn_h,*crn_h,*drn_h;
     char *orn_l,*crn_l,*drn_l;
+    char *drn;
     // creg = creg op oreg
 
     use_longlong(reg);
@@ -4006,9 +4028,9 @@
 {
     char *crn_h;
     char *crn_l;
-    char *grn;
+    char *grn,*drn;
     int v;
-    int greg;
+    int greg,dx=-1;
 
     use_longlong(creg);
     crn_h = lregister_name_high(creg);
@@ -4035,7 +4057,7 @@
 	grn = register_name(greg);
 	printf("\tsrl %s,%s,%d\n",grn,crn_l,v);
 	printf("\tsll %s,%s,%d\n",grn,crn_h,32-v);
-	printf("\tor  %s,%s,%d\n",grn,grn,grn);
+	printf("\tor  %s,%s,%s\n",grn,grn,grn);
 	printf("\tsra %s,%s,%d\n",crn_h,crn_h,v);
 	free_register(greg);
 	return;
@@ -4237,7 +4259,7 @@
 
 #endif
 
-static char *
+static void
 ladd(int dreg,int dir)
 {
   int xreg;
@@ -4245,14 +4267,14 @@
   char *dh=lregister_name_high(dreg);
   char *xrn=register_name(xreg=get_register());
   if (dir>0) {
-    printf("\tsltu %s,%s,1\n", xrn,dl,dir);
+    printf("\tsltu %s,%s,1\n", xrn,dl);
     printf("\taddu %s,%s,%d\n", dl,dl,dir);
-    printf("\taddu %s,%s,%d\n", dh,dh,xrn);
+    printf("\taddu %s,%s,%s\n", dh,dh,xrn);
   } else {
-    printf("\tsltu %s,%s,1\n", xrn,dl,-dir);
-    printf("\tsubu %s,%s,%d\n", dl,dl,dir);
+    printf("\tsltu %s,%s,1\n", xrn,dl);
+    printf("\tsubu %s,%s,%d\n", dl,dl,-dir);
     printf("\tsubu %s,%s,1\n", dh,dh);
-    printf("\taddu %s,%s,%d\n", dh,dh,xrn);
+    printf("\taddu %s,%s,%s\n", dh,dh,xrn);
   }
   free_register(xreg);
 }
--- a/mc.h	Tue May 11 01:41:14 2004 +0900
+++ b/mc.h	Tue May 11 02:26:10 2004 +0900
@@ -250,6 +250,7 @@
 
 #define DASS	(DOP+ASS)
 #define DCMPGE	(DOP+CMPGE)
+#define DCMPEQ	(DOP+CMPEQ)
 #define DASSOP	(DOP+ASSOP)
 #define DCMP	(DOP+CMP)
 #define DMINUS	(DOP+MINUS)
@@ -260,6 +261,7 @@
 
 #define FASS	(FOP+ASS)
 #define FCMPGE	(FOP+CMPGE)
+#define FCMPEQ	(FOP+CMPEQ)
 #define FASSOP	(FOP+ASSOP)
 #define FCMP	(FOP+CMP)
 #define FMINUS	(FOP+MINUS)