asmb: struktuelle aenderungen
authorBernhard Urban <lewurm@gmail.com>
Thu, 4 Mar 2010 18:12:42 +0000 (19:12 +0100)
committerBernhard Urban <lewurm@gmail.com>
Thu, 4 Mar 2010 18:12:42 +0000 (19:12 +0100)
.gitignore
asmb/Makefile
asmb/README [deleted file]
asmb/asmbtest.c [changed mode: 0755->0644]
asmb/main.c [deleted file]
asmb/test.sh

index f68ecb8853efad88398609e13c90b2ce3932f5ce..90579c4bb0d2bcaa682de8b2f91d484efad39acd 100644 (file)
@@ -10,7 +10,7 @@ oxout.*
 asma/asma
 
 #asmb
-asmb/asmb
+asmb/asmbtest
 
 #scanner
 scanner/scanner.c
index f3074164e698abe618eed09afaeec93394d81907..43a0fa5e00692cf8e8e273a7b0af9d04284d229e 100755 (executable)
@@ -7,13 +7,14 @@ $(NAME).o: $(NAME).s
 
 .PHONY: clean
 clean:
-       rm -f $(NAME).o $(NAME) *.trace *.tmp
+       rm -f $(NAME).o $(NAME)test *.trace *.tmp
 
 1test: all
        @echo "  COMPILE  $<"
-       @gcc -pedantic -ansi -Wall -g -o $(NAME) $(NAME).s main.c -D_GNU_SOURCE
-       @echo "execute ./$(NAME)"
-       @./$(NAME)
+       @gcc -O -pedantic -ansi -Wall -g -o $(NAME)test $(NAME).s $(NAME)test.c -D_GNU_SOURCE
+       @./dumpinstr.sh $(NAME)test $(NAME)
+       @echo "execute ./$(NAME)test"
+       @./$(NAME)test
 
 2test:
        /usr/ftp/pub/ublu/test/$(NAME)/test 2>&1
diff --git a/asmb/README b/asmb/README
deleted file mode 100644 (file)
index 90a5448..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-the mysterious mr. ubvl presents
-
-the asmb benchmark:
-unpack somewhere,
-./test.sh
-compare your instruction count to that of your colleagues. the smaller, the
-better. you can see what instructions were executed by looking at the trace.
old mode 100755 (executable)
new mode 100644 (file)
index 89e585b..b8932f7
@@ -15,7 +15,7 @@ unsigned char *asmb_ref(unsigned char *s)
        return s;
 }
 
