gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
mjc2wsl process div and rem, with error reporting
authorDoni Pracner <quinnuendo@gmail.com>
Tue, 26 Nov 2013 20:00:06 +0000 (21:00 +0100)
committerDoni Pracner <quinnuendo@gmail.com>
Tue, 26 Nov 2013 20:00:06 +0000 (21:00 +0100)
src/mjc2wsl.java

index c269f20ef53852419341bd77ad9fd374c888d976..86177134f1bd3cc9d6656c6afa286bd50c501b45 100644 (file)
@@ -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;
                        }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner