Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SibSurfer committed Jun 2, 2024
1 parent 92626fd commit 1c97f9b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/X86.lama
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,18 @@ fun compile (env, code) {
case env.pop2 of [fst, snd, env] ->
case env.allocate of [t, env] ->
case opers(op) of
Regular -> [env, code <+ Binop (op, fst, snd) <+> move (snd, t)]
| Divide -> [env, code <+> move(snd, eax) <+ Cltd <+ IDiv (fst) <+> move (eax, t)]
| DivRemainder -> [env, code <+> move(snd, eax) <+ Cltd <+ IDiv (fst) <+> move (edx, t)]
| Comparison -> [env, code <+ Binop ("^", eax, eax) <+ Binop ("cmp", fst, snd) <+
Set (suffix (op), "%al") <+> move (eax, t)]
| Binary -> [env, code <+ Binop ("^", eax, eax) <+ Binop ("cmp", L (0), snd) <+
Set (suffix ("!="), "%al") <+> move (eax, t) <+ Binop ("^", eax, eax) <+
Binop ("cmp", L (0), fst) <+ Set (suffix ("!="), "%al") <+ Binop (op, eax, t)]
Regular -> [env, code <+> move(snd, eax) <+
Binop (op, fst, eax) <+> move (eax, t)]
| Divide -> [env, code <+> move(snd, eax) <+
Cltd <+ IDiv (fst) <+> move (eax, t)]
| DivRemainder -> [env, code <+> move(snd, eax) <+
Cltd <+ IDiv (fst) <+> move (edx, t)]
| Comparison -> [env, code <+ Binop ("^", eax, eax) <+> move(snd, edx) <+
Binop ("cmp", fst, edx) <+ Set (suffix (op), "%al") <+> move (eax, t)]
| Binary -> [env, code <+ Binop ("^", eax, eax) <+
Binop ("cmp", L (0), snd) <+ Set (suffix ("!="), "%al") <+> move (eax, t) <+
Binop ("^", eax, eax) <+ Binop ("cmp", L (0), fst) <+
Set (suffix ("!="), "%al") <+ Binop (op, eax, t)]
esac
esac
esac
Expand Down

0 comments on commit 1c97f9b

Please sign in to comment.