Statistics
| Branch: | Revision:

root / target-i386 / ops_template_mem.h @ b6abf97d

History | View | Annotate | Download (2.6 kB)

1
/*
2
 *  i386 micro operations (included several times to generate
3
 *  different operand sizes)
4
 *
5
 *  Copyright (c) 2003 Fabrice Bellard
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 */
21
#ifdef MEM_WRITE
22

    
23
#if MEM_WRITE == 0
24

    
25
#if DATA_BITS == 8
26
#define MEM_SUFFIX b_raw
27
#elif DATA_BITS == 16
28
#define MEM_SUFFIX w_raw
29
#elif DATA_BITS == 32
30
#define MEM_SUFFIX l_raw
31
#elif DATA_BITS == 64
32
#define MEM_SUFFIX q_raw
33
#endif
34

    
35
#elif MEM_WRITE == 1
36

    
37
#if DATA_BITS == 8
38
#define MEM_SUFFIX b_kernel
39
#elif DATA_BITS == 16
40
#define MEM_SUFFIX w_kernel
41
#elif DATA_BITS == 32
42
#define MEM_SUFFIX l_kernel
43
#elif DATA_BITS == 64
44
#define MEM_SUFFIX q_kernel
45
#endif
46

    
47
#elif MEM_WRITE == 2
48

    
49
#if DATA_BITS == 8
50
#define MEM_SUFFIX b_user
51
#elif DATA_BITS == 16
52
#define MEM_SUFFIX w_user
53
#elif DATA_BITS == 32
54
#define MEM_SUFFIX l_user
55
#elif DATA_BITS == 64
56
#define MEM_SUFFIX q_user
57
#endif
58

    
59
#else
60

    
61
#error invalid MEM_WRITE
62

    
63
#endif
64

    
65
#else
66

    
67
#define MEM_SUFFIX SUFFIX
68

    
69
#endif
70

    
71
/* carry add/sub (we only need to set CC_OP differently) */
72

    
73
void OPPROTO glue(glue(op_adc, MEM_SUFFIX), _T0_T1_cc)(void)
74
{
75
    int cf;
76
    cf = cc_table[CC_OP].compute_c();
77
    T0 = T0 + T1 + cf;
78
#ifdef MEM_WRITE
79
    glue(st, MEM_SUFFIX)(A0, T0);
80
#endif
81
    CC_SRC = T1;
82
    CC_DST = T0;
83
    CC_OP = CC_OP_ADDB + SHIFT + cf * 4;
84
}
85

    
86
void OPPROTO glue(glue(op_sbb, MEM_SUFFIX), _T0_T1_cc)(void)
87
{
88
    int cf;
89
    cf = cc_table[CC_OP].compute_c();
90
    T0 = T0 - T1 - cf;
91
#ifdef MEM_WRITE
92
    glue(st, MEM_SUFFIX)(A0, T0);
93
#endif
94
    CC_SRC = T1;
95
    CC_DST = T0;
96
    CC_OP = CC_OP_SUBB + SHIFT + cf * 4;
97
}
98

    
99
void OPPROTO glue(glue(op_cmpxchg, MEM_SUFFIX), _T0_T1_EAX_cc)(void)
100
{
101
    target_ulong src, dst;
102

    
103
    src = T0;
104
    dst = EAX - T0;
105
    if ((DATA_TYPE)dst == 0) {
106
        T0 = T1;
107
#ifdef MEM_WRITE
108
        glue(st, MEM_SUFFIX)(A0, T0);
109
#endif
110
    } else {
111
        EAX = (EAX & ~DATA_MASK) | (T0 & DATA_MASK);
112
    }
113
    CC_SRC = src;
114
    CC_DST = dst;
115
    FORCE_RET();
116
}
117

    
118
#undef MEM_SUFFIX
119
#undef MEM_WRITE