OSDN Git Service

Changes to many generated files -- incorporate bochs into
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / bochs / cpu / logical16.cc
1 //  Copyright (C) 2001  MandrakeSoft S.A.
2 //
3 //    MandrakeSoft S.A.
4 //    43, rue d'Aboukir
5 //    75002 Paris - France
6 //    http://www.linux-mandrake.com/
7 //    http://www.mandrakesoft.com/
8 //
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.
13 //
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.
18 //
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
22
23
24
25
26
27
28 #define NEED_CPU_REG_SHORTCUTS 1
29 #include "bochs.h"
30 #define LOG_THIS BX_CPU_THIS_PTR
31
32
33
34
35   void
36 BX_CPU_C::XOR_EwGw(BxInstruction_t *i)
37 {
38     Bit16u op2_16, op1_16, result_16;
39
40
41     /* op2_16 is a register, op2_addr is an index of a register */
42     op2_16 = BX_READ_16BIT_REG(i->nnn);
43
44     /* op1_16 is a register or memory reference */
45     if (i->mod == 0xc0) {
46       op1_16 = BX_READ_16BIT_REG(i->rm);
47       }
48     else {
49       /* pointer, segment address pair */
50       read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
51       }
52
53     result_16 = op1_16 ^ op2_16;
54
55     /* now write result back to destination */
56     if (i->mod == 0xc0) {
57       BX_WRITE_16BIT_REG(i->rm, result_16);
58       }
59     else {
60       write_RMW_virtual_word(result_16);
61       }
62
63     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_XOR16);
64 }
65
66
67   void
68 BX_CPU_C::XOR_GwEw(BxInstruction_t *i)
69 {
70     Bit16u op1_16, op2_16, result_16;
71
72     op1_16 = BX_READ_16BIT_REG(i->nnn);
73
74     /* op2_16 is a register or memory reference */
75     if (i->mod == 0xc0) {
76       op2_16 = BX_READ_16BIT_REG(i->rm);
77       }
78     else {
79       /* pointer, segment address pair */
80       read_virtual_word(i->seg, i->rm_addr, &op2_16);
81       }
82
83     result_16 = op1_16 ^ op2_16;
84
85     /* now write result back to destination */
86     BX_WRITE_16BIT_REG(i->nnn, result_16);
87
88     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_XOR16);
89 }
90
91
92   void
93 BX_CPU_C::XOR_AXIw(BxInstruction_t *i)
94 {
95     Bit16u op1_16, op2_16, sum_16;
96
97     op1_16 = AX;
98
99     op2_16 = i->Iw;
100
101     sum_16 = op1_16 ^ op2_16;
102
103     /* now write sum back to destination */
104     AX = sum_16;
105
106     SET_FLAGS_OSZAPC_16(op1_16, op2_16, sum_16, BX_INSTR_XOR16);
107 }
108
109   void
110 BX_CPU_C::XOR_EwIw(BxInstruction_t *i)
111 {
112     Bit16u op2_16, op1_16, result_16;
113
114
115     op2_16 = i->Iw;
116
117     /* op1_16 is a register or memory reference */
118     if (i->mod == 0xc0) {
119       op1_16 = BX_READ_16BIT_REG(i->rm);
120       }
121     else {
122       /* pointer, segment address pair */
123       read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
124       }
125
126     result_16 = op1_16 ^ op2_16;
127
128     /* now write result back to destination */
129     if (i->mod == 0xc0) {
130       BX_WRITE_16BIT_REG(i->rm, result_16);
131       }
132     else {
133       write_RMW_virtual_word(result_16);
134       }
135
136     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_XOR16);
137 }
138
139
140   void
141 BX_CPU_C::OR_EwIw(BxInstruction_t *i)
142 {
143     Bit16u op2_16, op1_16, result_16;
144
145
146     op2_16 = i->Iw;
147
148     /* op1_16 is a register or memory reference */
149     if (i->mod == 0xc0) {
150       op1_16 = BX_READ_16BIT_REG(i->rm);
151       }
152     else {
153       /* pointer, segment address pair */
154       read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
155       }
156
157     result_16 = op1_16 | op2_16;
158
159     /* now write result back to destination */
160     if (i->mod == 0xc0) {
161       BX_WRITE_16BIT_REG(i->rm, result_16);
162       }
163     else {
164       write_RMW_virtual_word(result_16);
165       }
166
167     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_OR16);
168 }
169
170
171   void
172 BX_CPU_C::NOT_Ew(BxInstruction_t *i)
173 {
174     Bit16u op1_16, result_16;
175
176     /* op1 is a register or memory reference */
177     if (i->mod == 0xc0) {
178       op1_16 = BX_READ_16BIT_REG(i->rm);
179       }
180     else {
181       /* pointer, segment address pair */
182       read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
183       }
184
185     result_16 = ~op1_16;
186
187     /* now write result back to destination */
188     if (i->mod == 0xc0) {
189       BX_WRITE_16BIT_REG(i->rm, result_16);
190       }
191     else {
192       write_RMW_virtual_word(result_16);
193       }
194 }
195
196
197   void
198 BX_CPU_C::OR_EwGw(BxInstruction_t *i)
199 {
200     Bit16u op2_16, op1_16, result_16;
201
202
203     /* op2_16 is a register, op2_addr is an index of a register */
204     op2_16 = BX_READ_16BIT_REG(i->nnn);
205
206     /* op1_16 is a register or memory reference */
207     if (i->mod == 0xc0) {
208       op1_16 = BX_READ_16BIT_REG(i->rm);
209       }
210     else {
211       /* pointer, segment address pair */
212       read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
213       }
214
215     result_16 = op1_16 | op2_16;
216
217     /* now write result back to destination */
218     if (i->mod == 0xc0) {
219       BX_WRITE_16BIT_REG(i->rm, result_16);
220       }
221     else {
222       write_RMW_virtual_word(result_16);
223       }
224
225     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_OR16);
226 }
227
228
229   void
230 BX_CPU_C::OR_GwEw(BxInstruction_t *i)
231 {
232     Bit16u op1_16, op2_16, result_16;
233
234
235     op1_16 = BX_READ_16BIT_REG(i->nnn);
236
237     /* op2_16 is a register or memory reference */
238     if (i->mod == 0xc0) {
239       op2_16 = BX_READ_16BIT_REG(i->rm);
240       }
241     else {
242       /* pointer, segment address pair */
243       read_virtual_word(i->seg, i->rm_addr, &op2_16);
244       }
245
246     result_16 = op1_16 | op2_16;
247
248     /* now write result back to destination */
249     BX_WRITE_16BIT_REG(i->nnn, result_16);
250
251     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_OR16);
252 }
253
254
255   void
256 BX_CPU_C::OR_AXIw(BxInstruction_t *i)
257 {
258     Bit16u op1_16, op2_16, sum_16;
259
260     op1_16 = AX;
261
262     op2_16 = i->Iw;
263
264     sum_16 = op1_16 | op2_16;
265
266     /* now write sum back to destination */
267     AX = sum_16;
268
269     SET_FLAGS_OSZAPC_16(op1_16, op2_16, sum_16, BX_INSTR_OR16);
270 }
271
272
273
274   void
275 BX_CPU_C::AND_EwGw(BxInstruction_t *i)
276 {
277     Bit16u op2_16, op1_16, result_16;
278
279
280
281     /* op2_16 is a register, op2_addr is an index of a register */
282     op2_16 = BX_READ_16BIT_REG(i->nnn);
283
284     /* op1_16 is a register or memory reference */
285     if (i->mod == 0xc0) {
286       op1_16 = BX_READ_16BIT_REG(i->rm);
287       }
288     else {
289       /* pointer, segment address pair */
290       read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
291       }
292
293     result_16 = op1_16 & op2_16;
294
295     /* now write result back to destination */
296     if (i->mod == 0xc0) {
297       BX_WRITE_16BIT_REG(i->rm, result_16);
298       }
299     else {
300       write_RMW_virtual_word(result_16);
301       }
302
303     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_AND16);
304 }
305
306
307   void
308 BX_CPU_C::AND_GwEw(BxInstruction_t *i)
309 {
310     Bit16u op1_16, op2_16, result_16;
311
312
313     op1_16 = BX_READ_16BIT_REG(i->nnn);
314
315     /* op2_16 is a register or memory reference */
316     if (i->mod == 0xc0) {
317       op2_16 = BX_READ_16BIT_REG(i->rm);
318       }
319     else {
320       /* pointer, segment address pair */
321       read_virtual_word(i->seg, i->rm_addr, &op2_16);
322       }
323
324     result_16 = op1_16 & op2_16;
325
326     /* now write result back to destination */
327     BX_WRITE_16BIT_REG(i->nnn, result_16);
328
329     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_AND16);
330 }
331
332
333   void
334 BX_CPU_C::AND_AXIw(BxInstruction_t *i)
335 {
336     Bit16u op1_16, op2_16, sum_16;
337
338     op1_16 = AX;
339
340     op2_16 = i->Iw;
341
342     sum_16 = op1_16 & op2_16;
343
344     /* now write sum back to destination */
345     AX = sum_16;
346
347     SET_FLAGS_OSZAPC_16(op1_16, op2_16, sum_16, BX_INSTR_AND16);
348 }
349
350   void
351 BX_CPU_C::AND_EwIw(BxInstruction_t *i)
352 {
353     Bit16u op2_16, op1_16, result_16;
354
355     op2_16 = i->Iw;
356
357     /* op1_16 is a register or memory reference */
358     if (i->mod == 0xc0) {
359       op1_16 = BX_READ_16BIT_REG(i->rm);
360       }
361     else {
362       /* pointer, segment address pair */
363       read_RMW_virtual_word(i->seg, i->rm_addr, &op1_16);
364       }
365
366     result_16 = op1_16 & op2_16;
367
368     /* now write result back to destination */
369     if (i->mod == 0xc0) {
370       BX_WRITE_16BIT_REG(i->rm, result_16);
371       }
372     else {
373       write_RMW_virtual_word(result_16);
374       }
375
376     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_AND16);
377 }
378
379
380   void
381 BX_CPU_C::TEST_EwGw(BxInstruction_t *i)
382 {
383     Bit16u op2_16, op1_16, result_16;
384
385
386     /* op2_16 is a register, op2_addr is an index of a register */
387     op2_16 = BX_READ_16BIT_REG(i->nnn);
388
389     /* op1_16 is a register or memory reference */
390     if (i->mod == 0xc0) {
391       op1_16 = BX_READ_16BIT_REG(i->rm);
392       }
393     else {
394       /* pointer, segment address pair */
395       read_virtual_word(i->seg, i->rm_addr, &op1_16);
396       }
397
398     result_16 = op1_16 & op2_16;
399
400     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_TEST16);
401 }
402
403
404
405   void
406 BX_CPU_C::TEST_AXIw(BxInstruction_t *i)
407 {
408     Bit16u op2_16, op1_16, result_16;
409
410     op1_16 = AX;
411
412     /* op2_16 is imm16 */
413     op2_16 = i->Iw;
414
415     result_16 = op1_16 & op2_16;
416
417     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_TEST16);
418 }
419
420
421   void
422 BX_CPU_C::TEST_EwIw(BxInstruction_t *i)
423 {
424     Bit16u op2_16, op1_16, result_16;
425
426
427     /* op2_16 is imm16 */
428     op2_16 = i->Iw;
429
430     /* op1_16 is a register or memory reference */
431     if (i->mod == 0xc0) {
432       op1_16 = BX_READ_16BIT_REG(i->rm);
433       }
434     else {
435       /* pointer, segment address pair */
436       read_virtual_word(i->seg, i->rm_addr, &op1_16);
437       }
438
439     result_16 = op1_16 & op2_16;
440
441     SET_FLAGS_OSZAPC_16(op1_16, op2_16, result_16, BX_INSTR_TEST16);
442 }