diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-02-24 23:43:02 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-02-24 23:43:02 +0000 |
commit | 379ca80d34d685c038800be58d2314933619d78b (patch) | |
tree | 206fda3e9a6f47d06eb3b037098d340306b51768 /tests | |
parent | 4d1135e486fcdd3b00caf524f01af7f0d56a0af7 (diff) |
added shift tests
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@12 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 2 | ||||
-rw-r--r-- | tests/test-i386-shift.h | 79 | ||||
-rw-r--r-- | tests/test-i386.c | 24 |
3 files changed, 104 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile index cbe80e2974..c6347edfcc 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -17,7 +17,7 @@ test2: test2.c $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< # i386 emulation test (dump various opcodes) */ -test-i386: test-i386.c test-i386.h +test-i386: test-i386.c test-i386.h test-i386-shift.h $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test: test-i386 diff --git a/tests/test-i386-shift.h b/tests/test-i386-shift.h new file mode 100644 index 0000000000..af892f6c7d --- /dev/null +++ b/tests/test-i386-shift.h @@ -0,0 +1,79 @@ + +#define exec_op glue(exec_, OP) +#define exec_opl glue(glue(exec_, OP), l) +#define exec_opw glue(glue(exec_, OP), w) +#define exec_opb glue(glue(exec_, OP), b) + +#define EXECSHIFT(size, res, s1, flags) \ + asm ("push %4\n\t"\ + "popf\n\t"\ + stringify(OP) size " %%cl, %" size "0\n\t" \ + "pushf\n\t"\ + "popl %1\n\t"\ + : "=q" (res), "=g" (flags)\ + : "c" (s1), "0" (res), "1" (flags)); + +void exec_opl(int s0, int s1, int iflags) +{ + int res, flags; + res = s0; + flags = iflags; + EXECSHIFT("", res, s1, flags); + /* overflow is undefined if count != 1 */ + if (s1 != 1) + flags &= ~CC_O; + printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n", + stringify(OP) "l", s0, s1, res, iflags, flags & CC_MASK); +} + +void exec_opw(int s0, int s1, int iflags) +{ + int res, flags; + res = s0; + flags = iflags; + EXECSHIFT("w", res, s1, flags); + /* overflow is undefined if count != 1 */ + if (s1 != 1) + flags &= ~CC_O; + printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n", + stringify(OP) "w", s0, s1, res, iflags, flags & CC_MASK); +} + +void exec_opb(int s0, int s1, int iflags) +{ + int res, flags; + res = s0; + flags = iflags; + EXECSHIFT("b", res, s1, flags); + /* overflow is undefined if count != 1 */ + if (s1 != 1) + flags &= ~CC_O; + printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n", + stringify(OP) "b", s0, s1, res, iflags, flags & CC_MASK); +} + +void exec_op(int s0, int s1) +{ + exec_opl(s0, s1, 0); + exec_opw(s0, s1, 0); + exec_opb(s0, s1, 0); +#ifdef OP_CC + exec_opl(s0, s1, CC_C); + exec_opw(s0, s1, CC_C); + exec_opb(s0, s1, CC_C); +#endif +} + +void glue(test_, OP)(void) +{ + int i; + for(i = 0; i < 32; i++) + exec_op(0x12345678, i); + for(i = 0; i < 32; i++) + exec_op(0x82345678, i); +} + +void *glue(_test_, OP) __init_call = glue(test_, OP); + +#undef OP +#undef OP_CC diff --git a/tests/test-i386.c b/tests/test-i386.c index 943bbf07b5..5fb9c5cd05 100644 --- a/tests/test-i386.c +++ b/tests/test-i386.c @@ -67,6 +67,30 @@ static void *call_start __init_call = NULL; #define OP1 #include "test-i386.h" +#define OP shl +#include "test-i386-shift.h" + +#define OP shr +#include "test-i386-shift.h" + +#define OP sar +#include "test-i386-shift.h" + +#define OP rol +#include "test-i386-shift.h" + +#define OP ror +#include "test-i386-shift.h" + +#define OP rcr +#define OP_CC +#include "test-i386-shift.h" + +#define OP rcl +#define OP_CC +#include "test-i386-shift.h" + + /* lea test (modrm support) */ #define TEST_LEA(STR)\ {\ |