codea: super mega opt fuer einen sub spezialfall
[uebersetzerbau-ss10.git] / asmb / asmbtest.c
index bea72ba703a03c8ba70ee44607bc426bf08f929f..63b2ca6a6b92bc0121d14c31d4095b4c4fab8148 100644 (file)
@@ -39,7 +39,32 @@ static void hexdump(void *d, int len) {
        }
 }
 
-#define NUM_TESTCASES 17
+static void fillregisters(void)
+{
+       __asm__("push %rdx\n\t");
+       __asm__("mov $12345678, %rdx\n\t");
+
+       __asm__("movq %rdx, %xmm0\n\t");
+       __asm__("movq %rdx, %xmm1\n\t");
+       __asm__("movq %rdx, %xmm2\n\t");
+       __asm__("movq %rdx, %xmm3\n\t");
+       __asm__("movq %rdx, %xmm4\n\t");
+       __asm__("movq %rdx, %xmm5\n\t");
+       __asm__("movq %rdx, %xmm6\n\t");
+       __asm__("movq %rdx, %xmm7\n\t");
+       __asm__("movq %rdx, %xmm8\n\t");
+       __asm__("movq %rdx, %xmm9\n\t");
+       __asm__("movq %rdx, %xmm10\n\t");
+       __asm__("movq %rdx, %xmm11\n\t");
+       __asm__("movq %rdx, %xmm12\n\t");
+       __asm__("movq %rdx, %xmm13\n\t");
+       __asm__("movq %rdx, %xmm14\n\t");
+       __asm__("movq %rdx, %xmm15\n\t");
+       __asm__("pop %rdx\n\t");
+}
+
+
+#define NUM_TESTCASES 19
 int main()
 {
        char *input[NUM_TESTCASES]={
@@ -60,8 +85,10 @@ int main()
                "ASDFASDFasdfasdfaBC0AAAABBBBCCCCmuhKA\0asASDFasdf",
                "ASas\0ASas",
                "asdfABCDEFGHKL54",
+               "asdffvdfgerrggre\0",
+               "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1234567890allyourbasearebelongtousALLYOURBASEAREBELONGTOUS1337423133711111!!!!elfeinscos(0)sin(M_PI/2)MASTEROFDESTRUCTIONlordoftheuniverseFA!LblogICANhascheezburgericanHASCHEEZBURGERRickROLLrollRICK O RLY? you got 288 IMiss Teen South Carolina"
        };
-       int len[NUM_TESTCASES] = {
+       int len[NUM_TESTCASES+1] = {
                16,
                8,
                8,
@@ -78,21 +105,55 @@ int main()
                32,
                48,
                9,
-               16
+               16,
+               17,
+               296,
+               31337
+       };
+       int off[NUM_TESTCASES+1] = {
+               0,
+               0,
+               0,
+               0,
+               1,
+               2,
+               2,
+               1,
+               3,
+               6,
+               5,
+               6,
+               6,
+               2,
+               0,
+               0,
+               0,
+               0,
+               5,
+               10,
        };
        char *output_our, *output_ref;
        char *input_our,  *input_ref;
        int right=0, wrong=0, neither=0, i;
 
-       for(i = 0; i < NUM_TESTCASES; i++) {
-               input_our = (char *) malloc (len[i]);
-               input_ref = (char *) malloc (len[i]);
+       for(i = 0; i < NUM_TESTCASES+1; i++) {
+               input_our = (char *) calloc (len[i], 16);
+               input_ref = (char *) calloc (len[i], 16);
 
-               (void) memcpy(input_our, input[i], len[i]+1);
-               (void) memcpy(input_ref, input[i], len[i]+1);
+               if(i == NUM_TESTCASES) {
+                       long u;
+                       for(u=0; u < len[i]; u++) {
+                               input_our[u] = input_ref[u] = 'S';
+                       }
+                       input_our[len[i]] = input_ref[len[i]] = '\0';
+               } else {
+                       (void) memcpy(input_our, input[i], len[i]+1);
+                       (void) memcpy(input_ref, input[i], len[i]+1);
+               }
 
-               output_our = (char *) asmb((unsigned char *) input_our);
-               output_ref = (char *) asmb_ref((unsigned char *) input_ref);
+               fillregisters();
+               output_our = (char *) asmb((unsigned char *) input_our+off[i]);
+               output_ref = (char *) asmb_ref((unsigned char *) input_ref+off[i]);
 
                if(memcmp(output_our,output_ref, len[i]) != 0) {
                        if(strncmp(output_our, output_ref, len[i]) == 0) {
@@ -104,8 +165,11 @@ int main()
                                printf("Testfall%02i falsch!\n", i);
                        }
 
-                       printf("Input(\"%s\"):\n", input[i]);
-                       hexdump(input[i], len[i]);
+                       if (i < NUM_TESTCASES) {
+                               /* beim "spezialfall" wuerde das boese enden */
+                               printf("Input(\"%s\"):\n", input[i]);
+                               hexdump(input[i], len[i]);
+                       }
 
                        printf("\nerwartet:\n");
                        hexdump(output_ref, len[i]);