changeset 116:b14ff9671c90 self-compile-passed

register offset fix
author kono
date Fri, 21 Mar 2003 04:41:02 +0900
parents ebac635814dc
children 2d5a203cc3a6
files .gdbinit Changes mc-code-ia32.c mc-code-powerpc.c mc-code.h mc-codegen.c mc-parse.c stdio.h test/int.c
diffstat 9 files changed, 210 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Thu Mar 20 15:11:50 2003 +0900
+++ b/.gdbinit	Fri Mar 21 04:41:02 2003 +0900
@@ -1,13 +1,26 @@
 tb main
-r -s mc-code-powerpc.c
+r -s mc-parse.c
 define regs 
-printf "lr =%08x pc =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$lr,$pc,$r0,$r1,$r3,$r4
+printf "pc =%08x lr =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$pc,$lr,$r0,$r1,$r3,$r4
 printf "r10=%08x r11=%08x r12=%08x r13=%08x r14=%08x r15=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15
 end
 define fregs 
 printf "f1=%g f2=%g f3=%g f4=%g f5=%g f6=%g\n",$f1,$f2,$f3,$f4,$f5,$f6
 printf "f10=%g f11=%g f12=%g f13=%g f14=%g f15=%g\n",$f10,$f11,$f12,$f13,$f14,$f15
 end
+define allreg
+printf "pc =%08x lr =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$pc,$lr,$r0,$r1,$r3,$r4
+printf "r5=%08x r6=%08x r7=%08x r8=%08x r9=%08x\n",$r5,$r6,$r7,$r8,$r9
+printf "r10=%08x r11=%08x r12=%08x r13=%08x r14=%08x r15=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15
+printf "r16=%08x r17=%08x r18=%08x r19=%08x r20=%08x r21=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15
+printf "f1=%g f2=%g f3=%g f4=%g f5=%g f6=%g\n",$f1,$f2,$f3,$f4,$f5,$f6
+printf "f10=%g f11=%g f12=%g f13=%g f14=%g f15=%g\n",$f10,$f11,$f12,$f13,$f14,$f15
+printf "f20=%g f21=%g f22=%g f23=%g f24=%g f25=%g\n",$f20,$f21,$f22,$f23,$f24,$f25
+end
+define sh
+regs
+x/20i $pc-36
+end
 define si
 stepi
 regs
--- a/Changes	Thu Mar 20 15:11:50 2003 +0900
+++ b/Changes	Fri Mar 21 04:41:02 2003 +0900
@@ -2362,4 +2362,25 @@
 大きくないとダメなのか。
 
  
-
+Thu Mar 20 23:43:42 JST 2003
+
+ようやっと、self compile が通りそう。register save 系が
+やっぱり難しいみたいだね。dynamic loader を壊したりするし。
+
+あとmodがおかしいみたいで、hashの値が違うらしい。マイナスの値
+になるunsignedのかけ算ねぇ。int.c のrecursionが通らない。
+まだ、offset がおかしいらしい。
+
+macro のバグもとれたし。
+
+一応は、self compile は通りました。
+
+Fri Mar 21 03:18:26 JST 2003
+
+やっぱり、r1 と x(r30) の計算が合わない。きっと、
+呼出側で、引数の分のoffset を用意しているのだろう。
+だから、どれくらいの引数の関数を呼び出したかという
+値がいるのではないか?
+
+
+
--- a/mc-code-ia32.c	Thu Mar 20 15:11:50 2003 +0900
+++ b/mc-code-ia32.c	Fri Mar 21 04:41:02 2003 +0900
@@ -664,7 +664,7 @@
 
 
 void
