- update sector count before calling write completion function (SF patch #2144692)
[bochs-mirror.git] / cpu / logical64.cc
blob6e2e096f187577fc22fe68c4e4bb11660db12e51
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: logical64.cc,v 1.32 2008/08/11 20:34:05 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
26 /////////////////////////////////////////////////////////////////////////
28 #define NEED_CPU_REG_SHORTCUTS 1
29 #include "bochs.h"
30 #include "cpu.h"
31 #define LOG_THIS BX_CPU_THIS_PTR
33 #if BX_SUPPORT_X86_64
35 void BX_CPP_AttrRegparmN(1) BX_CPU_C::XOR_EqGqM(bxInstruction_c *i)
37 Bit64u op1_64, op2_64;
39 bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
41 op1_64 = read_RMW_virtual_qword_64(i->seg(), eaddr);
42 op2_64 = BX_READ_64BIT_REG(i->nnn());
43 op1_64 ^= op2_64;
44 write_RMW_virtual_qword(op1_64);
46 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
49 void BX_CPP_AttrRegparmN(1) BX_CPU_C::XOR_GqEqR(bxInstruction_c *i)
51 Bit64u op1_64, op2_64;
53 op1_64 = BX_READ_64BIT_REG(i->nnn());
54 op2_64 = BX_READ_64BIT_REG(i->rm());
55 op1_64 ^= op2_64;
57 /* now write result back to destination */
58 BX_WRITE_64BIT_REG(i->nnn(), op1_64);
60 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
63 void BX_CPP_AttrRegparmN(1) BX_CPU_C::XOR_RAXId(bxInstruction_c *i)
65 Bit64u op1_64, op2_64;
67 op1_64 = RAX;
68 op2_64 = (Bit32s) i->Id();
69 op1_64 ^= op2_64;
71 RAX = op1_64;
73 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
76 void BX_CPP_AttrRegparmN(1) BX_CPU_C::XOR_EqIdM(bxInstruction_c *i)
78 Bit64u op1_64, op2_64 = (Bit32s) i->Id();
80 bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
82 op1_64 = read_RMW_virtual_qword_64(i->seg(), eaddr);
83 op1_64 ^= op2_64;
84 write_RMW_virtual_qword(op1_64);
86 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
89 void BX_CPP_AttrRegparmN(1) BX_CPU_C::XOR_EqIdR(bxInstruction_c *i)
91 Bit64u op1_64, op2_64 = (Bit32s) i->Id();
93 op1_64 = BX_READ_64BIT_REG(i->rm());
94 op1_64 ^= op2_64;
95 BX_WRITE_64BIT_REG(i->rm(), op1_64);
97 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
100 void BX_CPP_AttrRegparmN(1) BX_CPU_C::OR_EqIdM(bxInstruction_c *i)
102 Bit64u op1_64, op2_64 = (Bit32s) i->Id();
104 bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
106 op1_64 = read_RMW_virtual_qword_64(i->seg(), eaddr);
107 op1_64 |= op2_64;
108 write_RMW_virtual_qword(op1_64);
110 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
113 void BX_CPP_AttrRegparmN(1) BX_CPU_C::OR_EqIdR(bxInstruction_c *i)
115 Bit64u op1_64, op2_64 = (Bit32s) i->Id();
117 op1_64 = BX_READ_64BIT_REG(i->rm());
118 op1_64 |= op2_64;
119 BX_WRITE_64BIT_REG(i->rm(), op1_64);
121 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
124 void BX_CPP_AttrRegparmN(1) BX_CPU_C::NOT_EqM(bxInstruction_c *i)
126 Bit64u op1_64;
128 bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
130 op1_64 = read_RMW_virtual_qword_64(i->seg(), eaddr);
131 op1_64 = ~op1_64;
132 write_RMW_virtual_qword(op1_64);
135 void BX_CPP_AttrRegparmN(1) BX_CPU_C::NOT_EqR(bxInstruction_c *i)
137 Bit64u op1_64 = BX_READ_64BIT_REG(i->rm());
138 op1_64 = ~op1_64;
139 BX_WRITE_64BIT_REG(i->rm(), op1_64);
142 void BX_CPP_AttrRegparmN(1) BX_CPU_C::OR_EqGqM(bxInstruction_c *i)
144 Bit64u op1_64, op2_64;
146 bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
148 op1_64 = read_RMW_virtual_qword_64(i->seg(), eaddr);
149 op2_64 = BX_READ_64BIT_REG(i->nnn());
150 op1_64 |= op2_64;
151 write_RMW_virtual_qword(op1_64);
153 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
156 void BX_CPP_AttrRegparmN(1) BX_CPU_C::OR_GqEqR(bxInstruction_c *i)
158 Bit64u op1_64, op2_64;
160 op1_64 = BX_READ_64BIT_REG(i->nnn());
161 op2_64 = BX_READ_64BIT_REG(i->rm());
162 op1_64 |= op2_64;
164 /* now write result back to destination */
165 BX_WRITE_64BIT_REG(i->nnn(), op1_64);
167 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
170 void BX_CPP_AttrRegparmN(1) BX_CPU_C::OR_RAXId(bxInstruction_c *i)
172 Bit64u op1_64, op2_64;
174 op1_64 = RAX;
175 op2_64 = (Bit32s) i->Id();
176 op1_64 |= op2_64;
178 RAX = op1_64;
180 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
183 void BX_CPP_AttrRegparmN(1) BX_CPU_C::AND_EqGqM(bxInstruction_c *i)
185 Bit64u op1_64, op2_64;
187 bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
189 op1_64 = read_RMW_virtual_qword_64(i->seg(), eaddr);
190 op2_64 = BX_READ_64BIT_REG(i->nnn());
191 op1_64 &= op2_64;
192 write_RMW_virtual_qword(op1_64);
194 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
197 void BX_CPP_AttrRegparmN(1) BX_CPU_C::AND_GqEqR(bxInstruction_c *i)
199 Bit64u op1_64, op2_64;
201 op1_64 = BX_READ_64BIT_REG(i->nnn());
202 op2_64 = BX_READ_64BIT_REG(i->rm());
203 op1_64 &= op2_64;
205 /* now write result back to destination */
206 BX_WRITE_64BIT_REG(i->nnn(), op1_64);
208 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
211 void BX_CPP_AttrRegparmN(1) BX_CPU_C::AND_RAXId(bxInstruction_c *i)
213 Bit64u op1_64, op2_64;
215 op1_64 = RAX;
216 op2_64 = (Bit32s) i->Id();
217 op1_64 &= op2_64;
218 RAX = op1_64;
220 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
223 void BX_CPP_AttrRegparmN(1) BX_CPU_C::AND_EqIdM(bxInstruction_c *i)
225 Bit64u op1_64, op2_64 = (Bit32s) i->Id();
227 bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
229 op1_64 = read_RMW_virtual_qword_64(i->seg(), eaddr);
230 op1_64 &= op2_64;
231 write_RMW_virtual_qword(op1_64);
233 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
236 void BX_CPP_AttrRegparmN(1) BX_CPU_C::AND_EqIdR(bxInstruction_c *i)
238 Bit64u op1_64, op2_64 = (Bit32s) i->Id();
240 op1_64 = BX_READ_64BIT_REG(i->rm());
241 op1_64 &= op2_64;
242 BX_WRITE_64BIT_REG(i->rm(), op1_64);
244 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
247 void BX_CPP_AttrRegparmN(1) BX_CPU_C::TEST_EqGqR(bxInstruction_c *i)
249 Bit64u op1_64, op2_64;
251 op1_64 = BX_READ_64BIT_REG(i->rm());
252 op2_64 = BX_READ_64BIT_REG(i->nnn());
253 op1_64 &= op2_64;
255 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
258 void BX_CPP_AttrRegparmN(1) BX_CPU_C::TEST_RAXId(bxInstruction_c *i)
260 Bit64u op1_64, op2_64;
262 op1_64 = RAX;
263 op2_64 = (Bit32s) i->Id();
264 op1_64 &= op2_64;
266 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
269 void BX_CPP_AttrRegparmN(1) BX_CPU_C::TEST_EqIdR(bxInstruction_c *i)
271 Bit64u op1_64, op2_64;
273 op1_64 = BX_READ_64BIT_REG(i->rm());
274 op2_64 = (Bit32s) i->Id();
275 op1_64 &= op2_64;
277 SET_FLAGS_OSZAPC_LOGIC_64(op1_64);
280 #endif /* if BX_SUPPORT_X86_64 */