1 /////////////////////////////////////////////////////////////////////////
2 // $Id: logical16.cc,v 1.26 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
34 void BX_CPU_C::XOR_EwGw(bxInstruction_c
*i
)
36 Bit16u op2_16
, op1_16
, result_16
;
38 op2_16
= BX_READ_16BIT_REG(i
->nnn());
41 op1_16
= BX_READ_16BIT_REG(i
->rm());
43 #if defined(BX_HostAsm_Xor16)
45 asmXor16(result_16
, op1_16
, op2_16
, flags32
);
46 setEFlagsOSZAPC(flags32
);
48 result_16
= op1_16
^ op2_16
;
50 BX_WRITE_16BIT_REG(i
->rm(), result_16
);
53 read_RMW_virtual_word(i
->seg(), RMAddr(i
), &op1_16
);
54 #if defined(BX_HostAsm_Xor16)
56 asmXor16(result_16
, op1_16
, op2_16
, flags32
);
57 setEFlagsOSZAPC(flags32
);
59 result_16
= op1_16
^ op2_16
;
61 write_RMW_virtual_word(result_16
);
64 #if !defined(BX_HostAsm_Xor16)
65 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
69 void BX_CPU_C::XOR_GwEw(bxInstruction_c
*i
)
71 Bit16u op1_16
, op2_16
, result_16
;
72 unsigned nnn
= i
->nnn();
74 op1_16
= BX_READ_16BIT_REG(nnn
);
77 op2_16
= BX_READ_16BIT_REG(i
->rm());
80 read_virtual_word(i
->seg(), RMAddr(i
), &op2_16
);
83 result_16
= op1_16
^ op2_16
;
85 BX_WRITE_16BIT_REG(nnn
, result_16
);
87 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
90 void BX_CPU_C::XOR_AXIw(bxInstruction_c
*i
)
92 Bit16u op1_16
, op2_16
, result_16
;
96 result_16
= op1_16
^ op2_16
;
99 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
102 void BX_CPU_C::XOR_EwIw(bxInstruction_c
*i
)
104 Bit16u op2_16
, op1_16
, result_16
;
109 op1_16
= BX_READ_16BIT_REG(i
->rm());
110 result_16
= op1_16
^ op2_16
;
111 BX_WRITE_16BIT_REG(i
->rm(), result_16
);
114 read_RMW_virtual_word(i
->seg(), RMAddr(i
), &op1_16
);
115 result_16
= op1_16
^ op2_16
;
116 write_RMW_virtual_word(result_16
);
119 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
122 void BX_CPU_C::OR_EwIw(bxInstruction_c
*i
)
124 Bit16u op2_16
, op1_16
, result_16
;
129 op1_16
= BX_READ_16BIT_REG(i
->rm());
130 result_16
= op1_16
| op2_16
;
131 BX_WRITE_16BIT_REG(i
->rm(), result_16
);
134 read_RMW_virtual_word(i
->seg(), RMAddr(i
), &op1_16
);
135 result_16
= op1_16
| op2_16
;
136 write_RMW_virtual_word(result_16
);
139 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
142 void BX_CPU_C::NOT_Ew(bxInstruction_c
*i
)
144 Bit16u op1_16
, result_16
;
147 op1_16
= BX_READ_16BIT_REG(i
->rm());
149 BX_WRITE_16BIT_REG(i
->rm(), result_16
);
152 read_RMW_virtual_word(i
->seg(), RMAddr(i
), &op1_16
);
154 write_RMW_virtual_word(result_16
);
158 void BX_CPU_C::OR_EwGw(bxInstruction_c
*i
)
160 Bit16u op2_16
, op1_16
, result_16
;
162 op2_16
= BX_READ_16BIT_REG(i
->nnn());
165 op1_16
= BX_READ_16BIT_REG(i
->rm());
166 result_16
= op1_16
| op2_16
;
167 BX_WRITE_16BIT_REG(i
->rm(), result_16
);
170 read_RMW_virtual_word(i
->seg(), RMAddr(i
), &op1_16
);
171 result_16
= op1_16
| op2_16
;
172 write_RMW_virtual_word(result_16
);
175 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
178 void BX_CPU_C::OR_GwEw(bxInstruction_c
*i
)
180 Bit16u op1_16
, op2_16
, result_16
;
182 op1_16
= BX_READ_16BIT_REG(i
->nnn());
185 op2_16
= BX_READ_16BIT_REG(i
->rm());
188 read_virtual_word(i
->seg(), RMAddr(i
), &op2_16
);
191 #if defined(BX_HostAsm_Or16)
193 asmOr16(result_16
, op1_16
, op2_16
, flags32
);
194 setEFlagsOSZAPC(flags32
);
196 result_16
= op1_16
| op2_16
;
197 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
200 BX_WRITE_16BIT_REG(i
->nnn(), result_16
);
203 void BX_CPU_C::OR_AXIw(bxInstruction_c
*i
)
205 Bit16u op1_16
, op2_16
, result_16
;
209 result_16
= op1_16
| op2_16
;
212 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
215 void BX_CPU_C::AND_EwGw(bxInstruction_c
*i
)
217 Bit16u op2_16
, op1_16
, result_16
;
219 op2_16
= BX_READ_16BIT_REG(i
->nnn());
222 op1_16
= BX_READ_16BIT_REG(i
->rm());
224 #if defined(BX_HostAsm_And16)
226 asmAnd16(result_16
, op1_16
, op2_16
, flags32
);
227 setEFlagsOSZAPC(flags32
);
229 result_16
= op1_16
& op2_16
;
232 BX_WRITE_16BIT_REG(i
->rm(), result_16
);
235 read_RMW_virtual_word(i
->seg(), RMAddr(i
), &op1_16
);
237 #if defined(BX_HostAsm_And16)
239 asmAnd16(result_16
, op1_16
, op2_16
, flags32
);
240 setEFlagsOSZAPC(flags32
);
242 result_16
= op1_16
& op2_16
;
245 write_RMW_virtual_word(result_16
);
248 #if !defined(BX_HostAsm_And16)
249 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
253 void BX_CPU_C::AND_GwEw(bxInstruction_c
*i
)
255 Bit16u op1_16
, op2_16
, result_16
;
257 op1_16
= BX_READ_16BIT_REG(i
->nnn());
260 op2_16
= BX_READ_16BIT_REG(i
->rm());
263 read_virtual_word(i
->seg(), RMAddr(i
), &op2_16
);
266 #if defined(BX_HostAsm_And16)
268 asmAnd16(result_16
, op1_16
, op2_16
, flags32
);
269 setEFlagsOSZAPC(flags32
);
271 result_16
= op1_16
& op2_16
;
272 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
275 BX_WRITE_16BIT_REG(i
->nnn(), result_16
);
278 void BX_CPU_C::AND_AXIw(bxInstruction_c
*i
)
280 Bit16u op1_16
, op2_16
, result_16
;
285 #if defined(BX_HostAsm_And16)
287 asmAnd16(result_16
, op1_16
, op2_16
, flags32
);
288 setEFlagsOSZAPC(flags32
);
290 result_16
= op1_16
& op2_16
;
291 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
297 void BX_CPU_C::AND_EwIw(bxInstruction_c
*i
)
299 Bit16u op2_16
, op1_16
, result_16
;
304 op1_16
= BX_READ_16BIT_REG(i
->rm());
306 #if defined(BX_HostAsm_And16)
308 asmAnd16(result_16
, op1_16
, op2_16
, flags32
);
309 setEFlagsOSZAPC(flags32
);
311 result_16
= op1_16
& op2_16
;
314 BX_WRITE_16BIT_REG(i
->rm(), result_16
);
317 read_RMW_virtual_word(i
->seg(), RMAddr(i
), &op1_16
);
319 #if defined(BX_HostAsm_And16)
321 asmAnd16(result_16
, op1_16
, op2_16
, flags32
);
322 setEFlagsOSZAPC(flags32
);
324 result_16
= op1_16
& op2_16
;
327 write_RMW_virtual_word(result_16
);
330 #if !defined(BX_HostAsm_And16)
331 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
335 void BX_CPU_C::TEST_EwGw(bxInstruction_c
*i
)
337 Bit16u op2_16
, op1_16
;
339 op2_16
= BX_READ_16BIT_REG(i
->nnn());
342 op1_16
= BX_READ_16BIT_REG(i
->rm());
345 read_virtual_word(i
->seg(), RMAddr(i
), &op1_16
);
348 #if defined(BX_HostAsm_Test16)
350 asmTest16(op1_16
, op2_16
, flags32
);
351 setEFlagsOSZAPC(flags32
);
353 Bit16u result_16
= op1_16
& op2_16
;
354 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
358 void BX_CPU_C::TEST_AXIw(bxInstruction_c
*i
)
360 Bit16u op2_16
, op1_16
;
365 #if defined(BX_HostAsm_Test16)
367 asmTest16(op1_16
, op2_16
, flags32
);
368 setEFlagsOSZAPC(flags32
);
370 Bit16u result_16
= op1_16
& op2_16
;
371 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);
375 void BX_CPU_C::TEST_EwIw(bxInstruction_c
*i
)
377 Bit16u op2_16
, op1_16
;
382 op1_16
= BX_READ_16BIT_REG(i
->rm());
385 read_virtual_word(i
->seg(), RMAddr(i
), &op1_16
);
388 #if defined(BX_HostAsm_Test16)
390 asmTest16(op1_16
, op2_16
, flags32
);
391 setEFlagsOSZAPC(flags32
);
393 Bit16u result_16
= op1_16
& op2_16
;
394 SET_FLAGS_OSZAPC_RESULT_16(result_16
, BX_INSTR_LOGIC16
);