OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [bochs486/] [cpu/] [bit.cc] - Blame information for rev 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/////////////////////////////////////////////////////////////////////////
2
// $Id: bit.cc 11313 2012-08-05 13:52:40Z sshwarts $
3
/////////////////////////////////////////////////////////////////////////
4
//
5
//  Copyright (C) 2001-2012  The Bochs Project
6
//
7
//  This library is free software; you can redistribute it and/or
8
//  modify it under the terms of the GNU Lesser General Public
9
//  License as published by the Free Software Foundation; either
10
//  version 2 of the License, or (at your option) any later version.
11
//
12
//  This library is distributed in the hope that it will be useful,
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
//  Lesser General Public License for more details.
16
//
17
//  You should have received a copy of the GNU Lesser General Public
18
//  License along with this library; if not, write to the Free Software
19
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
20
/////////////////////////////////////////////////////////////////////////
21
 
22
#define NEED_CPU_REG_SHORTCUTS 1
23
#include "bochs.h"
24
#include "cpu.h"
25
#define LOG_THIS BX_CPU_THIS_PTR
26
 
27
#if BX_CPU_LEVEL >= 3
28
 
29
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETO_EbM(bxInstruction_c *i)
30
{
31
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
32
 
33
  Bit8u result_8 = getB_OF();
34
  write_virtual_byte(i->seg(), eaddr, result_8);
35
 
36
  BX_NEXT_INSTR(i);
37
}
38
 
39
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETO_EbR(bxInstruction_c *i)
40
{
41
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), getB_OF());
42
 
43
  BX_NEXT_INSTR(i);
44
}
45
 
46
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNO_EbM(bxInstruction_c *i)
47
{
48
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
49
 
50
  Bit8u result_8 = !getB_OF();
51
  write_virtual_byte(i->seg(), eaddr, result_8);
52
 
53
  BX_NEXT_INSTR(i);
54
}
55
 
56
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNO_EbR(bxInstruction_c *i)
57
{
58
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), !getB_OF());
59
 
60
  BX_NEXT_INSTR(i);
61
}
62
 
63
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETB_EbM(bxInstruction_c *i)
64
{
65
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
66
 
67
  Bit8u result_8 = getB_CF();
68
  write_virtual_byte(i->seg(), eaddr, result_8);
69
 
70
  BX_NEXT_INSTR(i);
71
}
72
 
73
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETB_EbR(bxInstruction_c *i)
74
{
75
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), getB_CF());
76
 
77
  BX_NEXT_INSTR(i);
78
}
79
 
80
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNB_EbM(bxInstruction_c *i)
81
{
82
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
83
 
84
  Bit8u result_8 = !getB_CF();
85
  write_virtual_byte(i->seg(), eaddr, result_8);
86
 
87
  BX_NEXT_INSTR(i);
88
}
89
 
90
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNB_EbR(bxInstruction_c *i)
91
{
92
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), !getB_CF());
93
 
94
  BX_NEXT_INSTR(i);
95
}
96
 
97
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETZ_EbM(bxInstruction_c *i)
98
{
99
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
100
 
101
  Bit8u result_8 = getB_ZF();
102
  write_virtual_byte(i->seg(), eaddr, result_8);
103
 
104
  BX_NEXT_INSTR(i);
105
}
106
 
107
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETZ_EbR(bxInstruction_c *i)
108
{
109
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), getB_ZF());
110
 
111
  BX_NEXT_INSTR(i);
112
}
113
 
114
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNZ_EbM(bxInstruction_c *i)
115
{
116
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
117
 
118
  Bit8u result_8 = !getB_ZF();
119
  write_virtual_byte(i->seg(), eaddr, result_8);
120
 
121
  BX_NEXT_INSTR(i);
122
}
123
 
124
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNZ_EbR(bxInstruction_c *i)
125
{
126
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), !getB_ZF());
127
 
128
  BX_NEXT_INSTR(i);
129
}
130
 
131
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETBE_EbM(bxInstruction_c *i)
132
{
133
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
134
 
135
  Bit8u result_8 = (getB_CF() | getB_ZF());
136
  write_virtual_byte(i->seg(), eaddr, result_8);
137
 
138
  BX_NEXT_INSTR(i);
139
}
140
 