-code_bool(int e1,int creg) {
+code_bool(int e1) {
     char *xrn;
     int e2,e3;
     b_expr(e1,1,e2=fwdlabel(),1);  /* including > < ... */
--- a/mc-code-powerpc.c	Thu Mar 20 15:11:50 2003 +0900
+++ b/mc-code-powerpc.c	Fri Mar 21 04:41:02 2003 +0900
@@ -21,7 +21,17 @@
 
 static int code_disp_label;
 static int code_setup;
-static int func_disp_label;
+static int r1_offset_label;
+static int lvar_offset_label;
+
+static int reg_save;
+static int freg_save;
+
+int size_of_int = 4;
+int size_of_float = 4;
+int size_of_double = 8;
+int size_of_longlong = 8;
+int endian = 1;
 
 
 /*
@@ -50,29 +60,46 @@
      f0    return value etc.
      f1-r8  input register
      f24-f31 saved register variable
+
+                       <------r1_offset------------------------------>
+                                      <------------lvar_offset------->
+ r+  +------------+---+---------------+----------+--------------+----+    -
+      caller arg   xx   register save   local      callee arg     xx
+                          reg_save      disp       max_func_args*size_of_int
  */
-int arg_offset = 40;
-int disp_offset = -48;
-int func_disp_offset = -40;
+
+int arg_offset = 0;
+int disp_offset = 0;
+#define r1_offset 60 
+#define func_disp_offset (r1_offset-12)
 int code_disp_offset = 0;
 int jump_offset = 0;
 
-/*
-    printf(".set L_%d,%d\n",func_disp_label,
-	-(disp+func_disp_offset+disp_offset+reg_save));
-    lvar(int l)
-	if (fnptr->sc==CODE) { return l+code_disp_offset;
-	} else if (l<0) {      return l+disp_offset;
-	} else {               return l+arg_offset;
-	}
+int max_func_args;
+
+void
+code_offset_set()
+{
+    printf(".set L_%d,%d\n",lvar_offset_label,
+	-(disp-max_func_args*size_of_int-func_disp_offset));
+    printf(".set L_%d,%d\n",r1_offset_label,
+	-(disp-max_func_args*size_of_int+reg_save-r1_offset));
+    printf("## disp %d arg_offset=%d disp_offset=%d reg_save=%d\n",disp,arg_offset,disp_offset,reg_save); 
+}
 
- */
+int
+lvar(int l)
+{
+    if (fnptr->sc==CODE) {
+	return l+code_disp_offset;
+    } else if (l<0) {
+	return l+disp_offset;
+    } else {
+	return l+arg_offset;
+    }
+}
 
-int size_of_int = 4;
-int size_of_float = 4;
-int size_of_double = 8;
-int size_of_longlong = 8;
-int endian = 1;
+
 
 #define REG_fp   1
 #define REG_sp   30
@@ -586,8 +613,8 @@
 
 void
 code_lvar(int e2,int creg) {
-    printf("\tla %s,lo16(%d+L_%d)(r1)\n",register_name(creg),
-	e2,func_disp_label);
+    printf("\tla %s,lo16(%d+L_%d)(r30)\n",register_name(creg),
+	e2,lvar_offset_label);
     regv[creg]=1;
 }
 
@@ -602,15 +629,15 @@
 
 void
 code_rlvar(int e2,int reg) {
-    printf("\tlwz %s,lo16(%d+L_%d)(r1)\n",register_name(reg),
-	e2,func_disp_label);
+    printf("\tlwz %s,lo16(%d+L_%d)(r30)\n",register_name(reg),
+	e2,lvar_offset_label);
     regv[creg]=1;
 }
 
 
 void
 code_crlvar(int e2,int reg) {
-    printf("\tlbz %s,lo16(%d+L_%d)(r1)\n",register_name(reg),e2,func_disp_label);
+    printf("\tlbz %s,lo16(%d+L_%d)(r30)\n",register_name(reg),e2,lvar_offset_label);
     printf("\textsb %s,%s\n",register_name(reg),register_name(reg));
     regv[reg]=1;
 }
@@ -842,7 +869,7 @@
 
 
 void
-code_bool(int e1,int creg) {
+code_bool(int e1) {
     char *xrn;
     int e2,e3;
     b_expr(e1,1,e2=fwdlabel(),1);  /* including > < ... */
@@ -893,7 +920,7 @@
 void
 code_cmp_crlvar(int e1) {
     char *crn = register_name(creg);
-    printf("\tlbz %s,lo16(%d+L_%d)(r1)\n",crn,e1,func_disp_label);
+    printf("\tlbz %s,lo16(%d+L_%d)(r30)\n",crn,e1,lvar_offset_label);
     code_cmp_register(creg);
     regv[creg]=0;
 }
@@ -913,7 +940,7 @@
 void
 code_cmp_rlvar(int e1) {
     char *crn = register_name(creg);
-    printf("\tlwz %s,lo16(%d+L_%d)(r1)\n",crn,e1,func_disp_label);
+    printf("\tlwz %s,lo16(%d+L_%d)(r30)\n",crn,e1,lvar_offset_label);
     code_cmp_register(creg);
     regv[creg]=0;
 }
@@ -934,6 +961,8 @@
 	    printf("%cn",92);
 	else if (*s<' ')
 	    printf("%c%03o",92,*s);
+	else if (*s=='\\')
+	    printf("\\\\");
 	else if (*s==34)
 	    printf("%c%c",92,34);
 	else 
@@ -1101,9 +1130,9 @@
 use_var(int arg)
 {
     if (car(arg)==REGISTER)
-	regs[arg]=USING_REG;
+	regs[cadr(arg)]=USING_REG;
     else if (car(arg)==DREGISTER)
-	fregs[arg]=USING_REG;
+	fregs[cadr(arg)]=USING_REG;
 }
 
 void
@@ -1177,7 +1206,9 @@
 	jmp = get_register_var(0);
 	if (car(jmp)!=REGISTER) error(-1);
 	reg_arg_list = list2(jmp,reg_arg_list);
-	g_expr(assign_expr0(jmp,e2,INT,INT));
+	g_expr(e2);
+	code_register(creg,cadr(jmp));
+        /* g_expr(assign_expr0(jmp,e2,INT,INT)); functions are lvalue */
     }
 
     /* now all input register vars are free */
@@ -1192,7 +1223,7 @@
 	if(scalar(t)) {
 	    if (reg_arg>MAX_INPUT_REGISTER_VAR) { 
 		arg = list2(LVAR,arg_offset_v(nargs));
-	    } else if (!simple_args(e3)) {
+	    } else if (!simple_args(e3) && cadr(e3)) {
 		arg = get_register_var(0); 
 		arg_assign = list2(
 		    assign_expr0(get_input_register_var(reg_arg,0),arg,t,t),
@@ -1250,6 +1281,7 @@
 	}
 	++nargs;
     }
+    if (max_func_args<nargs) max_func_args=nargs;
     for(;arg_assign;arg_assign=cadr(arg_assign)) {
 	g_expr_u(car(arg_assign));
     }
@@ -1286,7 +1318,7 @@
 
 void
 code_fix_frame_pointer(int disp_offset) {
-    printf("\tla r1,%d(r1)\n",disp_offset);
+    printf("\tla r1,%d(r30)\n",disp_offset);
 }
 
 void
@@ -1345,9 +1377,9 @@
     char *crn;
     crn=register_name(creg);
     if (byte) {
-	printf("\tstb %s,lo16(%d+L_%d)(r1)\n",crn,e2,func_disp_label);
+	printf("\tstb %s,lo16(%d+L_%d)(r30)\n",crn,e2,lvar_offset_label);
     } else {
-	printf("\tstw %s,lo16(%d+L_%d)(r1)\n",crn,e2,func_disp_label);
+	printf("\tstw %s,lo16(%d+L_%d)(r30)\n",crn,e2,lvar_offset_label);
     }
 }
 
@@ -1454,6 +1486,8 @@
 	printf("\tor %s,%s,%s\n",crn,crn,orn);
 	break;
     case MUL:
+	printf("\tmullw %s,%s,%s\n",crn,crn,orn);
+	break;
     case UMUL:
 	printf("\tmullw %s,%s,%s\n",crn,crn,orn);
 	break;
@@ -1466,17 +1500,17 @@
     case MOD:
 	dx=get_register();
 	drn = register_name(dx);
-	printf("\tdivwu %s,%s,%s\n",drn,crn,orn);
-	printf("\tmullw %s,%s,%s\n",drn,drn,crn);
-	printf("\tsubf %s,%s,%s\n",crn,drn,orn);
+	printf("\tdivw %s,%s,%s\n",drn,crn,orn);
+	printf("\tmullw %s,%s,%s\n",drn,drn,orn);
+	printf("\tsubf %s,%s,%s\n",crn,drn,crn);
 	free_register(dx);
 	break;
     case UMOD:
 	dx=get_register();
 	drn = register_name(dx);
 	printf("\tdivwu %s,%s,%s\n",drn,crn,orn);
-	printf("\tmullw %s,%s,%s\n",drn,drn,crn);
-	printf("\tsubf %s,%s,%s\n",crn,drn,orn);
+	printf("\tmullw %s,%s,%s\n",drn,drn,orn);
+	printf("\tsubf %s,%s,%s\n",crn,drn,crn);
 	free_register(dx);
 	break;
     default:
@@ -1576,7 +1610,7 @@
  */
     printf("_%s:\n",name);
     code_disp_label=fwdlabel();
-    printf("\tla r30,L_%d(r1)\n",code_disp_label);
+    printf("\tla r30,L_%d(r30)\n",code_disp_label);
 }
 
 
@@ -1618,10 +1652,12 @@
     printf("\tbl L_%d\n",code_setup);
     code_base=fwdlabel();
     fwddef(code_base);
-    func_disp_label = fwdlabel();
-    printf("\tstwu r1,lo16(-L_%d)(r1)\n",func_disp_label);
+    r1_offset_label = fwdlabel();
+    lvar_offset_label = fwdlabel();
+    printf("\tstwu r1,lo16(-L_%d)(r1)\n",r1_offset_label);
     printf("\tmr r30,r1\n");
     printf("\tmflr r31\n");
+    max_func_args = 0;
 }
 
 void
@@ -1635,7 +1671,7 @@
 reg_save_offset()
 {
     return -(
-	(REAL_MAX_REGISTER-(REG_VAR_BASE-max_reg_var))*size_of_int*2+
+	(REAL_MAX_REGISTER-(REG_VAR_BASE-max_reg_var))*size_of_int+
 	(REAL_MAX_FREGISTER-(FREG_VAR_BASE-max_freg_var))*size_of_double
 	);
 }
@@ -1643,8 +1679,6 @@
 void
 leave(int control, char *name)
 {
-    int reg_save;
-    int freg_save;
 
     if (control) {
 	code_set_return_register(1);
@@ -1652,6 +1686,7 @@
     if (retcont) fwddef(retcont);
     fwddef(retlabel);
     printf("\tlwz r1,0(r1)\n");
+    if (max_freg_var>=0 && max_freg_var<=3) max_freg_var=3; 
     reg_save = reg_save_offset();
     if (max_freg_var>=0) {
 	printf("\tlmw r%d,%d(r1)\n",
@@ -1664,14 +1699,14 @@
 	printf("\tlwz r0,8(r1)\n");
 	printf("\tmtlr r0\n");
 	printf("\tlmw r%d,%d(r1)\n",
-		    REG_VAR_BASE-max_reg_var,reg_save_offset());
+		    REG_VAR_BASE-max_reg_var,reg_save);
 	printf("\tblr\n");
     }
 
     disp &= -size_of_int;
     fwddef(code_setup);
     printf("\tstmw r%d,%d(r1)\n",
-		    REG_VAR_BASE-max_reg_var,reg_save_offset());
+		    REG_VAR_BASE-max_reg_var,reg_save);
     printf("\tstw r0,8(r1)\n");
     if (max_freg_var>=0)
 	printf("\tb saveFP+%d ; save f%d-f31\n",
@@ -1681,13 +1716,7 @@
 	printf("\tblr\n");
     }
 
-    printf("## disp %d arg_offset=%d disp_offset=%d reg_save=%d\n",disp,arg_offset,disp_offset,reg_save); 
-    printf(".set L_%d,%d\n",func_disp_label,
-	-(disp+func_disp_offset+disp_offset+reg_save));
-/*
-    printf("L_%d:\n",labelno);
-    printf("\t.size\t%s,L_%d-%s\n",name,labelno,name);
- */
+    code_offset_set();
     local_table();
     labelno++;
     free_all_register();
@@ -1783,11 +1812,11 @@
     } else if(t!=CHAR) {       
 	gpc += size_of_int;
 	if(car(e)==ADDRESS&&car(cadr(e))==GVAR) {
-	    printf("\t.long %s\n",((NMTBL *)cadr(cadr(e)))->nm);
+	    printf("\t.long _%s\n",((NMTBL *)cadr(cadr(e)))->nm);
 	} else if(car(e)==FNAME) {
-	    printf("\t.long %s\n",((NMTBL *)cadr(e))->nm);
+	    printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm);
 	} else if(car(e)==GVAR) {
-	    printf("\t.long %s\n",((NMTBL *)cadr(e))->nm);
+	    printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm);
 	} else if(car(e)==STRING) {       
 	    if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) {
 		l = fwdlabel();
@@ -1879,11 +1908,12 @@
 		data_mode(0);
 		init=1;
 	    }
