Permalink
Browse files

corrected error in -,/,%

  • Loading branch information...
1 parent 40c5f3b commit 9c22c6821ab044cad1429b26ba35900d0046a52a @vivekzhere committed Apr 28, 2012
Showing with 12 additions and 3 deletions.
  1. +12 −3 spsil.h
View
@@ -601,8 +601,11 @@ void codegen(struct tree * root)
}
else
{
+ fprintf(fp,"MOV T%d,%s\n",regcount,reg1);
+ regcount++;
codegen(root->ptr2);
- fprintf(fp,"SUB T%d,%s\n",regcount-1,reg1);
+ fprintf(fp,"SUB T%d,T%d\n",regcount-2,regcount-1);
+ regcount--;
}
}
else
@@ -665,8 +668,11 @@ void codegen(struct tree * root)
}
else
{
+ fprintf(fp,"MOV T%d,%s\n",regcount,reg1);
+ regcount++;
codegen(root->ptr2);
- fprintf(fp,"DIV T%d,%s\n",regcount-1,reg1);
+ fprintf(fp,"DIV T%d,T%d\n",regcount-2,regcount-1);
+ regcount--;
}
}
else
@@ -697,8 +703,11 @@ void codegen(struct tree * root)
}
else
{
+ fprintf(fp,"MOV T%d,%s\n",regcount,reg1);
+ regcount++;
codegen(root->ptr2);
- fprintf(fp,"MOD T%d,%s\n",regcount-1,reg1);
+ fprintf(fp,"MOD T%d,T%d\n",regcount-2,regcount-1);
+ regcount--;
}
}
else

0 comments on commit 9c22c68

Please sign in to comment.