Skip to content

Commit

Permalink
Fix shift operations (#103)
Browse files Browse the repository at this point in the history
The negative value of the shift amount does not reverse the direction
of the shift operation.

Close #102
  • Loading branch information
vacantron authored Apr 16, 2023
1 parent 049302a commit 8406447
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions amacc.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,7 @@ void expr(int lev)
if (compound) { compound = 0; expr(Assign); }
else expr(Add);
if (*n == Num && *b == Num) {
if (n[1] < 0) n[1] = b[1] >> -n[1];
else n[1] = b[1] << n[1];
n[1] = b[1] << n[1];
} else { *--n = (int) b; *--n = Shl; }
ty = INT;
break;
Expand All @@ -840,8 +839,7 @@ void expr(int lev)
if (compound) { compound = 0; expr(Assign); }
else expr(Add);
if (*n == Num && *b == Num) {
if (n[1] < 0) n[1] = b[1] << -n[1];
else n[1] = b[1] >> n[1];
n[1] = b[1] >> n[1];
} else { *--n = (int) b; *--n = Shr; }
ty = INT;
break;
Expand Down

0 comments on commit 8406447

Please sign in to comment.