1 // Copyright (C) 2001 MandrakeSoft S.A.
5 // 75002 Paris - France
6 // http://www.linux-mandrake.com/
7 // http://www.mandrakesoft.com/
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define NEED_CPU_REG_SHORTCUTS 1
30 #define LOG_THIS BX_CPU_THIS_PTR
36 BX_CPU_C::XOR_EwGw(BxInstruction_t *i)
38 Bit16u op2_16, op1_16, result_16;
41 /* op2_16 is a register, op2_addr is an index of a register */
42 op2_16 = BX_READ_16BIT_REG(i->nnn);
44 /* op1_16 is a register or memory reference */
46 op1_16 = BX_READ_16BIT_REG(i->rm);
49 /* pointer, segment address pair */
50 read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
53 result_16 = op1_16 ^ op2_16;
55 /* now write result back to destination */
57 BX_WRITE_16BIT_REG(i->rm, result_16);
60 write_RMW_virtual_word(result_16);
63 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_XOR16);
68 BX_CPU_C::XOR_GwEw(BxInstruction_t *i)
70 Bit16u op1_16, op2_16, result_16;
72 op1_16 = BX_READ_16BIT_REG(i->nnn);
74 /* op2_16 is a register or memory reference */
76 op2_16 = BX_READ_16BIT_REG(i->rm);
79 /* pointer, segment address pair */
80 read_virtual_word(i->seg, i->rm_addr, &op2_16);
83 result_16 = op1_16 ^ op2_16;
85 /* now write result back to destination */
86 BX_WRITE_16BIT_REG(i->nnn, result_16);
88 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_XOR16);
93 BX_CPU_C::XOR_AXIw(BxInstruction_t *i)
95 Bit16u op1_16, op2_16, sum_16;
101 sum_16 = op1_16 ^ op2_16;
103 /* now write sum back to destination */
106 SET_FLAGS_OSZAPC_16(op1_16, op2_16, sum_16, BX_INSTR_XOR16);
110 BX_CPU_C::XOR_EwIw(BxInstruction_t *i)
112 Bit16u op2_16, op1_16, result_16;
117 /* op1_16 is a register or memory reference */
118 if (i->mod == 0xc0) {
119 op1_16 = BX_READ_16BIT_REG(i->rm);
122 /* pointer, segment address pair */
123 read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
126 result_16 = op1_16 ^ op2_16;
128 /* now write result back to destination */
129 if (i->mod == 0xc0) {
130 BX_WRITE_16BIT_REG(i->rm, result_16);
133 write_RMW_virtual_word(result_16);
136 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_XOR16);
141 BX_CPU_C::OR_EwIw(BxInstruction_t *i)
143 Bit16u op2_16, op1_16, result_16;
148 /* op1_16 is a register or memory reference */
149 if (i->mod == 0xc0) {
150 op1_16 = BX_READ_16BIT_REG(i->rm);
153 /* pointer, segment address pair */
154 read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
157 result_16 = op1_16 | op2_16;
159 /* now write result back to destination */
160 if (i->mod == 0xc0) {
161 BX_WRITE_16BIT_REG(i->rm, result_16);
164 write_RMW_virtual_word(result_16);
167 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_OR16);
172 BX_CPU_C::NOT_Ew(BxInstruction_t *i)
174 Bit16u op1_16, result_16;
176 /* op1 is a register or memory reference */
177 if (i->mod == 0xc0) {
178 op1_16 = BX_READ_16BIT_REG(i->rm);
181 /* pointer, segment address pair */
182 read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
187 /* now write result back to destination */
188 if (i->mod == 0xc0) {
189 BX_WRITE_16BIT_REG(i->rm, result_16);
192 write_RMW_virtual_word(result_16);
198 BX_CPU_C::OR_EwGw(BxInstruction_t *i)
200 Bit16u op2_16, op1_16, result_16;
203 /* op2_16 is a register, op2_addr is an index of a register */
204 op2_16 = BX_READ_16BIT_REG(i->nnn);
206 /* op1_16 is a register or memory reference */
207 if (i->mod == 0xc0) {
208 op1_16 = BX_READ_16BIT_REG(i->rm);
211 /* pointer, segment address pair */
212 read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
215 result_16 = op1_16 | op2_16;
217 /* now write result back to destination */
218 if (i->mod == 0xc0) {
219 BX_WRITE_16BIT_REG(i->rm, result_16);
222 write_RMW_virtual_word(result_16);
225 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_OR16);
230 BX_CPU_C::OR_GwEw(BxInstruction_t *i)
232 Bit16u op1_16, op2_16, result_16;
235 op1_16 = BX_READ_16BIT_REG(i->nnn);
237 /* op2_16 is a register or memory reference */
238 if (i->mod == 0xc0) {
239 op2_16 = BX_READ_16BIT_REG(i->rm);
242 /* pointer, segment address pair */
243 read_virtual_word(i->seg, i->rm_addr, &op2_16);
246 result_16 = op1_16 | op2_16;
248 /* now write result back to destination */
249 BX_WRITE_16BIT_REG(i->nnn, result_16);
251 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_OR16);
256 BX_CPU_C::OR_AXIw(BxInstruction_t *i)
258 Bit16u op1_16, op2_16, sum_16;
264 sum_16 = op1_16 | op2_16;
266 /* now write sum back to destination */
269 SET_FLAGS_OSZAPC_16(op1_16, op2_16, sum_16, BX_INSTR_OR16);
275 BX_CPU_C::AND_EwGw(BxInstruction_t *i)
277 Bit16u op2_16, op1_16, result_16;
281 /* op2_16 is a register, op2_addr is an index of a register */
282 op2_16 = BX_READ_16BIT_REG(i->nnn);
284 /* op1_16 is a register or memory reference */
285 if (i->mod == 0xc0) {
286 op1_16 = BX_READ_16BIT_REG(i->rm);
289 /* pointer, segment address pair */
290 read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
293 result_16 = op1_16 & op2_16;
295 /* now write result back to destination */
296 if (i->mod == 0xc0) {
297 BX_WRITE_16BIT_REG(i->rm, result_16);
300 write_RMW_virtual_word(result_16);
303 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_AND16);
308 BX_CPU_C::AND_GwEw(BxInstruction_t *i)
310 Bit16u op1_16, op2_16, result_16;
313 op1_16 = BX_READ_16BIT_REG(i->nnn);
315 /* op2_16 is a register or memory reference */
316 if (i->mod == 0xc0) {
317 op2_16 = BX_READ_16BIT_REG(i->rm);
320 /* pointer, segment address pair */
321 read_virtual_word(i->seg, i->rm_addr, &op2_16);
324 result_16 = op1_16 & op2_16;
326 /* now write result back to destination */
327 BX_WRITE_16BIT_REG(i->nnn, result_16);
329 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_AND16);
334 BX_CPU_C::AND_AXIw(BxInstruction_t *i)
336 Bit16u op1_16, op2_16, sum_16;
342 sum_16 = op1_16 & op2_16;
344 /* now write sum back to destination */
347 SET_FLAGS_OSZAPC_16(op1_16, op2_16, sum_16, BX_INSTR_AND16);
351 BX_CPU_C::AND_EwIw(BxInstruction_t *i)
353 Bit16u op2_16, op1_16, result_16;
357 /* op1_16 is a register or memory reference */
358 if (i->mod == 0xc0) {
359 op1_16 = BX_READ_16BIT_REG(i->rm);
362 /* pointer, segment address pair */
363 read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
366 result_16 = op1_16 & op2_16;
368 /* now write result back to destination */
369 if (i->mod == 0xc0) {
370 BX_WRITE_16BIT_REG(i->rm, result_16);
373 write_RMW_virtual_word(result_16);
376 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_AND16);
381 BX_CPU_C::TEST_EwGw(BxInstruction_t *i)
383 Bit16u op2_16, op1_16, result_16;
386 /* op2_16 is a register, op2_addr is an index of a register */
387 op2_16 = BX_READ_16BIT_REG(i->nnn);
389 /* op1_16 is a register or memory reference */
390 if (i->mod == 0xc0) {
391 op1_16 = BX_READ_16BIT_REG(i->rm);
394 /* pointer, segment address pair */
395 read_virtual_word(i->seg, i->rm_addr, &op1_16);
398 result_16 = op1_16 & op2_16;
400 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_TEST16);
406 BX_CPU_C::TEST_AXIw(BxInstruction_t *i)
408 Bit16u op2_16, op1_16, result_16;
412 /* op2_16 is imm16 */
415 result_16 = op1_16 & op2_16;
417 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_TEST16);
422 BX_CPU_C::TEST_EwIw(BxInstruction_t *i)
424 Bit16u op2_16, op1_16, result_16;
427 /* op2_16 is imm16 */
430 /* op1_16 is a register or memory reference */
431 if (i->mod == 0xc0) {
432 op1_16 = BX_READ_16BIT_REG(i->rm);
435 /* pointer, segment address pair */
436 read_virtual_word(i->seg, i->rm_addr, &op1_16);
439 result_16 = op1_16 & op2_16;
441 SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_TEST16);