Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cowbe/arch8086.cow.ng
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,10 @@ gen al := REMU1(al, mem1|bl|cl|dl:rhs) { E("\txor ah, ah\n"); E_insn("di
gen al := DIVS1(al, mem1|bl|cl|dl:rhs) { E("\tcbw\n"); E_insn("idiv"); E_op0($rhs, &$@rhs.operand); E_nl(); }
gen al := REMS1(al, mem1|bl|cl|dl:rhs) { E("\tcbw\n"); E_insn("idiv"); E_op0($rhs, &$@rhs.operand); E_nl(); E("\tmov al, ah\n"); }

gen ax := DIVU2(ax, mem2|bx|cx|dx:rhs) uses dx { E("\txor dx, dx\n"); E_insn("div"); E_op0($rhs, &$@rhs.operand); E_nl(); }
gen dx := REMU2(ax, mem2|bx|cx|dx:rhs) { E("\txor dx, dx\n"); E_insn("div"); E_op0($rhs, &$@rhs.operand); E_nl(); }
gen ax := DIVS2(ax, mem2|bx|cx|dx:rhs) uses dx { E("\tcwd\n"); E_insn("idiv"); E_op0($rhs, &$@rhs.operand); E_nl(); }
gen dx := REMS2(ax, mem2|bx|cx|dx:rhs) { E("\tcwd\n"); E_insn("idiv"); E_op0($rhs, &$@rhs.operand); E_nl(); }
gen ax := DIVU2(ax, mem2|bx|cx|di|si:rhs) uses dx { E("\txor dx,dx\n"); E_insn("div"); E_op0($rhs, &$@rhs.operand); E_nl(); }
gen dx := REMU2(ax, mem2|bx|cx|di|si:rhs) { E("\txor dx,dx\n"); E_insn("div"); E_op0($rhs, &$@rhs.operand); E_nl(); }
gen ax := DIVS2(ax, mem2|bx|cx|di|si:rhs) uses dx { E("\tcwd\n"); E_insn("idiv"); E_op0($rhs, &$@rhs.operand); E_nl(); }
gen dx := REMS2(ax, mem2|bx|cx|di|si:rhs) { E("\tcwd\n"); E_insn("idiv"); E_op0($rhs, &$@rhs.operand); E_nl(); }

gen al|bl|dl := LSHIFT1($$:lhs, cl:rhs) { E_insn("shl"); E_reg($lhs); E(", cl\n"); }
gen ax|bx|dx|si|di := LSHIFT2($$:lhs, cl:rhs) { E_insn("shl"); E_reg($lhs); E(", cl\n"); }
Expand Down
4 changes: 4 additions & 0 deletions tests/divrem-16bit-s.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
-7/3=-2: yes
7/-3=-2: yes
-7/-3=2: yes
7/THREE=2: yes
-7/THREE=-2: yes
7/-THREE=-2: yes
-7/-THREE=2: yes
7%3=1: yes
-7%3=-1: yes
7%-3=1: yes
Expand Down
5 changes: 5 additions & 0 deletions tests/divrem-16bit-s.test.cow
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ print("-7/3=-2"); if mseven/three == -2 then yes(); else no(); end if;
print("7/-3=-2"); if seven/mthree == -2 then yes(); else no(); end if;
print("-7/-3=2"); if mseven/mthree == 2 then yes(); else no(); end if;

print("7/THREE=2");if (seven/3) == 2 then yes(); else no(); end if;
print("-7/THREE=-2");if (mseven/3) == -2 then yes(); else no(); end if;
print("7/-THREE=-2");if (seven/-3) == -2 then yes(); else no(); end if;
print("-7/-THREE=2");if (mseven/-3) == 2 then yes(); else no(); end if;

print("7%3=1"); if seven%three == 1 then yes(); else no(); end if;
print("-7%3=-1"); if mseven%three == -1 then yes(); else no(); end if;
print("7%-3=1"); if seven%mthree == 1 then yes(); else no(); end if;
Expand Down
Loading