DEADSOFTWARE

Добавлена функция SYSTEM.ROT
[dsw-obn.git] / rtl / SYSTEM.java
index ce1b50621e447042154ad9d70dc11136278673ff..20cbe60f2115f1167d1076d32f81b2f7a3040386 100644 (file)
@@ -81,4 +81,50 @@ public class SYSTEM
                        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));
+               }
+       }
 }