DEADSOFTWARE

Исправлены VAR-параметры, добавлены модули Files и Strings
[dsw-obn.git] / rtl / SYSTEM.java
index 44e1cc321a594c4adb723c82b35c58b07dbe6e33..ce1b50621e447042154ad9d70dc11136278673ff 100644 (file)
@@ -17,16 +17,34 @@ public class SYSTEM
                return i;
        }
 
+       public static String STRING(byte[] x)
+       {
+               return new String(x, 0, LEN(x));
+       }
+
        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++)
+               int ix = LEN(x);
+               int iv = v.length - 1;
+
+               int i = 0;
+               int len = (ix < iv) ? (ix) : (iv);
+               while(i < len)
                {
                        v[i] = x[i];
+                       i += 1;
                }
-               v[len] = 0;
+               v[i] = 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)
@@ -54,6 +72,10 @@ public class SYSTEM
                {
                        throw new RuntimeException("WITH TRAP");
                }
+               else if(n == -3)
+               {
+                       throw new RuntimeException("NOT IMPLEMENTED");
+               }
                else
                {
                        throw new RuntimeException("TRAP CODE " + n);