Statistics
| Branch: | Revision:

root / target-i386 / ops_template_mem.h @ b6abf97d

History | View | Annotate | Download (2.6 kB)

1 2c0262af bellard
/*
2 2c0262af bellard
 *  i386 micro operations (included several times to generate
3 2c0262af bellard
 *  different operand sizes)
4 5fafdf24 ths
 *
5 2c0262af bellard
 *  Copyright (c) 2003 Fabrice Bellard
6 2c0262af bellard
 *
7 2c0262af bellard
 * This library is free software; you can redistribute it and/or
8 2c0262af bellard
 * modify it under the terms of the GNU Lesser General Public
9 2c0262af bellard
 * License as published by the Free Software Foundation; either
10 2c0262af bellard
 * version 2 of the License, or (at your option) any later version.
11 2c0262af bellard
 *
12 2c0262af bellard
 * This library is distributed in the hope that it will be useful,
13 2c0262af bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 2c0262af bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 2c0262af bellard
 * Lesser General Public License for more details.
16 2c0262af bellard
 *
17 2c0262af bellard
 * You should have received a copy of the GNU Lesser General Public
18 2c0262af bellard
 * License along with this library; if not, write to the Free Software
19 2c0262af bellard
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 2c0262af bellard
 */
21 2c0262af bellard
#ifdef MEM_WRITE
22 2c0262af bellard
23 943144d9 bellard
#if MEM_WRITE == 0
24 943144d9 bellard
25 943144d9 bellard
#if DATA_BITS == 8
26 943144d9 bellard
#define MEM_SUFFIX b_raw
27 943144d9 bellard
#elif DATA_BITS == 16
28 943144d9 bellard
#define MEM_SUFFIX w_raw
29 943144d9 bellard
#elif DATA_BITS == 32
30 943144d9 bellard
#define MEM_SUFFIX l_raw
31 14ce26e7 bellard
#elif DATA_BITS == 64
32 14ce26e7 bellard
#define MEM_SUFFIX q_raw
33 943144d9 bellard
#endif
34 943144d9 bellard
35 943144d9 bellard
#elif MEM_WRITE == 1
36 943144d9 bellard
37 943144d9 bellard
#if DATA_BITS == 8
38 943144d9 bellard
#define MEM_SUFFIX b_kernel
39 943144d9 bellard
#elif DATA_BITS == 16
40 943144d9 bellard
#define MEM_SUFFIX w_kernel
41 943144d9 bellard
#elif DATA_BITS == 32
42 943144d9 bellard
#define MEM_SUFFIX l_kernel
43 14ce26e7 bellard
#elif DATA_BITS == 64
44 14ce26e7 bellard
#define MEM_SUFFIX q_kernel
45 943144d9 bellard
#endif
46 943144d9 bellard
47 943144d9 bellard
#elif MEM_WRITE == 2
48 943144d9 bellard
49 2c0262af bellard
#if DATA_BITS == 8
50 943144d9 bellard
#define MEM_SUFFIX b_user
51 2c0262af bellard
#elif DATA_BITS == 16
52 943144d9 bellard
#define MEM_SUFFIX w_user
53 2c0262af bellard
#elif DATA_BITS == 32
54 943144d9 bellard
#define MEM_SUFFIX l_user
55 14ce26e7 bellard
#elif DATA_BITS == 64
56 14ce26e7 bellard
#define MEM_SUFFIX q_user
57 943144d9 bellard
#endif
58 943144d9 bellard
59 943144d9 bellard
#else
60 943144d9 bellard
61 943144d9 bellard
#error invalid MEM_WRITE
62 943144d9 bellard
63 2c0262af bellard
#endif
64 2c0262af bellard
65 2c0262af bellard
#else
66 2c0262af bellard
67 2c0262af bellard
#define MEM_SUFFIX SUFFIX
68 2c0262af bellard
69 2c0262af bellard
#endif
70 2c0262af bellard
71 2c0262af bellard
/* carry add/sub (we only need to set CC_OP differently) */
72 2c0262af bellard
73 2c0262af bellard
void OPPROTO glue(glue(op_adc, MEM_SUFFIX), _T0_T1_cc)(void)
74 2c0262af bellard
{
75 2c0262af bellard
    int cf;
76 2c0262af bellard
    cf = cc_table[CC_OP].compute_c();
77 2c0262af bellard
    T0 = T0 + T1 + cf;
78 2c0262af bellard
#ifdef MEM_WRITE
79 14ce26e7 bellard
    glue(st, MEM_SUFFIX)(A0, T0);
80 2c0262af bellard
#endif
81 2c0262af bellard
    CC_SRC = T1;
82 2c0262af bellard
    CC_DST = T0;
83 14ce26e7 bellard
    CC_OP = CC_OP_ADDB + SHIFT + cf * 4;
84 2c0262af bellard
}
85 2c0262af bellard
86 2c0262af bellard
void OPPROTO glue(glue(op_sbb, MEM_SUFFIX), _T0_T1_cc)(void)
87 2c0262af bellard
{
88 2c0262af bellard
    int cf;
89 2c0262af bellard
    cf = cc_table[CC_OP].compute_c();
90 2c0262af bellard
    T0 = T0 - T1 - cf;
91 2c0262af bellard
#ifdef MEM_WRITE
92 14ce26e7 bellard
    glue(st, MEM_SUFFIX)(A0, T0);
93 2c0262af bellard
#endif
94 2c0262af bellard
    CC_SRC = T1;
95 2c0262af bellard
    CC_DST = T0;
96 14ce26e7 bellard
    CC_OP = CC_OP_SUBB + SHIFT + cf * 4;
97 2c0262af bellard
}
98 2c0262af bellard
99 2c0262af bellard
void OPPROTO glue(glue(op_cmpxchg, MEM_SUFFIX), _T0_T1_EAX_cc)(void)
100 2c0262af bellard
{
101 14ce26e7 bellard
    target_ulong src, dst;
102 2c0262af bellard
103 2c0262af bellard
    src = T0;
104 2c0262af bellard
    dst = EAX - T0;
105 2c0262af bellard
    if ((DATA_TYPE)dst == 0) {
106 2c0262af bellard
        T0 = T1;
107 1e4fe7ce bellard
#ifdef MEM_WRITE
108 14ce26e7 bellard
        glue(st, MEM_SUFFIX)(A0, T0);
109 1e4fe7ce bellard
#endif
110 2c0262af bellard
    } else {
111 2c0262af bellard
        EAX = (EAX & ~DATA_MASK) | (T0 & DATA_MASK);
112 2c0262af bellard
    }
113 2c0262af bellard
    CC_SRC = src;
114 2c0262af bellard
    CC_DST = dst;
115 2c0262af bellard
    FORCE_RET();
116 2c0262af bellard
}
117 2c0262af bellard
118 2c0262af bellard
#undef MEM_SUFFIX
119 2c0262af bellard
#undef MEM_WRITE