From d2375fee6a547b3dab989f24818a4290c4091d54 Mon Sep 17 00:00:00 2001 From: Georg Schiesser Date: Wed, 26 May 2010 18:48:12 +0200 Subject: [PATCH] codeb testfaelle asma asmb --- codeb/georg_asma_00.call | 19 ++++++++++++++++++ codeb/georg_asma_01.0 | 43 ++++++++++++++++++++++++++++++++++++++++ codeb/georg_asma_01.call | 1 + codeb/georg_asma_02.0 | 42 +++++++++++++++++++++++++++++++++++++++ codeb/georg_asma_02.call | 1 + codeb/georg_asma_03.0 | 43 ++++++++++++++++++++++++++++++++++++++++ codeb/georg_asma_03.call | 1 + codeb/georg_asma_04.0 | 41 ++++++++++++++++++++++++++++++++++++++ codeb/georg_asma_04.call | 1 + codeb/georg_asmb_00.call | 25 +++++++++++++++++++++++ codeb/georg_asmb_01.0 | 40 +++++++++++++++++++++++++++++++++++++ codeb/georg_asmb_01.call | 1 + 12 files changed, 258 insertions(+) create mode 100644 codeb/georg_asma_00.call create mode 100644 codeb/georg_asma_01.0 create mode 120000 codeb/georg_asma_01.call create mode 100644 codeb/georg_asma_02.0 create mode 120000 codeb/georg_asma_02.call create mode 100644 codeb/georg_asma_03.0 create mode 120000 codeb/georg_asma_03.call create mode 100644 codeb/georg_asma_04.0 create mode 120000 codeb/georg_asma_04.call create mode 100644 codeb/georg_asmb_00.call create mode 100644 codeb/georg_asmb_01.0 create mode 120000 codeb/georg_asmb_01.call diff --git a/codeb/georg_asma_00.call b/codeb/georg_asma_00.call new file mode 100644 index 0000000..1c4a165 --- /dev/null +++ b/codeb/georg_asma_00.call @@ -0,0 +1,19 @@ +/* BOF georg_asma_00.call */ +#include /* strcmp() */ +char x[] = "UVWxyz6789abcDEFUVWxyz6789abcDEFUVWxyz6789abcDEFUVWxyz6789abcDEF"; +char y[] = "UVWxyz6789abcDEFUVWxyz6789abcDEFUVWxyz6789abcDEFUVWxyz6789abcDEF"; +char z[] = "UVWxyz6789abcDEFuvwxyz6789abcdefUVWxyz6789abcDEFUVWxyz6789abcDEF"; +char *p = &y[16]; +extern char *asma(char *); +int ret = (asma(p)==p && (strcmp(y,z)==0)); +if (ret != 1) { + x[sizeof(x)-1] = '\0'; /* just 2b sure */ + y[sizeof(y)-1] = '\0'; /* just 2b sure */ + z[sizeof(z)-1] = '\0'; /* just 2b sure */ + fprintf(stderr, "### %s:%d:%s() x '%s'\n", __FILE__, __LINE__, __FUNCTION__, x); + fprintf(stderr, "### %s:%d:%s() y '%s'\n", __FILE__, __LINE__, __FUNCTION__, y); + fprintf(stderr, "### %s:%d:%s() z '%s'\n", __FILE__, __LINE__, __FUNCTION__, z); +} +RET(ret); +/* vim: set filetype=c: */ +/* EOF georg_asma_00.call */ diff --git a/codeb/georg_asma_01.0 b/codeb/georg_asma_01.0 new file mode 100644 index 0000000..6daa90f --- /dev/null +++ b/codeb/georg_asma_01.0 @@ -0,0 +1,43 @@ +/** 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 p := this; + var i := 0; + while i < 16 + do + var a := (p-(0-i)).f; + var b := (p-(-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; + + (p-(0-i)).f := (256 * b) -(0-c); + + i := i--1; + end; + return this; +end; diff --git a/codeb/georg_asma_01.call b/codeb/georg_asma_01.call new file mode 120000 index 0000000..fa84142 --- /dev/null +++ b/codeb/georg_asma_01.call @@ -0,0 +1 @@ +georg_asma_00.call \ No newline at end of file diff --git a/codeb/georg_asma_02.0 b/codeb/georg_asma_02.0 new file mode 100644 index 0000000..85f8ff5 --- /dev/null +++ b/codeb/georg_asma_02.0 @@ -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; diff --git a/codeb/georg_asma_02.call b/codeb/georg_asma_02.call new file mode 120000 index 0000000..fa84142 --- /dev/null +++ b/codeb/georg_asma_02.call @@ -0,0 +1 @@ +georg_asma_00.call \ No newline at end of file diff --git a/codeb/georg_asma_03.0 b/codeb/georg_asma_03.0 new file mode 100644 index 0000000..3d56525 --- /dev/null +++ b/codeb/georg_asma_03.0 @@ -0,0 +1,43 @@ +/** 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!? */ +struct f end; +method asma() + var p := this; + var q := this--16; + while p < q + do + var a := p.f; + var b := (p--1).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; + + p.f := (256 * b) -(0-c); + + p := p--1; + end; + return this; +end; diff --git a/codeb/georg_asma_03.call b/codeb/georg_asma_03.call new file mode 120000 index 0000000..fa84142 --- /dev/null +++ b/codeb/georg_asma_03.call @@ -0,0 +1 @@ +georg_asma_00.call \ No newline at end of file diff --git a/codeb/georg_asma_04.0 b/codeb/georg_asma_04.0 new file mode 100644 index 0000000..3eab8c4 --- /dev/null +++ b/codeb/georg_asma_04.0 @@ -0,0 +1,41 @@ +/** 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!? */ +struct f end; +method asma() + var p := this; + var q := this--16; + while p < q + 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; diff --git a/codeb/georg_asma_04.call b/codeb/georg_asma_04.call new file mode 120000 index 0000000..fa84142 --- /dev/null +++ b/codeb/georg_asma_04.call @@ -0,0 +1 @@ +georg_asma_00.call \ No newline at end of file diff --git a/codeb/georg_asmb_00.call b/codeb/georg_asmb_00.call new file mode 100644 index 0000000..22696b6 --- /dev/null +++ b/codeb/georg_asmb_00.call @@ -0,0 +1,25 @@ +/* BOF georg_asmb_00.call */ +#include /* strcmp() strlen() */ +char x[] = "UVWxyz6789abcDEFUVWxyz6789abcDEFUVWxyz6789abcDE\0UVWxyz6789abcDEFUVWxyz6789abcDEF"; +char y[] = "UVWxyz6789abcDEFUVWxyz6789abcDEFUVWxyz6789abcDE\0UVWxyz6789abcDEFUVWxyz6789abcDEF"; +char z[] = "UVWxyz6789abcDEFuvwxyz6789abcdefuvwxyz6789abcde\0UVWxyz6789abcDEFUVWxyz6789abcDEF"; +char *p = &y[16]; +extern char *asmb(char *); +int ret = (asmb(p)==p && (strcmp(y,z)==0)); +if (ret != 1) { + x[sizeof(x)-1] = '\0'; /* just 2b sure */ + y[sizeof(y)-1] = '\0'; /* just 2b sure */ + z[sizeof(z)-1] = '\0'; /* just 2b sure */ + x[sizeof(x)-2] = '\0'; /* just 2b sure */ + y[sizeof(y)-2] = '\0'; /* just 2b sure */ + z[sizeof(z)-2] = '\0'; /* just 2b sure */ + x[strlen(x)] = '#'; + y[strlen(y)] = '#'; + z[strlen(z)] = '#'; + fprintf(stderr, "### %s:%d:%s() x '%s'\n", __FILE__, __LINE__, __FUNCTION__, x); + fprintf(stderr, "### %s:%d:%s() y '%s'\n", __FILE__, __LINE__, __FUNCTION__, y); + fprintf(stderr, "### %s:%d:%s() z '%s'\n", __FILE__, __LINE__, __FUNCTION__, z); +} +RET(ret); +/* vim: set filetype=c: */ +/* EOF georg_asmb_00.call */ diff --git a/codeb/georg_asmb_01.0 b/codeb/georg_asmb_01.0 new file mode 100644 index 0000000..3f6ecc7 --- /dev/null +++ b/codeb/georg_asmb_01.0 @@ -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; diff --git a/codeb/georg_asmb_01.call b/codeb/georg_asmb_01.call new file mode 120000 index 0000000..5b7fedb --- /dev/null +++ b/codeb/georg_asmb_01.call @@ -0,0 +1 @@ +georg_asmb_00.call \ No newline at end of file -- 2.25.1