Revision 379ca80d

b/tests/Makefile
17 17
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
18 18

  
19 19
# i386 emulation test (dump various opcodes) */
20
test-i386: test-i386.c test-i386.h
20
test-i386: test-i386.c test-i386.h test-i386-shift.h
21 21
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
22 22

  
23 23
test: test-i386
b/tests/test-i386-shift.h
1

  
2
#define exec_op glue(exec_, OP)
3
#define exec_opl glue(glue(exec_, OP), l)
4
#define exec_opw glue(glue(exec_, OP), w)
5
#define exec_opb glue(glue(exec_, OP), b)
6

  
7
#define EXECSHIFT(size, res, s1, flags) \
8
    asm ("push %4\n\t"\
9
         "popf\n\t"\
10
         stringify(OP) size " %%cl, %" size "0\n\t" \
11
         "pushf\n\t"\
12
         "popl %1\n\t"\
13
         : "=q" (res), "=g" (flags)\
14
         : "c" (s1), "0" (res), "1" (flags));
15

  
16
void exec_opl(int s0, int s1, int iflags)
17
{
18
    int res, flags;
19
    res = s0;
20
    flags = iflags;
21
    EXECSHIFT("", res, s1, flags);
22
    /* overflow is undefined if count != 1 */
23
    if (s1 != 1)
24
      flags &= ~CC_O;
25
    printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
26
           stringify(OP) "l", s0, s1, res, iflags, flags & CC_MASK);
27
}
28

  
29
void exec_opw(int s0, int s1, int iflags)
30
{
31
    int res, flags;
32
    res = s0;
33
    flags = iflags;
34
    EXECSHIFT("w", res, s1, flags);
35
    /* overflow is undefined if count != 1 */
36
    if (s1 != 1)
37
      flags &= ~CC_O;
38
    printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
39
           stringify(OP) "w", s0, s1, res, iflags, flags & CC_MASK);
40
}
41

  
42
void exec_opb(int s0, int s1, int iflags)
43
{
44
    int res, flags;
45
    res = s0;
46
    flags = iflags;
47
    EXECSHIFT("b", res, s1, flags);
48
    /* overflow is undefined if count != 1 */
49
    if (s1 != 1)
50
      flags &= ~CC_O;
51
    printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
52
           stringify(OP) "b", s0, s1, res, iflags, flags & CC_MASK);
53
}
54

  
55
void exec_op(int s0, int s1)
56
{
57
    exec_opl(s0, s1, 0);
58
    exec_opw(s0, s1, 0);
59
    exec_opb(s0, s1, 0);
60
#ifdef OP_CC
61
    exec_opl(s0, s1, CC_C);
62
    exec_opw(s0, s1, CC_C);
63
    exec_opb(s0, s1, CC_C);
64
#endif
65
}
66

  
67
void glue(test_, OP)(void)
68
{
69
    int i;
70
    for(i = 0; i < 32; i++)
71
        exec_op(0x12345678, i);
72
    for(i = 0; i < 32; i++)
73
        exec_op(0x82345678, i);
74
}
75

  
76
void *glue(_test_, OP) __init_call = glue(test_, OP);
77

  
78
#undef OP
79
#undef OP_CC
b/tests/test-i386.c
67 67
#define OP1
68 68
#include "test-i386.h"
69 69

  
70
#define OP shl
71
#include "test-i386-shift.h"
72

  
73
#define OP shr
74
#include "test-i386-shift.h"
75

  
76
#define OP sar
77
#include "test-i386-shift.h"
78

  
79
#define OP rol
80
#include "test-i386-shift.h"
81

  
82
#define OP ror
83
#include "test-i386-shift.h"
84

  
85
#define OP rcr
86
#define OP_CC
87
#include "test-i386-shift.h"
88

  
89
#define OP rcl
90
#define OP_CC
91
#include "test-i386-shift.h"
92

  
93

  
70 94
/* lea test (modrm support) */
71 95
#define TEST_LEA(STR)\
72 96
{\

Also available in: Unified diff