asmb: pernors infforum thread bla
authorBernhard Urban <lewurm@gmail.com>
Wed, 3 Mar 2010 19:39:28 +0000 (20:39 +0100)
committerBernhard Urban <lewurm@gmail.com>
Wed, 3 Mar 2010 19:39:28 +0000 (20:39 +0100)
asmb/asmbtest.c [changed from symlink to file mode: 0755]
asmb/dumpinstr.sh

deleted file mode 120000 (symlink)
index 8a03e9439ec4377b095a0e031e0f301a8888e6de..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-main.c
\ No newline at end of file
new file mode 100755 (executable)
index 0000000000000000000000000000000000000000..89e585b4697140028506e53b6d1ed1db90aa88f6
--- /dev/null
@@ -0,0 +1,80 @@
+#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 = asmb(input_our);
+               output_ref = asmb_ref(input_ref);
+               if(memcmp(output_our,output_ref, len[i]) != 0) {
+                       printf("Testfall falsch! \n Input: \n");
+                       for(j = 0; j <= len[i]; j++) {
+                               printf("%02X ",input[j]);
+                       }
+                       printf("\nerwartet: \n");
+                       for(j = 0; j <= len[i]; j++) {
+                               printf("%02X ",output_ref[j]);
+                       }
+                       printf("\ntatsaechliches Ergebnis: \n");
+                       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 abff42d87b60e4d55142ce6796259bb8be856c04..54726e7ea97cd703fe0e85708df80abb7e6ebae9 100755 (executable)
@@ -63,4 +63,4 @@ awk -- '\
 echo instructions: `grep "^  " $EXECFILE.trace | wc -l`
 echo trace output: $EXECFILE.trace
 
-#rm $EXECFILE.tmp $EXECFILE.output
+rm $EXECFILE.tmp $EXECFILE.output