From 1df11af4aa88816abcb609d38793129e11ad983d Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Tue, 26 Nov 2013 21:00:06 +0100 Subject: [PATCH] mjc2wsl process div and rem, with error reporting --- src/mjc2wsl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; } -- 2.25.1