X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=rtl%2FSYSTEM.java;h=68f82bd0983c3ee348507e7903023dc63318cf8c;hb=75d0fd92a5342358f37ed9369ccce9355273e51a;hp=f98236bd90926eeb0ca4d8dd58c46e190e43cd8e;hpb=9f8036eb00032fa7f756113365cb42e05ab262df;p=dsw-obn.git diff --git a/rtl/SYSTEM.java b/rtl/SYSTEM.java index f98236b..68f82bd 100644 --- a/rtl/SYSTEM.java +++ b/rtl/SYSTEM.java @@ -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); + } + } }