1 /////////////////////////////////////////////////////////////////////////
2 // $Id: logical32.cc,v 1.27 2007/04/17 21:38:51 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
5 // Copyright (C) 2001 MandrakeSoft S.A.
9 // 75002 Paris - France
10 // http://www.linux-mandrake.com/
11 // http://www.mandrakesoft.com/
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2 of the License, or (at your option) any later version.
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define NEED_CPU_REG_SHORTCUTS 1
31 #define LOG_THIS BX_CPU_THIS_PTR
33 #if BX_SUPPORT_X86_64==0
34 // Make life easier for merging cpu64 and cpu32 code.
38 void BX_CPU_C::XOR_EdGd(bxInstruction_c
*i
)
40 Bit32u op2_32
, op1_32
, result_32
;
42 op2_32
= BX_READ_32BIT_REG(i
->nnn());
45 op1_32
= BX_READ_32BIT_REG(i
->rm());
46 result_32
= op1_32
^ op2_32
;
47 BX_WRITE_32BIT_REGZ(i
->rm(), result_32
);
50 read_RMW_virtual_dword(i
->seg(), RMAddr(i
), &op1_32
);
51 result_32
= op1_32
^ op2_32
;
52 write_RMW_virtual_dword(result_32
);
55 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
58 void BX_CPU_C::XOR_GdEd(bxInstruction_c
*i
)
60 Bit32u op1_32
, op2_32
, result_32
;
61 unsigned nnn
= i
->nnn();
63 op1_32
= BX_READ_32BIT_REG(nnn
);
66 op2_32
= BX_READ_32BIT_REG(i
->rm());
69 read_virtual_dword(i
->seg(), RMAddr(i
), &op2_32
);
72 result_32
= op1_32
^ op2_32
;
74 BX_WRITE_32BIT_REGZ(nnn
, result_32
);
76 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
79 void BX_CPU_C::XOR_EAXId(bxInstruction_c
*i
)
81 Bit32u op1_32
, op2_32
, result_32
;
86 result_32
= op1_32
^ op2_32
;
89 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
92 void BX_CPU_C::XOR_EdId(bxInstruction_c
*i
)
94 Bit32u op2_32
, op1_32
, result_32
;
99 op1_32
= BX_READ_32BIT_REG(i
->rm());
100 result_32
= op1_32
^ op2_32
;
101 BX_WRITE_32BIT_REGZ(i
->rm(), result_32
);
104 read_RMW_virtual_dword(i
->seg(), RMAddr(i
), &op1_32
);
105 result_32
= op1_32
^ op2_32
;
106 write_RMW_virtual_dword(result_32
);
109 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
112 void BX_CPU_C::OR_EdId(bxInstruction_c
*i
)
114 Bit32u op2_32
, op1_32
, result_32
;
119 op1_32
= BX_READ_32BIT_REG(i
->rm());
120 result_32
= op1_32
| op2_32
;
121 BX_WRITE_32BIT_REGZ(i
->rm(), result_32
);
124 read_RMW_virtual_dword(i
->seg(), RMAddr(i
), &op1_32
);
125 result_32
= op1_32
| op2_32
;
126 write_RMW_virtual_dword(result_32
);
129 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
132 void BX_CPU_C::NOT_Ed(bxInstruction_c
*i
)
134 Bit32u op1_32
, result_32
;
137 op1_32
= BX_READ_32BIT_REG(i
->rm());
139 BX_WRITE_32BIT_REGZ(i
->rm(), result_32
);
142 read_RMW_virtual_dword(i
->seg(), RMAddr(i
), &op1_32
);
144 write_RMW_virtual_dword(result_32
);
148 void BX_CPU_C::OR_EdGd(bxInstruction_c
*i
)
150 Bit32u op2_32
, op1_32
, result_32
;
152 op2_32
= BX_READ_32BIT_REG(i
->nnn());
155 op1_32
= BX_READ_32BIT_REG(i
->rm());
156 result_32
= op1_32
| op2_32
;
157 BX_WRITE_32BIT_REGZ(i
->rm(), result_32
);
160 read_RMW_virtual_dword(i
->seg(), RMAddr(i
), &op1_32
);
161 result_32
= op1_32
| op2_32
;
162 write_RMW_virtual_dword(result_32
);
165 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
168 void BX_CPU_C::OR_GdEd(bxInstruction_c
*i
)
170 Bit32u op1_32
, op2_32
, result_32
;
172 op1_32
= BX_READ_32BIT_REG(i
->nnn());
175 op2_32
= BX_READ_32BIT_REG(i
->rm());
178 read_virtual_dword(i
->seg(), RMAddr(i
), &op2_32
);
181 #if defined(BX_HostAsm_Or32)
183 asmOr32(result_32
, op1_32
, op2_32
, flags32
);
184 setEFlagsOSZAPC(flags32
);
186 result_32
= op1_32
| op2_32
;
187 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
190 BX_WRITE_32BIT_REGZ(i
->nnn(), result_32
);
193 void BX_CPU_C::OR_EAXId(bxInstruction_c
*i
)
195 Bit32u op1_32
, op2_32
, result_32
;
199 result_32
= op1_32
| op2_32
;
203 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
206 void BX_CPU_C::AND_EdGd(bxInstruction_c
*i
)
208 Bit32u op2_32
, op1_32
, result_32
;
210 op2_32
= BX_READ_32BIT_REG(i
->nnn());
213 op1_32
= BX_READ_32BIT_REG(i
->rm());
215 #if defined(BX_HostAsm_And32)
217 asmAnd32(result_32
, op1_32
, op2_32
, flags32
);
218 setEFlagsOSZAPC(flags32
);
220 result_32
= op1_32
& op2_32
;
223 BX_WRITE_32BIT_REGZ(i
->rm(), result_32
);
226 read_RMW_virtual_dword(i
->seg(), RMAddr(i
), &op1_32
);
228 #if defined(BX_HostAsm_And32)
230 asmAnd32(result_32
, op1_32
, op2_32
, flags32
);
231 setEFlagsOSZAPC(flags32
);
233 result_32
= op1_32
& op2_32
;
236 write_RMW_virtual_dword(result_32
);
239 #if !defined(BX_HostAsm_And32)
240 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
244 void BX_CPU_C::AND_GdEd(bxInstruction_c
*i
)
246 Bit32u op1_32
, op2_32
, result_32
;
248 op1_32
= BX_READ_32BIT_REG(i
->nnn());
251 op2_32
= BX_READ_32BIT_REG(i
->rm());
254 read_virtual_dword(i
->seg(), RMAddr(i
), &op2_32
);
257 #if defined(BX_HostAsm_And32)
259 asmAnd32(result_32
, op1_32
, op2_32
, flags32
);
260 setEFlagsOSZAPC(flags32
);
262 result_32
= op1_32
& op2_32
;
263 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
266 BX_WRITE_32BIT_REGZ(i
->nnn(), result_32
);
269 void BX_CPU_C::AND_EAXId(bxInstruction_c
*i
)
271 Bit32u op1_32
, op2_32
, result_32
;
276 #if defined(BX_HostAsm_And32)
278 asmAnd32(result_32
, op1_32
, op2_32
, flags32
);
279 setEFlagsOSZAPC(flags32
);
281 result_32
= op1_32
& op2_32
;
282 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
288 void BX_CPU_C::AND_EdId(bxInstruction_c
*i
)
290 Bit32u op2_32
, op1_32
, result_32
;
295 op1_32
= BX_READ_32BIT_REG(i
->rm());
297 #if defined(BX_HostAsm_And32)
299 asmAnd32(result_32
, op1_32
, op2_32
, flags32
);
300 setEFlagsOSZAPC(flags32
);
302 result_32
= op1_32
& op2_32
;
305 BX_WRITE_32BIT_REGZ(i
->rm(), result_32
);
308 read_RMW_virtual_dword(i
->seg(), RMAddr(i
), &op1_32
);
310 #if defined(BX_HostAsm_And32)
312 asmAnd32(result_32
, op1_32
, op2_32
, flags32
);
313 setEFlagsOSZAPC(flags32
);
315 result_32
= op1_32
& op2_32
;
318 write_RMW_virtual_dword(result_32
);
321 #if !defined(BX_HostAsm_And32)
322 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
326 void BX_CPU_C::TEST_EdGd(bxInstruction_c
*i
)
328 Bit32u op2_32
, op1_32
;
330 op2_32
= BX_READ_32BIT_REG(i
->nnn());
333 op1_32
= BX_READ_32BIT_REG(i
->rm());
336 read_virtual_dword(i
->seg(), RMAddr(i
), &op1_32
);
339 #if defined(BX_HostAsm_Test32)
341 asmTest32(op1_32
, op2_32
, flags32
);
342 setEFlagsOSZAPC(flags32
);
344 Bit32u result_32
= op1_32
& op2_32
;
345 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
349 void BX_CPU_C::TEST_EAXId(bxInstruction_c
*i
)
351 Bit32u op2_32
, op1_32
;
356 #if defined(BX_HostAsm_Test32)
358 asmTest32(op1_32
, op2_32
, flags32
);
359 setEFlagsOSZAPC(flags32
);
361 Bit32u result_32
= op1_32
& op2_32
;
362 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);
366 void BX_CPU_C::TEST_EdId(bxInstruction_c
*i
)
368 Bit32u op2_32
, op1_32
;
373 op1_32
= BX_READ_32BIT_REG(i
->rm());
376 read_virtual_dword(i
->seg(), RMAddr(i
), &op1_32
);
379 #if defined(BX_HostAsm_Test32)
381 asmTest32(op1_32
, op2_32
, flags32
);
382 setEFlagsOSZAPC(flags32
);
384 Bit32u result_32
= op1_32
& op2_32
;
385 SET_FLAGS_OSZAPC_RESULT_32(result_32
, BX_INSTR_LOGIC32
);