- compare disk size with the size calculated from geometry to avoid image
[bochs-mirror.git] / cpu / logical16.cc
blob3928f4d78d99d62e5703f51f5754edec340568e3
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: logical16.cc,v 1.26 2007/04/17 21:38:51 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2001 MandrakeSoft S.A.
6 //
7 // MandrakeSoft S.A.
8 // 43, rue d'Aboukir
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
29 #include "bochs.h"
30 #include "cpu.h"
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());
40 if (i->modC0()) {
41 op1_16 = BX_READ_16BIT_REG(i->rm());
43 #if defined(BX_HostAsm_Xor16)
44 Bit32u flags32;
45 asmXor16(result_16, op1_16, op2_16, flags32);
46 setEFlagsOSZAPC(flags32);
47 #else
48 result_16 = op1_16 ^ op2_16;
49 #endif
50 BX_WRITE_16BIT_REG(i->rm(), result_16);
52 else {
53 read_RMW_virtual_word(i->seg(), RMAddr(i), &op1_16);
54 #if defined(BX_HostAsm_Xor16)
55 Bit32u flags32;
56 asmXor16(result_16, op1_16, op2_16, flags32);
57 setEFlagsOSZAPC(flags32);
58 #else
59 result_16 = op1_16 ^ op2_16;
60 #endif
61 write_RMW_virtual_word(result_16);
64 #if !defined(BX_HostAsm_Xor16)
65 SET_FLAGS_OSZAPC_RESULT_16(result_16, BX_INSTR_LOGIC16);
66 #endif
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);
76 if (i->modC0()) {
77 op2_16 = BX_READ_16BIT_REG(i->rm());
79 else {
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;
94 op1_16 = AX;
95 op2_16 = i->Iw();
96 result_16 = op1_16 ^ op2_16;
97 AX = result_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;
106 op2_16 = i->Iw();
108 if (i->modC0()) {
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);
113 else {
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;
126 op2_16 = i->Iw();
128 if (i->modC0()) {
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);
133 else {
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;
146 if (i->modC0()) {
147 op1_16 = BX_READ_16BIT_REG(i->rm());
148 result_16 = ~op1_16;
149 BX_WRITE_16BIT_REG(i->rm(), result_16);
151 else {
152 read_RMW_virtual_word(i->seg(), RMAddr(i), &op1_16);
153 result_16 = ~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());
164 if (i->modC0()) {
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);
169 else {
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());
184 if (i->modC0()) {
185 op2_16 = BX_READ_16BIT_REG(i->rm());
187 else {
188 read_virtual_word(i->seg(), RMAddr(i), &op2_16);
191 #if defined(BX_HostAsm_Or16)
192 Bit32u flags32;
193 asmOr16(result_16, op1_16, op2_16, flags32);
194 setEFlagsOSZAPC(flags32);
195 #else
196 result_16 = op1_16 | op2_16;
197 SET_FLAGS_OSZAPC_RESULT_16(result_16, BX_INSTR_LOGIC16);
198 #endif
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;
207 op1_16 = AX;
208 op2_16 = i->Iw();
209 result_16 = op1_16 | op2_16;
210 AX = result_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());
221 if (i->modC0()) {
222 op1_16 = BX_READ_16BIT_REG(i->rm());
224 #if defined(BX_HostAsm_And16)
225 Bit32u flags32;
226 asmAnd16(result_16, op1_16, op2_16, flags32);
227 setEFlagsOSZAPC(flags32);
228 #else
229 result_16 = op1_16 & op2_16;
230 #endif
232 BX_WRITE_16BIT_REG(i->rm(), result_16);
234 else {
235 read_RMW_virtual_word(i->seg(), RMAddr(i), &op1_16);
237 #if defined(BX_HostAsm_And16)
238 Bit32u flags32;
239 asmAnd16(result_16, op1_16, op2_16, flags32);
240 setEFlagsOSZAPC(flags32);
241 #else
242 result_16 = op1_16 & op2_16;
243 #endif
245 write_RMW_virtual_word(result_16);
248 #if !defined(BX_HostAsm_And16)
249 SET_FLAGS_OSZAPC_RESULT_16(result_16, BX_INSTR_LOGIC16);
250 #endif
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());
259 if (i->modC0()) {
260 op2_16 = BX_READ_16BIT_REG(i->rm());
262 else {
263 read_virtual_word(i->seg(), RMAddr(i), &op2_16);
266 #if defined(BX_HostAsm_And16)
267 Bit32u flags32;
268 asmAnd16(result_16, op1_16, op2_16, flags32);
269 setEFlagsOSZAPC(flags32);
270 #else
271 result_16 = op1_16 & op2_16;
272 SET_FLAGS_OSZAPC_RESULT_16(result_16, BX_INSTR_LOGIC16);
273 #endif
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;
282 op1_16 = AX;
283 op2_16 = i->Iw();
285 #if defined(BX_HostAsm_And16)
286 Bit32u flags32;
287 asmAnd16(result_16, op1_16, op2_16, flags32);
288 setEFlagsOSZAPC(flags32);
289 #else
290 result_16 = op1_16 & op2_16;
291 SET_FLAGS_OSZAPC_RESULT_16(result_16, BX_INSTR_LOGIC16);
292 #endif
294 AX = result_16;
297 void BX_CPU_C::AND_EwIw(bxInstruction_c *i)
299 Bit16u op2_16, op1_16, result_16;
301 op2_16 = i->Iw();
303 if (i->modC0()) {
304 op1_16 = BX_READ_16BIT_REG(i->rm());
306 #if defined(BX_HostAsm_And16)
307 Bit32u flags32;
308 asmAnd16(result_16, op1_16, op2_16, flags32);
309 setEFlagsOSZAPC(flags32);
310 #else
311 result_16 = op1_16 & op2_16;
312 #endif
314 BX_WRITE_16BIT_REG(i->rm(), result_16);
316 else {
317 read_RMW_virtual_word(i->seg(), RMAddr(i), &op1_16);
319 #if defined(BX_HostAsm_And16)
320 Bit32u flags32;
321 asmAnd16(result_16, op1_16, op2_16, flags32);
322 setEFlagsOSZAPC(flags32);
323 #else
324 result_16 = op1_16 & op2_16;
325 #endif
327 write_RMW_virtual_word(result_16);
330 #if !defined(BX_HostAsm_And16)
331 SET_FLAGS_OSZAPC_RESULT_16(result_16, BX_INSTR_LOGIC16);
332 #endif
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());
341 if (i->modC0()) {
342 op1_16 = BX_READ_16BIT_REG(i->rm());
344 else {
345 read_virtual_word(i->seg(), RMAddr(i), &op1_16);
348 #if defined(BX_HostAsm_Test16)
349 Bit32u flags32;
350 asmTest16(op1_16, op2_16, flags32);
351 setEFlagsOSZAPC(flags32);
352 #else
353 Bit16u result_16 = op1_16 & op2_16;
354 SET_FLAGS_OSZAPC_RESULT_16(result_16, BX_INSTR_LOGIC16);
355 #endif
358 void BX_CPU_C::TEST_AXIw(bxInstruction_c *i)
360 Bit16u op2_16, op1_16;
362 op1_16 = AX;
363 op2_16 = i->Iw();
365 #if defined(BX_HostAsm_Test16)
366 Bit32u flags32;
367 asmTest16(op1_16, op2_16, flags32);
368 setEFlagsOSZAPC(flags32);
369 #else
370 Bit16u result_16 = op1_16 & op2_16;
371 SET_FLAGS_OSZAPC_RESULT_16(result_16, BX_INSTR_LOGIC16);
372 #endif
375 void BX_CPU_C::TEST_EwIw(bxInstruction_c *i)
377 Bit16u op2_16, op1_16;
379 op2_16 = i->Iw();
381 if (i->modC0()) {
382 op1_16 = BX_READ_16BIT_REG(i->rm());
384 else {
385 read_virtual_word(i->seg(), RMAddr(i), &op1_16);
388 #if defined(BX_HostAsm_Test16)
389 Bit32u flags32;
390 asmTest16(op1_16, op2_16, flags32);
391 setEFlagsOSZAPC(flags32);
392 #else
393 Bit16u result_16 = op1_16 & op2_16;
394 SET_FLAGS_OSZAPC_RESULT_16(result_16, BX_INSTR_LOGIC16);
395 #endif