DEADSOFTWARE

JVM: Добавлено сравнение строк
[dsw-obn.git] / rtl / SYSTEM.java
index f98236bd90926eeb0ca4d8dd58c46e190e43cd8e..68f82bd0983c3ee348507e7903023dc63318cf8c 100644 (file)
@@ -17,19 +17,30 @@ public class SYSTEM
                return i;
        }
 
-       /* Встроенная процедура COPY(x, v) */
        public static void COPY(byte[] x, byte[] v)
        {
                int len_x = LEN(x);
                int len_v = v.length - 1;
+
                int len = (len_x < len_v) ? (len_x) : (len_v);
                for(int i = 0; i < len; i++)
                {
                        v[i] = x[i];
                }
+
                v[len] = 0;
        }
 
+       public static int STRCMP(byte[] a, byte[] b)
+       {
+               int i = 0;
+               while(a[i] != 0 && a[i] == b[i])
+               {
+                       i += 1;
+               }
+               return a[i] - b[i];
+       }
+
        public static void HALT(long n)
        {
                System.exit((int) n);
@@ -44,4 +55,20 @@ public class SYSTEM
        {
                assert x : n;
        }
+
+       public static void TRAP(long n)
+       {
+               if(n == -1)
+               {
+                       throw new RuntimeException("CASE TRAP");
+               }
+               else if(n == -2)
+               {
+                       throw new RuntimeException("WITH TRAP");
+               }
+               else
+               {
+                       throw new RuntimeException("TRAP CODE " + n);
+               }
+       }
 }