141
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETBE_EbR(bxInstruction_c *i)
142
{
143
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), (getB_CF() | getB_ZF()));
144
 
145
  BX_NEXT_INSTR(i);
146
}
147
 
148
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNBE_EbM(bxInstruction_c *i)
149
{
150
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
151
 
152
  Bit8u result_8 = !(getB_CF() | getB_ZF());
153
  write_virtual_byte(i->seg(), eaddr, result_8);
154
 
155
  BX_NEXT_INSTR(i);
156
}
157
 
158
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNBE_EbR(bxInstruction_c *i)
159
{
160
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), !(getB_CF() | getB_ZF()));
161
 
162
  BX_NEXT_INSTR(i);
163
}
164
 
165
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETS_EbM(bxInstruction_c *i)
166
{
167
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
168
 
169
  Bit8u result_8 = getB_SF();
170
  write_virtual_byte(i->seg(), eaddr, result_8);
171
 
172
  BX_NEXT_INSTR(i);
173
}
174
 
175
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETS_EbR(bxInstruction_c *i)
176
{
177
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), getB_SF());
178
 
179
  BX_NEXT_INSTR(i);
180
}
181
 
182
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNS_EbM(bxInstruction_c *i)
183
{
184
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
185
 
186
  Bit8u result_8 = !getB_SF();
187
  write_virtual_byte(i->seg(), eaddr, result_8);
188
 
189
  BX_NEXT_INSTR(i);
190
}
191
 
192
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNS_EbR(bxInstruction_c *i)
193
{
194
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), !getB_SF());
195
 
196
  BX_NEXT_INSTR(i);
197
}
198
 
199
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETP_EbM(bxInstruction_c *i)
200
{
201
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
202
 
203
  Bit8u result_8 = getB_PF();
204
  write_virtual_byte(i->seg(), eaddr, result_8);
205
 
206
  BX_NEXT_INSTR(i);
207
}
208
 
209
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETP_EbR(bxInstruction_c *i)
210
{
211
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), getB_PF());
212
 
213
  BX_NEXT_INSTR(i);
214
}
215
 
216
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNP_EbM(bxInstruction_c *i)
217
{
218
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
219
 
220
  Bit8u result_8 = !getB_PF();
221
  write_virtual_byte(i->seg(), eaddr, result_8);
222
 
223
  BX_NEXT_INSTR(i);
224
}
225
 
226
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNP_EbR(bxInstruction_c *i)
227
{
228
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), !getB_PF());
229
 
230
  BX_NEXT_INSTR(i);
231
}
232
 
233
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETL_EbM(bxInstruction_c *i)
234
{
235
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
236
 
237
  Bit8u result_8 = (getB_SF() ^ getB_OF());
238
  write_virtual_byte(i->seg(), eaddr, result_8);
239
 
240
  BX_NEXT_INSTR(i);
241
}
242
 
243
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETL_EbR(bxInstruction_c *i)
244
{
245
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), (getB_SF() ^ getB_OF()));
246
 
247
  BX_NEXT_INSTR(i);
248
}
249
 
250
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNL_EbM(bxInstruction_c *i)
251
{
252
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
253
 
254
  Bit8u result_8 = !(getB_SF() ^ getB_OF());
255
  write_virtual_byte(i->seg(), eaddr, result_8);
256
 
257
  BX_NEXT_INSTR(i);
258
}
259
 
260
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNL_EbR(bxInstruction_c *i)
261
{
262
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), !(getB_SF() ^ getB_OF()));
263
 
264
  BX_NEXT_INSTR(i);
265
}
266
 
267
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETLE_EbM(bxInstruction_c *i)
268
{
269
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
270
 
271
  Bit8u result_8 = getB_ZF() | (getB_SF() ^ getB_OF());
272
  write_virtual_byte(i->seg(), eaddr, result_8);
273
 
274
  BX_NEXT_INSTR(i);
275
}
276
 
277
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETLE_EbR(bxInstruction_c *i)
278
{
279
  Bit8u result_8 = getB_ZF() | (getB_SF() ^ getB_OF());
280
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), result_8);
281
 
