root / target-i386 / op.c @ 651ba608
History | View | Annotate | Download (4 kB)
1 | 2c0262af | bellard | /*
|
---|---|---|---|
2 | 2c0262af | bellard | * i386 micro operations
|
3 | 5fafdf24 | ths | *
|
4 | 2c0262af | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | 2c0262af | bellard | *
|
6 | 2c0262af | bellard | * This library is free software; you can redistribute it and/or
|
7 | 2c0262af | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 2c0262af | bellard | * License as published by the Free Software Foundation; either
|
9 | 2c0262af | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 2c0262af | bellard | *
|
11 | 2c0262af | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 2c0262af | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 2c0262af | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 2c0262af | bellard | * Lesser General Public License for more details.
|
15 | 2c0262af | bellard | *
|
16 | 2c0262af | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 2c0262af | bellard | * License along with this library; if not, write to the Free Software
|
18 | 2c0262af | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 2c0262af | bellard | */
|
20 | f68dd770 | bellard | |
21 | f68dd770 | bellard | #define ASM_SOFTMMU
|
22 | 2c0262af | bellard | #include "exec.h" |
23 | 2c0262af | bellard | |
24 | 2c0262af | bellard | /* we define the various pieces of code used by the JIT */
|
25 | 2c0262af | bellard | |
26 | 2c0262af | bellard | #define REG EAX
|
27 | 2c0262af | bellard | #define REGNAME _EAX
|
28 | 2c0262af | bellard | #include "opreg_template.h" |
29 | 2c0262af | bellard | #undef REG
|
30 | 2c0262af | bellard | #undef REGNAME
|
31 | 2c0262af | bellard | |
32 | 2c0262af | bellard | #define REG ECX
|
33 | 2c0262af | bellard | #define REGNAME _ECX
|
34 | 2c0262af | bellard | #include "opreg_template.h" |
35 | 2c0262af | bellard | #undef REG
|
36 | 2c0262af | bellard | #undef REGNAME
|
37 | 2c0262af | bellard | |
38 | 2c0262af | bellard | #define REG EDX
|
39 | 2c0262af | bellard | #define REGNAME _EDX
|
40 | 2c0262af | bellard | #include "opreg_template.h" |
41 | 2c0262af | bellard | #undef REG
|
42 | 2c0262af | bellard | #undef REGNAME
|
43 | 2c0262af | bellard | |
44 | 2c0262af | bellard | #define REG EBX
|
45 | 2c0262af | bellard | #define REGNAME _EBX
|
46 | 2c0262af | bellard | #include "opreg_template.h" |
47 | 2c0262af | bellard | #undef REG
|
48 | 2c0262af | bellard | #undef REGNAME
|
49 | 2c0262af | bellard | |
50 | 2c0262af | bellard | #define REG ESP
|
51 | 2c0262af | bellard | #define REGNAME _ESP
|
52 | 2c0262af | bellard | #include "opreg_template.h" |
53 | 2c0262af | bellard | #undef REG
|
54 | 2c0262af | bellard | #undef REGNAME
|
55 | 2c0262af | bellard | |
56 | 2c0262af | bellard | #define REG EBP
|
57 | 2c0262af | bellard | #define REGNAME _EBP
|
58 | 2c0262af | bellard | #include "opreg_template.h" |
59 | 2c0262af | bellard | #undef REG
|
60 | 2c0262af | bellard | #undef REGNAME
|
61 | 2c0262af | bellard | |
62 | 2c0262af | bellard | #define REG ESI
|
63 | 2c0262af | bellard | #define REGNAME _ESI
|
64 | 2c0262af | bellard | #include "opreg_template.h" |
65 | 2c0262af | bellard | #undef REG
|
66 | 2c0262af | bellard | #undef REGNAME
|
67 | 2c0262af | bellard | |
68 | 2c0262af | bellard | #define REG EDI
|
69 | 2c0262af | bellard | #define REGNAME _EDI
|
70 | 2c0262af | bellard | #include "opreg_template.h" |
71 | 2c0262af | bellard | #undef REG
|
72 | 2c0262af | bellard | #undef REGNAME
|
73 | 2c0262af | bellard | |
74 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
75 | 14ce26e7 | bellard | |
76 | 14ce26e7 | bellard | #define REG (env->regs[8]) |
77 | 14ce26e7 | bellard | #define REGNAME _R8
|
78 | 14ce26e7 | bellard | #include "opreg_template.h" |
79 | 14ce26e7 | bellard | #undef REG
|
80 | 14ce26e7 | bellard | #undef REGNAME
|
81 | 14ce26e7 | bellard | |
82 | 14ce26e7 | bellard | #define REG (env->regs[9]) |
83 | 14ce26e7 | bellard | #define REGNAME _R9
|
84 | 14ce26e7 | bellard | #include "opreg_template.h" |
85 | 14ce26e7 | bellard | #undef REG
|
86 | 14ce26e7 | bellard | #undef REGNAME
|
87 | 14ce26e7 | bellard | |
88 | 14ce26e7 | bellard | #define REG (env->regs[10]) |
89 | 14ce26e7 | bellard | #define REGNAME _R10
|
90 | 14ce26e7 | bellard | #include "opreg_template.h" |
91 | 14ce26e7 | bellard | #undef REG
|
92 | 14ce26e7 | bellard | #undef REGNAME
|
93 | 14ce26e7 | bellard | |
94 | 14ce26e7 | bellard | #define REG (env->regs[11]) |
95 | 14ce26e7 | bellard | #define REGNAME _R11
|
96 | 14ce26e7 | bellard | #include "opreg_template.h" |
97 | 14ce26e7 | bellard | #undef REG
|
98 | 14ce26e7 | bellard | #undef REGNAME
|
99 | 14ce26e7 | bellard | |
100 | 14ce26e7 | bellard | #define REG (env->regs[12]) |
101 | 14ce26e7 | bellard | #define REGNAME _R12
|
102 | 14ce26e7 | bellard | #include "opreg_template.h" |
103 | 14ce26e7 | bellard | #undef REG
|
104 | 14ce26e7 | bellard | #undef REGNAME
|
105 | 14ce26e7 | bellard | |
106 | 14ce26e7 | bellard | #define REG (env->regs[13]) |
107 | 14ce26e7 | bellard | #define REGNAME _R13
|
108 | 14ce26e7 | bellard | #include "opreg_template.h" |
109 | 14ce26e7 | bellard | #undef REG
|
110 | 14ce26e7 | bellard | #undef REGNAME
|
111 | 14ce26e7 | bellard | |
112 | 14ce26e7 | bellard | #define REG (env->regs[14]) |
113 | 14ce26e7 | bellard | #define REGNAME _R14
|
114 | 14ce26e7 | bellard | #include "opreg_template.h" |
115 | 14ce26e7 | bellard | #undef REG
|
116 | 14ce26e7 | bellard | #undef REGNAME
|
117 | 14ce26e7 | bellard | |
118 | 14ce26e7 | bellard | #define REG (env->regs[15]) |
119 | 14ce26e7 | bellard | #define REGNAME _R15
|
120 | 14ce26e7 | bellard | #include "opreg_template.h" |
121 | 14ce26e7 | bellard | #undef REG
|
122 | 14ce26e7 | bellard | #undef REGNAME
|
123 | 14ce26e7 | bellard | |
124 | 14ce26e7 | bellard | #endif
|
125 | 14ce26e7 | bellard | |
126 | 2c0262af | bellard | /* multiple size ops */
|
127 | 2c0262af | bellard | |
128 | 2c0262af | bellard | #define ldul ldl
|
129 | 2c0262af | bellard | |
130 | 2c0262af | bellard | #define SHIFT 0 |
131 | 2c0262af | bellard | #include "ops_template.h" |
132 | 2c0262af | bellard | #undef SHIFT
|
133 | 2c0262af | bellard | |
134 | 2c0262af | bellard | #define SHIFT 1 |
135 | 2c0262af | bellard | #include "ops_template.h" |
136 | 2c0262af | bellard | #undef SHIFT
|
137 | 2c0262af | bellard | |
138 | 2c0262af | bellard | #define SHIFT 2 |
139 | 2c0262af | bellard | #include "ops_template.h" |
140 | 2c0262af | bellard | #undef SHIFT
|
141 | 2c0262af | bellard | |
142 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
143 | 14ce26e7 | bellard | |
144 | 14ce26e7 | bellard | #define SHIFT 3 |
145 | 14ce26e7 | bellard | #include "ops_template.h" |
146 | 14ce26e7 | bellard | #undef SHIFT
|
147 | 14ce26e7 | bellard | |
148 | 14ce26e7 | bellard | #endif
|
149 | 14ce26e7 | bellard | |
150 | 2c0262af | bellard | /* flags handling */
|
151 | 2c0262af | bellard | |
152 | 14ce26e7 | bellard | void OPPROTO op_jmp_label(void) |
153 | 14ce26e7 | bellard | { |
154 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
155 | 2c0262af | bellard | } |
156 | 2c0262af | bellard | |
157 | 14ce26e7 | bellard | void OPPROTO op_jnz_T0_label(void) |
158 | 2c0262af | bellard | { |
159 | 2c0262af | bellard | if (T0)
|
160 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
161 | 39c61f49 | bellard | FORCE_RET(); |
162 | 14ce26e7 | bellard | } |
163 | 14ce26e7 | bellard | |
164 | 2c0262af | bellard | /* slow set cases (compute x86 flags) */
|
165 | 2c0262af | bellard | void OPPROTO op_seto_T0_cc(void) |
166 | 2c0262af | bellard | { |
167 | 2c0262af | bellard | int eflags;
|
168 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
169 | 2c0262af | bellard | T0 = (eflags >> 11) & 1; |
170 | 2c0262af | bellard | } |
171 | 2c0262af | bellard | |
172 | 2c0262af | bellard | void OPPROTO op_setb_T0_cc(void) |
173 | 2c0262af | bellard | { |
174 | 2c0262af | bellard | T0 = cc_table[CC_OP].compute_c(); |
175 | 2c0262af | bellard | } |
176 | 2c0262af | bellard | |
177 | 2c0262af | bellard | void OPPROTO op_setz_T0_cc(void) |
178 | 2c0262af | bellard | { |
179 | 2c0262af | bellard | int eflags;
|
180 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
181 | 2c0262af | bellard | T0 = (eflags >> 6) & 1; |
182 | 2c0262af | bellard | } |
183 | 2c0262af | bellard | |
184 | 2c0262af | bellard | void OPPROTO op_setbe_T0_cc(void) |
185 | 2c0262af | bellard | { |
186 | 2c0262af | bellard | int eflags;
|
187 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
188 | 2c0262af | bellard | T0 = (eflags & (CC_Z | CC_C)) != 0;
|
189 | 2c0262af | bellard | } |
190 | 2c0262af | bellard | |
191 | 2c0262af | bellard | void OPPROTO op_sets_T0_cc(void) |
192 | 2c0262af | bellard | { |
193 | 2c0262af | bellard | int eflags;
|
194 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
195 | 2c0262af | bellard | T0 = (eflags >> 7) & 1; |
196 | 2c0262af | bellard | } |
197 | 2c0262af | bellard | |
198 | 2c0262af | bellard | void OPPROTO op_setp_T0_cc(void) |
199 | 2c0262af | bellard | { |
200 | 2c0262af | bellard | int eflags;
|
201 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
202 | 2c0262af | bellard | T0 = (eflags >> 2) & 1; |
203 | 2c0262af | bellard | } |
204 | 2c0262af | bellard | |
205 | 2c0262af | bellard | void OPPROTO op_setl_T0_cc(void) |
206 | 2c0262af | bellard | { |
207 | 2c0262af | bellard | int eflags;
|
208 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
209 | 2c0262af | bellard | T0 = ((eflags ^ (eflags >> 4)) >> 7) & 1; |
210 | 2c0262af | bellard | } |
211 | 2c0262af | bellard | |
212 | 2c0262af | bellard | void OPPROTO op_setle_T0_cc(void) |
213 | 2c0262af | bellard | { |
214 | 2c0262af | bellard | int eflags;
|
215 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
216 | 2c0262af | bellard | T0 = (((eflags ^ (eflags >> 4)) & 0x80) || (eflags & CC_Z)) != 0; |
217 | 2c0262af | bellard | } |
218 | 2c0262af | bellard | |
219 | 2c0262af | bellard | void OPPROTO op_xor_T0_1(void) |
220 | 2c0262af | bellard | { |
221 | 2c0262af | bellard | T0 ^= 1;
|
222 | 2c0262af | bellard | } |