-printf("L_%s$non_lazy_ptr:\n\t.long\t_%s\n\n",n->nm,n->nm);
+printf("L_%s$non_lazy_ptr:\n\t.long\t_%s\n",n->nm,n->nm);
 	}
     }
     init = 0;
     for(n=ntable;n < &ntable[GSYMS];n++) {
+	if (is_code(n)||is_function(n)) continue;
 	if (n->sc==EXTRN1) {
 	    if(init==0) {
 		data_mode(0);
@@ -1938,18 +1968,6 @@
  */
 }
 
-int
-lvar(int l)
-{
-    if (fnptr->sc==CODE) {
-	return l+code_disp_offset;
-    } else if (l<0) {
-	return l+disp_offset;
-    } else {
-	return l+arg_offset;
-    }
-}
-
 /* floating point */
 
 static int float_one_lib_used=0;
@@ -2024,8 +2042,8 @@
 
 void code_dassign_lvar(int e2,int freg,int d)
 { 
-    printf("\t%s %s,lo16(%d+L_%d)(r1)\n",fstore(d),fregister_name(freg),
-	e2,func_disp_label);
+    printf("\t%s %s,lo16(%d+L_%d)(r30)\n",fstore(d),fregister_name(freg),
+	e2,lvar_offset_label);
     fregv[freg]=1;
 }
 
@@ -2108,9 +2126,9 @@
     int d = new_lvar(size_of_double);
     d = lvar(d);
     printf("\tfctiwz  %s,%s\n",frn,frn);
-    printf("\tstfd  %s,lo16(%d+L_%d)(r1)\n",frn,d,func_disp_label);
-    printf("\tlwz %s,lo16(%d+L_%d)(r1)\n",crn,
-	d+size_of_double-size_of_int,func_disp_label);
+    printf("\tstfd  %s,lo16(%d+L_%d)(r30)\n",frn,d,lvar_offset_label);
+    printf("\tlwz %s,lo16(%d+L_%d)(r30)\n",crn,
+	d+size_of_double-size_of_int,lvar_offset_label);
     fregs[freg]=0;
     regs[creg]=1;
 }
@@ -2132,10 +2150,10 @@
 "        mflr r10",
 "        mtlr r0",
 "        xoris r3,r3,0x8000",
-"        stw r3,-28(r1)",
+"        stw r3,-28(r30)",
 "        lis r0,0x4330",
-"        stw r0,-32(r1)",
-"        lfd f0,-32(r1)",
+"        stw r0,-32(r30)",
+"        lfd f0,-32(r30)",
 "        addis r9,r10,ha16(__i2dLC0-__i2dL1$pb)",
 "        lfd f1,lo16(__i2dLC0-__i2dL1$pb)(r9)",
 "        fsub f1,f0,f1",
@@ -2176,16 +2194,16 @@
 "        cror 2,1,2",
 "        beq- cr0,__d2uL2",
 "        fctiwz f0,f1",
-"        stfd f0,-32(r1)",
-"        lwz r3,-28(r1)",
+"        stfd f0,-32(r30)",
+"        lwz r3,-28(r30)",
 "        blr",
 "__d2uL2:",
 "        addis r9,r10,ha16(__d2uLC0-__d2uL1$pb)",
 "        lfd f0,lo16(__d2uLC0-__d2uL1$pb)(r9)",
 "        fsub f0,f1,f0",
 "        fctiwz f0,f0",
-"        stfd f0,-24(r1)",
-"        lwz r3,-20(r1)",
+"        stfd f0,-24(r30)",
+"        lwz r3,-20(r30)",
 "        xoris r3,r3,0x8000",
 "        blr",
 0
@@ -2219,10 +2237,10 @@
 "__u2dL2$pb:",
 "        mflr r10",
 "        mtlr r0",
-"        stw r3,-28(r1)",
+"        stw r3,-28(r30)",
 "        lis r0,0x4330",
-"        stw r0,-32(r1)",
-"        lfd f0,-32(r1)",
+"        stw r0,-32(r30)",
+"        lfd f0,-32(r30)",
 "        addis r9,r10,ha16(__u2dLC1-__u2dL2$pb)",
 "        lfd f1,lo16(__u2dLC1-__u2dL2$pb)(r9)",
 "        fsub f1,f0,f1",
@@ -2258,8 +2276,8 @@
 
 void code_drlvar(int e2,int d,int freg)
 { 
-    printf("\t%s %s,lo16(%d+L_%d)(r1)\n",fload(d),fregister_name(freg),
-	e2,func_disp_label);
+    printf("\t%s %s,lo16(%d+L_%d)(r30)\n",fload(d),fregister_name(freg),
+	e2,lvar_offset_label);
     fregv[freg]=1;
 }
 
@@ -2282,8 +2300,8 @@
     int g=get_fregister();
     char *grn=fregister_name(g);
 
-    printf("\t%s %s,lo16(%d+L_%d)(r1)\n",fload(1),grn,
-	e2,func_disp_label);
+    printf("\t%s %s,lo16(%d+L_%d)(r30)\n",fload(1),grn,
+	e2,lvar_offset_label);
     printf("\tfcmpu cr0,%s,%s\n",frn,grn);
     free_fregister(g);
     fregv[freg]=0;
--- a/mc-code.h	Thu Mar 20 15:11:50 2003 +0900
+++ b/mc-code.h	Fri Mar 21 04:41:02 2003 +0900
@@ -51,7 +51,7 @@
 extern void code_cpredec(int e1,int e2,int reg);
 extern void code_return(int reg);
 extern void code_environment(int reg);
-extern void code_bool(int e1,int reg);
+extern void code_bool(int e1);
 extern char *code_gt(int cond);
 extern char *code_ugt(int cond);
 extern char *code_ge(int cond);
--- a/mc-codegen.c	Thu Mar 20 15:11:50 2003 +0900
+++ b/mc-codegen.c	Fri Mar 21 04:41:02 2003 +0900
@@ -279,7 +279,7 @@
 	code_environment(creg);
 	return ADDRESS;
     default:
-	code_bool(e1,creg); /* type? */
+	code_bool(e1); /* type? */
 	return INT;
     }
 }
