asmb: ups @ alignment und mehr testfaelle
authorBernhard Urban <lewurm@gmail.com>
Sat, 13 Mar 2010 10:10:00 +0000 (11:10 +0100)
committerBernhard Urban <lewurm@gmail.com>
Sat, 13 Mar 2010 10:10:00 +0000 (11:10 +0100)
asmb/asmb.s
asmb/asmbtest.c

index 9f0e2e42ccb6b8ec82d54df4870e584a42fc07b1..28942c8d2aaef9c3411f016b9891c28419f436f9 100644 (file)
@@ -59,9 +59,9 @@ asmb:
        //speicheradresse des parameters zurueckgeben (wird noch modifziert)
        mov %rdi, %rax
 
-       /*===============
-       ab hier uebler hax um nach \0 trotzdem die gleichen bytes wie
-       * input zu haben, also um selbiges verhalten wie asmb_ref zu erzwingen */
+       //===============
+       //ab hier uebler hax um nach \0 trotzdem die gleichen bytes wie
+       //input zu haben, also um selbiges verhalten wie asmb_ref zu erzwingen
 
        //\0 byte stelle durch rausfinden des MSB des %ecx
        bsf %ecx, %r11d
@@ -118,7 +118,7 @@ asmb:
        psubb %xmm9, %xmm11
 
        //ergebnis zurueckspielen und fertig \o/
-       movapd %xmm11, -16(%rax, %rdx, 8)
+       movdqu %xmm11, -16(%rax, %rdx, 8)
 
        ret
 .LFE2:
index 45c13956309edf77cae0f52e589227433a1434f3..1e536fa2a7f039a0dfd22505f6869c0d71b3d535 100644 (file)
@@ -39,6 +39,31 @@ static void hexdump(void *d, int len) {
        }
 }
 
+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 18
 int main()
 {
@@ -82,6 +107,26 @@ int main()
                16,
                17,
        };
+       int off[NUM_TESTCASES] = {
+               0,
+               0,
+               0,
+               0,
+               1,
+               2,
+               2,
+               1,
+               3,
+               6,
+               5,
+               6,
+               6,
+               2,
+               0,
+               0,
+               0,
+               0,
+       };
        char *output_our, *output_ref;
        char *input_our,  *input_ref;
        int right=0, wrong=0, neither=0, i;
@@ -93,8 +138,9 @@ int main()
                (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) {