282
  BX_NEXT_INSTR(i);
283
}
284
 
285
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNLE_EbM(bxInstruction_c *i)
286
{
287
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
288
 
289
  Bit8u result_8 = !(getB_ZF() | (getB_SF() ^ getB_OF()));
290
  write_virtual_byte(i->seg(), eaddr, result_8);
291
 
292
  BX_NEXT_INSTR(i);
293
}
294
 
295
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SETNLE_EbR(bxInstruction_c *i)
296
{
297
  Bit8u result_8 = !(getB_ZF() | (getB_SF() ^ getB_OF()));
298
  BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), result_8);
299
 
300
  BX_NEXT_INSTR(i);
301
}
302
 
303
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::BSWAP_RX(bxInstruction_c *i)
304
{
305
  BX_ERROR(("BSWAP with 16-bit opsize: undefined behavior !"));
306
  BX_WRITE_16BIT_REG(i->dst(), 0);
307
 
308
  BX_NEXT_INSTR(i);
309
}
310
 
311
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::BSWAP_ERX(bxInstruction_c *i)
312
{
313
  Bit32u val32 = BX_READ_32BIT_REG(i->dst());
314
 
315
  BX_WRITE_32BIT_REGZ(i->dst(), bx_bswap32(val32));
316
 
317
  BX_NEXT_INSTR(i);
318
}
319
 
320
#if BX_SUPPORT_X86_64
321
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::BSWAP_RRX(bxInstruction_c *i)
322
{
323
  Bit64u val64 = BX_READ_64BIT_REG(i->dst());
324
 
325
  BX_WRITE_64BIT_REG(i->dst(), bx_bswap64(val64));
326
 
327
  BX_NEXT_INSTR(i);
328
}
329
#endif
330
 
331
#if BX_CPU_LEVEL >= 6
332
 
333
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVBE_GwMw(bxInstruction_c *i)
334
{
335
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
336
  Bit16u val16 = read_virtual_word(i->seg(), eaddr);
337
 
338
  BX_WRITE_16BIT_REG(i->dst(), bx_bswap16(val16));
339
 
340
  BX_NEXT_INSTR(i);
341
}
342
 
343
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVBE_MwGw(bxInstruction_c *i)
344
{
345
  Bit16u val16 = BX_READ_16BIT_REG(i->src());
346
 
347
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
348
  write_virtual_word(i->seg(), eaddr, bx_bswap16(val16));
349
 
350
  BX_NEXT_INSTR(i);
351
}
352
 
353
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVBE_GdMd(bxInstruction_c *i)
354
{
355
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
356
  Bit32u val32 = read_virtual_dword(i->seg(), eaddr);
357
 
358
  BX_WRITE_32BIT_REGZ(i->dst(), bx_bswap32(val32));
359
 
360
  BX_NEXT_INSTR(i);
361
}
362
 
363
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVBE_MdGd(bxInstruction_c *i)
364
{
365
  Bit32u val32 = BX_READ_32BIT_REG(i->src());
366
 
367
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
368
  write_virtual_dword(i->seg(), eaddr, bx_bswap32(val32));
369
 
370
  BX_NEXT_INSTR(i);
371
}
372
 
373
#if BX_SUPPORT_X86_64
374
 
375
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVBE_GqMq(bxInstruction_c *i)
376
{
377
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
378
  Bit64u val64 = read_virtual_qword(i->seg(), eaddr);
379
 
380
  BX_WRITE_64BIT_REG(i->dst(), bx_bswap64(val64));
381
 
382
  BX_NEXT_INSTR(i);
383
}
384
 
385
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVBE_MqGq(bxInstruction_c *i)
386
{
387
  Bit64u val64 = BX_READ_64BIT_REG(i->src());
388
 
389
  bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
390
  write_virtual_qword_64(i->seg(), eaddr, bx_bswap64(val64));
391
 
392
  BX_NEXT_INSTR(i);
393
}
394
 
395
#endif // BX_SUPPORT_X86_64
396
 
397
#endif // BX_CPU_LEVEL >= 6
398
 
399
#endif // BX_CPU_LEVEL >= 3

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.