--- a/mc-parse.c	Thu Mar 20 15:11:50 2003 +0900
+++ b/mc-parse.c	Fri Mar 21 04:41:02 2003 +0900
@@ -339,8 +339,6 @@
 #endif
 }
 
-#define abs0(a) (a>0?a:-a)
-
 static void
 reserve(char *s, int d)
 {
@@ -349,9 +347,8 @@
 
     hash=0; name=namebuf; i=0;
     while((name[i++] = *s)) {
-	hash=((7*hash) ^ *s++);
+	hash=(((7*hash)&0xfffffff) ^ *s++);
     }
-    hash = abs0(hash);
     if (cheapp+i >= cheap+CHEAPSIZE) error(STRERR);
     name[i++] = 0;
     (nptr = gsearch())->sc = RESERVE;
@@ -2830,11 +2827,11 @@
 	name = namebuf;
 	while (alpha(ch) || digit(ch)) {
 	    if (i < LBUFSIZE-1)
-		hash=(7*hash ^ (name[i++]=ch));
+		hash=(((7*hash)&0xfffffff) ^ (name[i++]=ch));
 	    getch();
 	}
-	hash = abs0(hash);
 	name[i++] = '\0';
+/* printf("# hash %u %s\n",hash,name); */
 
 	nptrm=msearch(name);
 	if (mode==MDECL) {
@@ -3148,9 +3145,8 @@
 
     i = 0; hash = 0;
     while((name[i])) {
-	hash=((7*hash) ^ name[i++]);
+	hash=(((7*hash)&0xfffffff) ^ (name[i++]));
     }
-    hash = abs0(hash);
     iptr=nptr= &mtable[hash%MSYMS];
     while(nptr->sc!=0 && neqname(nptr->nm,name)) {
 	if (++nptr== &mtable[MSYMS])
@@ -3260,6 +3256,8 @@
 	    return '\r';
 	case 'f':
 	    return '\f';
+	case '\\':
+	    return '\\';
 	case '\n':
 	    return escape();
 	default:
@@ -3433,9 +3431,8 @@
 
     hash=0; name=namebuf; i=0;
     while((name[i++] = *s)) {
-        hash=((7*hash) ^ *s++);
+	hash=(((7*hash)&0xfffffff) ^ (*s));
     }
-    hash = abs0(hash);
     if (cheapp+i >= cheap+CHEAPSIZE) error(STRERR);
     name[i++] = 0;
     (nptr0 = gsearch())->sc = EXTRN;
--- a/stdio.h	Thu Mar 20 15:11:50 2003 +0900
+++ b/stdio.h	Fri Mar 21 04:41:02 2003 +0900
@@ -2,19 +2,23 @@
 #include "/usr/include/stdio.h"
 #else
 
-typedef	struct {
-	/* this is all wrong, but so what? */
-	/* char	pad[96];	 */
-	char	pad[148];	
-} FILE;
 #ifdef __APPLE__
 
+typedef	struct {
+	/* char	pad[96];	 */
+	char	pad[88];	
+} FILE;
 extern FILE __sF[];
 #define stdin   (&__sF[0])
 #define stdout  (&__sF[1])
 #define stderr  (&__sF[2])
 
 #else
+typedef	struct {
+	/* this is all wrong, but so what? */
+	/* char	pad[96];	 */
+	char	pad[148];	
+} FILE;
 #ifdef bsd
 extern FILE __sstdin;
 extern FILE __sstdout;
--- a/test/int.c	Thu Mar 20 15:11:50 2003 +0900
+++ b/test/int.c	Fri Mar 21 04:41:02 2003 +0900
@@ -40,11 +40,13 @@
    int i;
    unsigned u;
    unsigned d00 = ac?-30:ac;
+   unsigned d01 = 0x3ffffff;
+   unsigned d02 = 0x300;
 
    printf("%d %f %d %f\n",1,0.1,1,0.1);
    printf("%f %d %f %d\n",0.1,1,0.1,1);
 
-   printf("%ud\n",d00);
+   printf("%u %u %u\n",d00,d01%d02,d01*d02);
 
    g = 1;
    g = -g;
@@ -87,6 +89,7 @@
 
    test1();
    printf("nested call: %d\n",test2(test2(test2(test2(-333,3),5),6),7));
+   /* test3(40,20); */
    return 0;
 }
 
@@ -150,6 +153,21 @@
     g = testd(g,g1);
     printf("%d:%d\t",n++,g);
     printf("\n");
+    g = g+g;
+
+    g = 3.0;
+    printf("%d:%d\t",n++,g);
+    g1 = g<<g;
+    printf("%d:%d\t",n++,g1);
+    g = g%g1;
+    printf("%d:%d\t",n++,g);
+    g = g|g1;
+    printf("%d:%d\t",n++,g);
+    g = g&g1;
+    printf("%d:%d\t",n++,g);
+    g = g^g1;
+    printf("%d:%d\t",n++,g);
+    printf("\n");
 
     printf("simple unsigned ");
     f = f+f;
@@ -164,6 +182,21 @@
     printf("%d:%d\t",n++,f);
     printf("\n");
 
+    f = 3.0;
+    printf("%d:%d\t",n++,f);
+    f1 = f<<f;
+    printf("%d:%d\t",n++,f1);
+    f = f%f1;
+    printf("%d:%d\t",n++,f);
+    f = f|f1;
+    printf("%d:%d\t",n++,f);
+    f = f&f1;
+    printf("%d:%d\t",n++,f);
+    f = f^f1;
+    printf("%d:%d\t",n++,f);
+    printf("\n");
+
+
     printf("post/pre increment ");
     g1 = g;
     printf("%d:%d\t",n++,g1++ - ++g);
@@ -314,10 +347,23 @@
     int g,h;
   
     if (i<=0) return f;
-#if 1
+#if 0
     printf("rec: %d %d\n",i,f);
 #endif
     g =  f*2;
     h =  f-3.5;
     return h/3-(3.0-(g+3)*test2(f*1.5,i-1)/(h-1));
 }
+
+int
+test3(int base,int base1)
+{
+    int i,j;
+    for(i=0;i<10;i++) {
+	for(j=0;j<10;j++) {
+	    printf("%d ",(base+i)%(base1+j));
+	}
+	printf("\n");
+    }
+    return 0;
+}