X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=rtl%2FSYSTEM.java;h=20cbe60f2115f1167d1076d32f81b2f7a3040386;hb=789adb9354da345b13aa284f3f4f8f1046cadbc4;hp=28d8c466df99d528685380520b5429a2248a18e5;hpb=3d4021b9a2dd52aaf4b97859a8a58b74903ebac9;p=dsw-obn.git diff --git a/rtl/SYSTEM.java b/rtl/SYSTEM.java index 28d8c46..20cbe60 100644 --- a/rtl/SYSTEM.java +++ b/rtl/SYSTEM.java @@ -17,6 +17,11 @@ 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 ix = LEN(x); @@ -67,9 +72,59 @@ public class SYSTEM { throw new RuntimeException("WITH TRAP"); } + else if(n == -3) + { + throw new RuntimeException("NOT IMPLEMENTED"); + } else { throw new RuntimeException("TRAP CODE " + n); } } + + public static int ASH(int x, int n) + { + return (n > 0) ? (x << n) : (x >> Math.abs(n)); + } + + public static long ASH(long x, long n) + { + return (n > 0) ? (x << n) : (x >> Math.abs(n)); + } + + public static int LSH(int x, int n) + { + return (n > 0) ? (x << n) : (x >>> Math.abs(n)); + } + + public static long LSH(long x, long n) + { + return (n > 0) ? (x << n) : (x >>> Math.abs(n)); + } + + public static int ROT(int x, int n) + { + if(n > 0) + { + return (x << n) | (x >>> (Integer.SIZE - n)); + } + else + { + n = Math.abs(n); + return (x >>> n) | (x << (Integer.SIZE - n)); + } + } + + public static long ROT(long x, long n) + { + if(n > 0) + { + return (x << n) | (x >>> (Long.SIZE - n)); + } + else + { + n = Math.abs(n); + return (x >>> n) | (x << (Long.SIZE - n)); + } + } }