-#define NUM_TESTCASES 12
+#define NUM_TESTCASES 13
 int main() {
        char *input[NUM_TESTCASES]={"asdfABCDEFGHKL54", 
                "foofuuMUHkk", 
@@ -28,20 +28,22 @@ int main() {
                "AbC\0AAAAAAAAAAAA", 
                "BLA|MUHMKUH|KAA\0", 
                "ASDFASDFasdfasdfaBC\0AAAABBBBCCCC", 
-               "ASDFASDFasdfasdfaBC0AAAABBBBCCCCmuhKA\0asASDFasdf" 
+               "ASDFASDFasdfasdfaBC0AAAABBBBCCCCmuhKA\0asASDFasdf" ,
+               "ASas\0ASas"
        };
        int len[NUM_TESTCASES] = {16,
                11,
                3,
                14,
-               60,
+               61,
                17,
                16,
                16,
                16,
                16,
                32,
-               48
+               48,
+               9
        };
        char *output_our, *output_ref;
        char *input_our,  *input_ref;
@@ -51,25 +53,25 @@ int main() {
                input_our = strndup(input[i], len[i]);
                input_ref = strndup(input[i], len[i]);
 
-               output_our = asmb(input_our);
-               output_ref = asmb_ref(input_ref);
+               output_our = (char *) asmb((unsigned char *) input_our);
+               output_ref = (char *) asmb_ref((unsigned char *) input_ref);
                if(memcmp(output_our,output_ref, len[i]) != 0) {
-                       printf("Testfall falsch! \n Input: \n");
+                       printf("Testfall%02i falsch!\n Input(\"%s\"):\n\t", i, input[i]);
                        for(j = 0; j <= len[i]; j++) {
-                               printf("%02X ",input[j]);
+                               printf("%02X ", input[i][j]);
                        }
-                       printf("\nerwartet: \n");
+                       printf("\nerwartet:\n\t");
                        for(j = 0; j <= len[i]; j++) {
-                               printf("%02X ",output_ref[j]);
+                               printf("%02X ", output_ref[j]);
                        }
-                       printf("\ntatsaechliches Ergebnis: \n");
+                       printf("\ntatsaechliches Ergebnis:\n\t");
                        for(j = 0; j <= len[i]; j++) {
-                               printf("%02X ",output_our[j]);
+                               printf("%02X ", output_our[j]);
                        }
                        printf("\n");
                }
                else {
-                       printf("Testfall korrekt\n");
+                       printf("Testfall%02i korrekt\n", i);
                }
                free(input_our);
                free(input_ref);
@@ -77,4 +79,3 @@ int main() {
        return 0;
 }
 
-
diff --git a/asmb/main.c b/asmb/main.c
deleted file mode 100755 (executable)
index e979897..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-extern unsigned char *asmb(unsigned char *a);
-
-unsigned char *asmb_ref(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;
-}
-
-#define NUM_TESTCASES 12
-int main()
-{
-       char *input[NUM_TESTCASES]={"asdfABCDEFGHKL54", 
-               "foofuuMUHkk", 
-               "AbC", 
-               "BLA|MUHMKUH|KA", 
-               "ASDFNERABHDFKHDFKLGJAHGLKAHGLKASHGEARNAKLVNLVAANLSADJVHASDLGH", 
-               "asdfABCDEFGHKL544", 
-               "asdfA\0BCDEFGHKL5", 
-               "foofuuMUHkk\0AAAA", 
-               "AbC\0AAAAAAAAAAAA", 
-               "BLA|MUHMKUH|KAA\0", 
-               "ASDFASDFasdfasdfaBC\0AAAABBBBCCCC", 
-               "ASDFASDFasdfasdfaBC0AAAABBBBCCCCmuhKA\0asASDFasdf" 
-       };
-       int len[NUM_TESTCASES] = {16,
-               11,
-               3,
-               14,
-               60,
-               17,
-               16,
-               16,
-               16,
-               16,
-               32,
-               48
-       };
-       char *output_our, *output_ref;
-       char *input_our,  *input_ref;
-
-       int i,j;
-       for(i = 0; i < NUM_TESTCASES; i++) {
-               input_our = strndup(input[i], len[i]);
-               input_ref = strndup(input[i], len[i]);
-
-               output_our = (char *) asmb((unsigned char*) input_our);
-               output_ref = (char *) asmb_ref((unsigned char*) input_ref);
-               if(memcmp(output_our,output_ref, len[i]) != 0) {
-                       printf("Testfall falsch!\nInput:\n\t");
-                       for(j = 0; j <= len[i]; j++) {
-                               printf("%02X ", input[i][j]);
-                       }
-                       printf("\nerwartet:\n\t");
-                       for(j = 0; j <= len[i]; j++) {
-                               printf("%02X ", output_ref[j]);
-                       }
-                       printf("\ntatsaechliches Ergebnis:\n\t");
-                       for(j = 0; j <= len[i]; j++) {
-                               printf("%02X ", output_our[j]);
-                       }
-                       printf("\n");
-               }
-               else {
-                       printf("Testfall korrekt\n");
-               }
-               free(input_our);
-               free(input_ref);
-       }
-       return 0;
-}
-
index 01e1870ee61137a158ae9c79c91077ac8816831c..7f576a0c38013d1893c11c8282e501a297c05322 100755 (executable)
@@ -2,6 +2,6 @@
 
 cd ~/abgabe/asmb
 make clean && make
-gcc -O -g -o asmbtest asmbtest.c asmb.o
+gcc -O -g -o asmbtest asmbtest.c asmb.o -D_GNU_SOURCE
 ./dumpinstr.sh asmbtest asmb
 rm -f asmbtest