[gesamt] Added ag/codea/codeb testcases
[testub10.git] / gesamt / codeb_georg_asma_02.0
diff --git a/gesamt/codeb_georg_asma_02.0 b/gesamt/codeb_georg_asma_02.0
new file mode 100644 (file)
index 0000000..85f8ff5
--- /dev/null
@@ -0,0 +1,42 @@
+/** asma - aka tolower() first 16 bytes.
+ *
+ *     unsigned char *asma(unsigned char *s)
+ *     {
+ *             int i;
+ *             for (i=0; i<16; i++)
+ *             {
+ *                     unsigned char c = s[i];
+ *                     c += (c >= 'A' && c <= 'Z') ? 'a'-'A' : 0;
+ *                     s[i] = c;
+ *             }
+ *             return s;
+ *     }
+ */
+/* AMD64 Little Endian byte order
+ * p[0]                c0 c1 c2 c3 c4 c5 c6 c7
+ * p[1]                   c1 c2 c3 c4 c5 c6 c7 c8
+ * p[1] * 256          00 c1 c2 c3 c4 c5 c6 c7
+ * p[0] - 256 * p[1]   c0
+ */
+/* WISHLIST signed!? p w/o i */
+struct f end;
+method asma()
+       var i := 0;
+       while i < 16
+       do
+               var a := (this-(0-i)).f;
+               var b := (this-(-1-i)).f;
+               var c := a - (256 * b);
+
+               /* add 'a'-'A' iff 'A' <= c <= 'Z' */
+               if 0x40 < c then if c < 0x5B then
+                       c := c--0x20;
+               end;
+               end;
+
+               (this-(0-i)).f := (256 * b) -(0-c);
+
+               i := i--1;
+       end;
+       return this;
+end;