From: Doni Pracner Date: Tue, 26 Nov 2013 20:00:06 +0000 (+0100) Subject: mjc2wsl process div and rem, with error reporting X-Git-Tag: v0.1.2~4 X-Git-Url: https://svarog.pmf.uns.ac.rs/gitweb/?a=commitdiff_plain;h=1df11af4aa88816abcb609d38793129e11ad983d;p=mjc2wsl.git mjc2wsl process div and rem, with error reporting --- diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java index c269f20..8617713 100644 --- a/src/mjc2wsl.java +++ b/src/mjc2wsl.java @@ -287,7 +287,15 @@ public class mjc2wsl{ } case div: { prl(getTopTwo()); - prl("tempres := tempb / tempa;"); + prl("IF tempa = 0 THEN ERROR(\"division by zero\") FI;"); + prl("tempres := tempb DIV tempa;"); + prl(cmdToEStack("tempres")); + break; + } + case rem: { + prl(getTopTwo()); + prl("IF tempa = 0 THEN ERROR(\"division by zero\") FI;"); + prl("tempres := tempb MOD tempa;"); prl(cmdToEStack("tempres")); break; }