Skip to content

Commit

Permalink
corrected error in -,/,%
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekzhere committed Apr 28, 2012
1 parent 40c5f3b commit 9c22c68
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions spsil.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -601,8 +601,11 @@ void codegen(struct tree * root)
} }
else else
{ {
fprintf(fp,"MOV T%d,%s\n",regcount,reg1);
regcount++;
codegen(root->ptr2); 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 else
Expand Down Expand Up @@ -665,8 +668,11 @@ void codegen(struct tree * root)
} }
else else
{ {
fprintf(fp,"MOV T%d,%s\n",regcount,reg1);
regcount++;
codegen(root->ptr2); 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 else
Expand Down Expand Up @@ -697,8 +703,11 @@ void codegen(struct tree * root)
} }
else else
{ {
fprintf(fp,"MOV T%d,%s\n",regcount,reg1);
regcount++;
codegen(root->ptr2); 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 else
Expand Down

0 comments on commit 9c22c68

Please sign in to comment.