From: Julian Seward Date: Mon, 6 Dec 2004 14:26:28 +0000 (+0000) Subject: Tests for x86 fldenv/fstenv; also fix error in frstor test. X-Git-Tag: svn/VALGRIND_3_0_1^2~706 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8970b347b9e61b562dba490c2f2c69b7f1f9c7ac;p=thirdparty%2Fvalgrind.git Tests for x86 fldenv/fstenv; also fix error in frstor test. git-svn-id: svn://svn.valgrind.org/vex/trunk@628 --- diff --git a/VEX/test/fldenv.c b/VEX/test/fldenv.c new file mode 100644 index 0000000000..4f37d61e78 --- /dev/null +++ b/VEX/test/fldenv.c @@ -0,0 +1,32 @@ + +#include +#include + +void do_fstenv ( void* p ) +{ + asm("movl 8(%esp), %eax ; fstenv (%eax)"); +} + +void do_fldenv ( void* p ) +{ + asm("movl 8(%esp), %eax ; fldenv (%eax)"); +} + +int main ( void ) +{ + int i; + unsigned short* buf = malloc(14*sizeof(short)); + for (i = 0; i < 14; i++) + buf[i] = i; + buf[0] = 0x037f; + + do_fldenv(buf); + do_fstenv(buf); + for (i = 0; i < 14; i++) { + printf("%04x ", buf[i]); + if (i > 0 && ((i % 12) == 11)) + printf("\n"); + } + printf("\n"); + return 0; +} diff --git a/VEX/test/frstor.c b/VEX/test/frstor.c index 437f094d02..ee3174a810 100644 --- a/VEX/test/frstor.c +++ b/VEX/test/frstor.c @@ -15,7 +15,7 @@ void do_frstor ( void* p ) int main ( void ) { int i; - unsigned short* buf = malloc(54*sizeof(int)); + unsigned short* buf = malloc(54*sizeof(short)); for (i = 0; i < 54; i++) buf[i] = i; buf[0] = 0x037f; diff --git a/VEX/test/fstenv.c b/VEX/test/fstenv.c new file mode 100644 index 0000000000..331714dcfd --- /dev/null +++ b/VEX/test/fstenv.c @@ -0,0 +1,22 @@ + +#include +#include + +void do_fstenv ( void* p ) +{ + asm("fldpi ; fld1; fldln2 ; movl 8(%esp), %eax ; fstenv (%eax)"); +} + +int main ( void ) +{ + int i; + unsigned int* buf = malloc(7*sizeof(int)); + do_fstenv(buf); + for (i = 0; i < 7; i++) { + printf("%08x ", buf[i]); + if (i > 0 && ((i % 6) == 5)) + printf("\n"); + } + printf("\n"); + return 0; +}