From eefbf06b166a206aec3cadb1a077db88ad519bf9 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Sat, 13 Mar 2010 11:10:00 +0100 Subject: [PATCH] asmb: ups @ alignment und mehr testfaelle --- asmb/asmb.s | 8 ++++---- asmb/asmbtest.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/asmb/asmb.s b/asmb/asmb.s index 9f0e2e4..28942c8 100644 --- a/asmb/asmb.s +++ b/asmb/asmb.s @@ -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: diff --git a/asmb/asmbtest.c b/asmb/asmbtest.c index 45c1395..1e536fa 100644 --- a/asmb/asmbtest.c +++ b/asmb/asmbtest.c @@ -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) { -- 2.25.1