[gesamt] Added ag/codea/codeb testcases
[testub10.git] / gesamt / codeb_georg_asmb_01.0
diff --git a/gesamt/codeb_georg_asmb_01.0 b/gesamt/codeb_georg_asmb_01.0
new file mode 100644 (file)
index 0000000..3f6ecc7
--- /dev/null
@@ -0,0 +1,40 @@
+/** asmb - aka tolower(), maybe more than strlen().
+ *
+ *     unsigned char *asmb(unsigned char *s)
+ *     {
+ *             unsigned long i;
+ *             for (i=0; s[i]; 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!? */
+struct f end;
+method asmb()
+       var p := this;
+       while p.f - (256 * (p--1).f)
+       do
+               var c := p.f - (256 * (p--1).f);
+
+               /* add 'a'-'A' iff 'A' <= c <= 'Z' */
+               if 0x40 < c then if c < 0x5B then
+                       c := c--0x20;
+               end;
+               end;
+
+               p.f := (256 * (p--1).f)-(0-c);
+
+               p := p--1;
+       end;
+       return this;
+end;