2003-05-26 23:30:33 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-03-11 00:43:11 +03:00
|
|
|
// $Id: sse_move.cc,v 1.98 2009-03-10 21:43:11 sshwarts Exp $
|
2005-03-19 23:44:01 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2003-05-26 23:30:33 +04:00
|
|
|
//
|
2004-02-14 00:27:45 +03:00
|
|
|
// Copyright (c) 2003 Stanislav Shwartsman
|
2007-03-24 00:27:13 +03:00
|
|
|
// Written by Stanislav Shwartsman [sshwarts at sourceforge net]
|
2003-05-26 23:30:33 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-01-16 21:18:59 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
|
2003-05-26 23:30:33 +04:00
|
|
|
//
|
2007-11-18 02:28:33 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
#define NEED_CPU_REG_SHORTCUTS 1
|
|
|
|
#include "bochs.h"
|
2006-03-07 01:03:16 +03:00
|
|
|
#include "cpu.h"
|
2003-05-26 23:30:33 +04:00
|
|
|
#define LOG_THIS BX_CPU_THIS_PTR
|
|
|
|
|
|
|
|
#if BX_SUPPORT_SSE
|
|
|
|
|
2006-01-24 22:03:55 +03:00
|
|
|
void BX_CPU_C::print_state_SSE(void)
|
|
|
|
{
|
2007-10-11 22:12:00 +04:00
|
|
|
BX_DEBUG(("MXCSR: 0x%08x\n", BX_MXCSR_REGISTER));
|
2008-06-14 20:55:45 +04:00
|
|
|
for(unsigned n=0;n<BX_XMM_REGISTERS;n++) {
|
|
|
|
BxPackedXmmRegister xmm = BX_READ_XMM_REG(n);
|
|
|
|
BX_DEBUG(("XMM%02u: %08x%08x:%08x%08x\n", n,
|
2007-10-11 22:12:00 +04:00
|
|
|
xmm.xmm32u(3), xmm.xmm32u(2), xmm.xmm32u(1), xmm.xmm32u(0)));
|
2006-01-24 22:03:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-25 19:46:39 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_SUPPORT_FPU
|
2008-05-10 17:34:47 +04:00
|
|
|
Bit8u BX_CPU_C::pack_FPU_TW(Bit16u twd)
|
|
|
|
{
|
|
|
|
Bit8u tag_byte = 0;
|
|
|
|
|
|
|
|
if((twd & 0x0003) != 0x0003) tag_byte |= 0x01;
|
|
|
|
if((twd & 0x000c) != 0x000c) tag_byte |= 0x02;
|
|
|
|
if((twd & 0x0030) != 0x0030) tag_byte |= 0x04;
|
|
|
|
if((twd & 0x00c0) != 0x00c0) tag_byte |= 0x08;
|
|
|
|
if((twd & 0x0300) != 0x0300) tag_byte |= 0x10;
|
|
|
|
if((twd & 0x0c00) != 0x0c00) tag_byte |= 0x20;
|
|
|
|
if((twd & 0x3000) != 0x3000) tag_byte |= 0x40;
|
|
|
|
if((twd & 0xc000) != 0xc000) tag_byte |= 0x80;
|
|
|
|
|
|
|
|
return tag_byte;
|
|
|
|
}
|
|
|
|
|
2008-02-13 19:45:21 +03:00
|
|
|
Bit16u BX_CPU_C::unpack_FPU_TW(Bit16u tag_byte)
|
|
|
|
{
|
|
|
|
Bit32u twd = 0;
|
|
|
|
|
|
|
|
/* FTW
|
|
|
|
*
|
|
|
|
* Note that the original format for FTW can be recreated from the stored
|
|
|
|
* FTW valid bits and the stored 80-bit FP data (assuming the stored data
|
|
|
|
* was not the contents of MMX registers) using the following table:
|
|
|
|
|
|
|
|
| Exponent | Exponent | Fraction | J,M bits | FTW valid | x87 FTW |
|
|
|
|
| all 1s | all 0s | all 0s | | | |
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
| 0 | 0 | 0 | 0x | 1 | S 10 |
|
|
|
|
| 0 | 0 | 0 | 1x | 1 | V 00 |
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
| 0 | 0 | 1 | 00 | 1 | S 10 |
|
|
|
|
| 0 | 0 | 1 | 10 | 1 | V 00 |
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
| 0 | 1 | 0 | 0x | 1 | S 10 |
|
|
|
|
| 0 | 1 | 0 | 1x | 1 | S 10 |
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
| 0 | 1 | 1 | 00 | 1 | Z 01 |
|
|
|
|
| 0 | 1 | 1 | 10 | 1 | S 10 |
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
| 1 | 0 | 0 | 1x | 1 | S 10 |
|
|
|
|
| 1 | 0 | 0 | 1x | 1 | S 10 |
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
| 1 | 0 | 1 | 00 | 1 | S 10 |
|
|
|
|
| 1 | 0 | 1 | 10 | 1 | S 10 |
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
| all combinations above | 0 | E 11 |
|
|
|
|
|
|
|
|
*
|
|
|
|
* The J-bit is defined to be the 1-bit binary integer to the left of
|
|
|
|
* the decimal place in the significand.
|
|
|
|
*
|
|
|
|
* The M-bit is defined to be the most significant bit of the fractional
|
|
|
|
* portion of the significand (i.e., the bit immediately to the right of
|
|
|
|
* the decimal place). When the M-bit is the most significant bit of the
|
|
|
|
* fractional portion of the significand, it must be 0 if the fraction
|
|
|
|
* is all 0's.
|
|
|
|
*/
|
|
|
|
|
2008-02-14 02:12:35 +03:00
|
|
|
for(int index = 7;index >= 0; index--, twd <<= 2, tag_byte <<= 1)
|
2008-02-13 19:45:21 +03:00
|
|
|
{
|
|
|
|
if(tag_byte & 0x80) {
|
|
|
|
const floatx80 &fpu_reg = BX_FPU_REG(index);
|
|
|
|
twd |= FPU_tagof(fpu_reg);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
twd |= FPU_Tag_Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (twd >> 2);
|
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ************************************ */
|
|
|
|
/* SSE: SAVE/RESTORE FPU/MMX/SSEx STATE */
|
|
|
|
/* ************************************ */
|
|
|
|
|
|
|
|
/* 0F AE Grp15 010 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LDMXCSR(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2008-01-10 22:37:56 +03:00
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
Bit32u new_mxcsr = read_virtual_dword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
if(new_mxcsr & ~MXCSR_MASK)
|
|
|
|
exception(BX_GP_EXCEPTION, 0, 0);
|
|
|
|
|
|
|
|
BX_MXCSR_REGISTER = new_mxcsr;
|
|
|
|
#else
|
|
|
|
BX_INFO(("LDMXCSR: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 0F AE Grp15 011 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::STMXCSR(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
Bit32u mxcsr = BX_MXCSR_REGISTER & MXCSR_MASK;
|
2008-01-10 22:37:56 +03:00
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2008-01-10 22:37:56 +03:00
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_dword(i->seg(), eaddr, mxcsr);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
|
|
|
BX_INFO(("STMXCSR: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 0F AE Grp15 000 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::FXSAVE(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-12-01 19:45:17 +03:00
|
|
|
#if BX_CPU_LEVEL >= 6
|
2003-05-26 23:30:33 +04:00
|
|
|
unsigned index;
|
2003-10-24 22:34:16 +04:00
|
|
|
BxPackedXmmRegister xmm;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
BX_DEBUG(("FXSAVE: save FPU/MMX/SSE state"));
|
|
|
|
|
2004-07-03 15:02:43 +04:00
|
|
|
#if BX_SUPPORT_MMX
|
2007-07-09 19:16:14 +04:00
|
|
|
if(BX_CPU_THIS_PTR cr0.get_TS())
|
2004-07-03 15:02:43 +04:00
|
|
|
exception(BX_NM_EXCEPTION, 0, 0);
|
|
|
|
|
2007-07-09 19:16:14 +04:00
|
|
|
if(BX_CPU_THIS_PTR cr0.get_EM())
|
2004-07-03 15:02:43 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
|
|
|
#endif
|
|
|
|
|
2004-06-18 18:11:11 +04:00
|
|
|
xmm.xmm16u(0) = BX_CPU_THIS_PTR the_i387.get_control_word();
|
2008-05-10 17:34:47 +04:00
|
|
|
xmm.xmm16u(1) = BX_CPU_THIS_PTR the_i387.get_status_word();
|
|
|
|
xmm.xmm16u(2) = pack_FPU_TW(BX_CPU_THIS_PTR the_i387.get_tag_word());
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* x87 FPU Opcode (16 bits) */
|
|
|
|
/* The lower 11 bits contain the FPU opcode, upper 5 bits are reserved */
|
2006-04-23 20:01:34 +04:00
|
|
|
xmm.xmm16u(3) = BX_CPU_THIS_PTR the_i387.foo;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2008-02-03 00:46:54 +03:00
|
|
|
/*
|
2006-04-23 20:01:34 +04:00
|
|
|
* x87 FPU IP Offset (32/64 bits)
|
2008-02-03 00:46:54 +03:00
|
|
|
* The contents of this field differ depending on the current
|
2006-04-23 20:01:34 +04:00
|
|
|
* addressing mode (16/32/64 bit) when the FXSAVE instruction was executed:
|
|
|
|
* + 64-bit mode - 64-bit IP offset
|
|
|
|
* + 32-bit mode - 32-bit IP offset
|
|
|
|
* + 16-bit mode - low 16 bits are IP offset; high 16 bits are reserved.
|
|
|
|
* x87 CS FPU IP Selector
|
|
|
|
* + 16 bit, in 16/32 bit mode only
|
2003-05-26 23:30:33 +04:00
|
|
|
*/
|
2006-04-23 20:01:34 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->os64L()) /* 64 bit operand size mode */
|
|
|
|
{
|
2006-08-31 22:18:17 +04:00
|
|
|
xmm.xmm64u(1) = (BX_CPU_THIS_PTR the_i387.fip);
|
2006-04-23 20:01:34 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2008-08-16 16:19:30 +04:00
|
|
|
xmm.xmm32u(2) = (Bit32u)(BX_CPU_THIS_PTR the_i387.fip);
|
2007-12-27 02:07:44 +03:00
|
|
|
xmm.xmm32u(3) = (BX_CPU_THIS_PTR the_i387.fcs);
|
2006-04-23 20:01:34 +04:00
|
|
|
}
|
2008-02-03 00:46:54 +03:00
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2008-01-10 22:37:56 +03:00
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_dqword_aligned(i->seg(), eaddr, (Bit8u *) &xmm);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2008-02-03 00:46:54 +03:00
|
|
|
/*
|
2006-04-23 20:01:34 +04:00
|
|
|
* x87 FPU Instruction Operand (Data) Pointer Offset (32/64 bits)
|
2008-02-03 00:46:54 +03:00
|
|
|
* The contents of this field differ depending on the current
|
2003-05-26 23:30:33 +04:00
|
|
|
* addressing mode (16/32 bit) when the FXSAVE instruction was executed:
|
2006-04-23 20:01:34 +04:00
|
|
|
* + 64-bit mode - 64-bit offset
|
|
|
|
* + 32-bit mode - 32-bit offset
|
|
|
|
* + 16-bit mode - low 16 bits are offset; high 16 bits are reserved.
|
2008-02-03 00:46:54 +03:00
|
|
|
* x87 DS FPU Instruction Operand (Data) Pointer Selector
|
2006-04-23 20:01:34 +04:00
|
|
|
* + 16 bit, in 16/32 bit mode only
|
2003-05-26 23:30:33 +04:00
|
|
|
*/
|
2006-04-23 20:01:34 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
if (i->os64L()) /* 64 bit operand size mode */
|
|
|
|
{
|
2006-08-31 22:18:17 +04:00
|
|
|
xmm.xmm64u(0) = (BX_CPU_THIS_PTR the_i387.fdp);
|
2006-04-23 20:01:34 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2008-08-16 16:19:30 +04:00
|
|
|
xmm.xmm32u(0) = (Bit32u)(BX_CPU_THIS_PTR the_i387.fdp);
|
2007-12-27 02:07:44 +03:00
|
|
|
xmm.xmm32u(1) = (BX_CPU_THIS_PTR the_i387.fds);
|
2006-04-23 20:01:34 +04:00
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2003-10-24 22:34:16 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 1
|
2003-05-26 23:30:33 +04:00
|
|
|
xmm.xmm32u(2) = BX_MXCSR_REGISTER;
|
|
|
|
xmm.xmm32u(3) = MXCSR_MASK;
|
2003-10-24 22:34:16 +04:00
|
|
|
#else
|
|
|
|
xmm.xmm32u(2) = 0;
|
|
|
|
xmm.xmm32u(3) = 0;
|
|
|
|
#endif
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_dqword(i->seg(), eaddr + 16, (Bit8u *) &xmm);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* store i387 register file */
|
|
|
|
for(index=0; index < 8; index++)
|
|
|
|
{
|
2004-07-03 00:24:47 +04:00
|
|
|
const floatx80 &fp = BX_FPU_REG(index);
|
|
|
|
|
|
|
|
xmm.xmm64u(0) = fp.fraction;
|
|
|
|
xmm.xmm64u(1) = 0;
|
|
|
|
xmm.xmm16u(4) = fp.exp;
|
2008-02-03 00:46:54 +03:00
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_dqword(i->seg(), eaddr+index*16+32, (Bit8u *) &xmm);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-11-25 23:52:40 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-04-01 00:56:27 +04:00
|
|
|
if (BX_CPU_THIS_PTR efer.get_FFXSR() && CPL == 0 && Is64BitMode())
|
2007-11-25 23:52:40 +03:00
|
|
|
return; // skip saving of the XMM state
|
|
|
|
#endif
|
|
|
|
|
2003-10-24 22:34:16 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 1
|
2003-05-26 23:30:33 +04:00
|
|
|
/* store XMM register file */
|
|
|
|
for(index=0; index < BX_XMM_REGISTERS; index++)
|
|
|
|
{
|
2006-08-31 22:18:17 +04:00
|
|
|
// save XMM8-XMM15 only in 64-bit mode
|
|
|
|
if (index < 8 || Is64BitMode()) {
|
2008-02-14 01:25:24 +03:00
|
|
|
write_virtual_dqword(i->seg(),
|
2008-08-08 13:22:49 +04:00
|
|
|
eaddr+index*16+160, (Bit8u *) &(BX_CPU_THIS_PTR xmm[index]));
|
2006-08-31 22:18:17 +04:00
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
2003-10-24 22:34:16 +04:00
|
|
|
#endif
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* do not touch reserved fields */
|
|
|
|
#else
|
2003-10-24 22:34:16 +04:00
|
|
|
BX_INFO(("FXSAVE: required P6 support, use --enable-cpu-level=6 option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 0F AE Grp15 001 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::FXRSTOR(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-12-01 19:45:17 +03:00
|
|
|
#if BX_CPU_LEVEL >= 6
|
2003-05-26 23:30:33 +04:00
|
|
|
BxPackedXmmRegister xmm;
|
2008-02-14 02:12:35 +03:00
|
|
|
unsigned index;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
BX_DEBUG(("FXRSTOR: restore FPU/MMX/SSE state"));
|
|
|
|
|
2004-07-03 15:02:43 +04:00
|
|
|
#if BX_SUPPORT_MMX
|
2007-07-09 19:16:14 +04:00
|
|
|
if(BX_CPU_THIS_PTR cr0.get_TS())
|
2004-07-03 15:02:43 +04:00
|
|
|
exception(BX_NM_EXCEPTION, 0, 0);
|
|
|
|
|
2007-07-09 19:16:14 +04:00
|
|
|
if(BX_CPU_THIS_PTR cr0.get_EM())
|
2004-07-03 15:02:43 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
|
|
|
#endif
|
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2008-01-10 22:37:56 +03:00
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
read_virtual_dqword_aligned(i->seg(), eaddr, (Bit8u *) &xmm);
|
2008-02-03 00:46:54 +03:00
|
|
|
|
2008-02-13 19:45:21 +03:00
|
|
|
BX_CPU_THIS_PTR the_i387.cwd = xmm.xmm16u(0);
|
|
|
|
BX_CPU_THIS_PTR the_i387.swd = xmm.xmm16u(1);
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR the_i387.tos = (xmm.xmm16u(1) >> 11) & 0x07;
|
|
|
|
|
2006-04-23 20:01:34 +04:00
|
|
|
/* Restore x87 FPU Opcode */
|
|
|
|
/* The lower 11 bits contain the FPU opcode, upper 5 bits are reserved */
|
|
|
|
BX_CPU_THIS_PTR the_i387.foo = xmm.xmm16u(3) & 0x7FF;
|
|
|
|
|
|
|
|
/* Restore x87 FPU IP */
|
|
|
|
#if BX_SUPPORT_X86_64
|
2008-02-13 19:45:21 +03:00
|
|
|
if (i->os64L()) {
|
2006-04-23 20:01:34 +04:00
|
|
|
BX_CPU_THIS_PTR the_i387.fip = xmm.xmm64u(1);
|
2008-02-13 19:45:21 +03:00
|
|
|
BX_CPU_THIS_PTR the_i387.fcs = 0;
|
2006-04-23 20:01:34 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR the_i387.fip = xmm.xmm32u(2);
|
2008-08-16 16:19:30 +04:00
|
|
|
BX_CPU_THIS_PTR the_i387.fcs = xmm.xmm16u(6);
|
2006-04-23 20:01:34 +04:00
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2008-02-13 19:45:21 +03:00
|
|
|
Bit32u tag_byte = xmm.xmmubyte(4);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2006-04-23 20:01:34 +04:00
|
|
|
/* Restore x87 FPU DP */
|
2008-08-08 13:22:49 +04:00
|
|
|
read_virtual_dqword(i->seg(), eaddr + 16, (Bit8u *) &xmm);
|
2006-04-23 20:01:34 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2008-02-13 19:45:21 +03:00
|
|
|
if (i->os64L()) {
|
2006-04-23 20:01:34 +04:00
|
|
|
BX_CPU_THIS_PTR the_i387.fdp = xmm.xmm64u(0);
|
2008-02-13 19:45:21 +03:00
|
|
|
BX_CPU_THIS_PTR the_i387.fds = 0;
|
2006-04-23 20:01:34 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
BX_CPU_THIS_PTR the_i387.fdp = xmm.xmm32u(0);
|
|
|
|
BX_CPU_THIS_PTR the_i387.fds = xmm.xmm16u(2);
|
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2003-10-24 22:34:16 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 1
|
2003-05-26 23:30:33 +04:00
|
|
|
/* If the OSFXSR bit in CR4 is not set, the FXRSTOR instruction does
|
|
|
|
not restore the states of the XMM and MXCSR registers. */
|
2005-09-06 23:12:02 +04:00
|
|
|
if(BX_CPU_THIS_PTR cr4.get_OSFXSR())
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2005-09-24 20:56:20 +04:00
|
|
|
Bit32u new_mxcsr = xmm.xmm32u(2);
|
|
|
|
if(new_mxcsr & ~MXCSR_MASK)
|
2003-05-26 23:30:33 +04:00
|
|
|
exception(BX_GP_EXCEPTION, 0, 0);
|
|
|
|
|
|
|
|
BX_MXCSR_REGISTER = new_mxcsr;
|
|
|
|
}
|
2003-10-24 22:34:16 +04:00
|
|
|
#endif
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* load i387 register file */
|
|
|
|
for(index=0; index < 8; index++)
|
|
|
|
{
|
2008-06-12 23:14:40 +04:00
|
|
|
floatx80 reg;
|
2008-08-08 13:22:49 +04:00
|
|
|
reg.fraction = read_virtual_qword(i->seg(), eaddr+index*16+32);
|
|
|
|
reg.exp = read_virtual_word (i->seg(), eaddr+index*16+40);
|
2008-06-12 23:14:40 +04:00
|
|
|
BX_FPU_REG(index) = reg;
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2008-02-13 19:45:21 +03:00
|
|
|
BX_CPU_THIS_PTR the_i387.twd = unpack_FPU_TW(tag_byte);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-11-25 23:52:40 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-04-01 00:56:27 +04:00
|
|
|
if (BX_CPU_THIS_PTR efer.get_FFXSR() && CPL == 0 && Is64BitMode())
|
2007-11-25 23:52:40 +03:00
|
|
|
return; // skip restore of the XMM state
|
|
|
|
#endif
|
|
|
|
|
2003-10-24 22:34:16 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 1
|
2003-05-26 23:30:33 +04:00
|
|
|
/* If the OSFXSR bit in CR4 is not set, the FXRSTOR instruction does
|
|
|
|
not restore the states of the XMM and MXCSR registers. */
|
2005-09-05 21:02:30 +04:00
|
|
|
if(BX_CPU_THIS_PTR cr4.get_OSFXSR())
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
/* load XMM register file */
|
|
|
|
for(index=0; index < BX_XMM_REGISTERS; index++)
|
|
|
|
{
|
2006-08-31 22:18:17 +04:00
|
|
|
// restore XMM8-XMM15 only in 64-bit mode
|
|
|
|
if (index < 8 || Is64BitMode()) {
|
2008-02-14 01:25:24 +03:00
|
|
|
read_virtual_dqword(i->seg(),
|
2008-08-08 13:22:49 +04:00
|
|
|
eaddr+index*16+160, (Bit8u *) &(BX_CPU_THIS_PTR xmm[index]));
|
2006-08-31 22:18:17 +04:00
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
}
|
2003-10-24 22:34:16 +04:00
|
|
|
#endif
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
#else
|
2003-10-24 22:34:16 +04:00
|
|
|
BX_INFO(("FXRSTOR: required P6 support, use --enable-cpu-level=6 option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* *************************** */
|
|
|
|
/* SSE: MEMORY MOVE OPERATIONS */
|
|
|
|
/* *************************** */
|
|
|
|
|
|
|
|
/* All these opcodes never generate SIMD floating point exeptions */
|
|
|
|
|
|
|
|
/* MOVUPS: 0F 10 */
|
|
|
|
/* MOVUPD: 66 0F 10 */
|
|
|
|
/* MOVDQU: F3 0F 6F */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVUPS_VpsWps(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op;
|
|
|
|
|
|
|
|
/* op is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
op = BX_READ_XMM_REG(i->rm());
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
read_virtual_dqword(i->seg(), eaddr, (Bit8u *) &op);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op);
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVUPS_VpsWps: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MOVUPS: 0F 11 */
|
|
|
|
/* MOVUPD: 66 0F 11 */
|
|
|
|
/* MOVDQU: F3 0F 7F */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVUPS_WpsVps(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op = BX_READ_XMM_REG(i->nnn());
|
|
|
|
|
|
|
|
/* op is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
BX_WRITE_XMM_REG(i->rm(), op);
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2008-01-10 22:37:56 +03:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_dqword(i->seg(), eaddr, (Bit8u *) &op);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVUPS_WpsVps: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MOVAPS: 0F 28 */
|
|
|
|
/* MOVAPD: 66 0F 28 */
|
|
|
|
/* MOVDQA: F3 0F 6F */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVAPS_VpsWps(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op;
|
|
|
|
|
|
|
|
/* op is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
op = BX_READ_XMM_REG(i->rm());
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
read_virtual_dqword_aligned(i->seg(), eaddr, (Bit8u *) &op);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op);
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVAPS_VpsWps: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MOVAPS: 0F 29 */
|
|
|
|
/* MOVAPD: 66 0F 29 */
|
|
|
|
/* MOVDQA: F3 0F 7F */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVAPS_WpsVps(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op = BX_READ_XMM_REG(i->nnn());
|
|
|
|
|
|
|
|
/* op is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
BX_WRITE_XMM_REG(i->rm(), op);
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2008-01-10 22:37:56 +03:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_dqword_aligned(i->seg(), eaddr, (Bit8u *) &op);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVAPS_WpsVps: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* F3 0F 10 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSS_VssWss(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
BxPackedXmmRegister op = BX_READ_XMM_REG(i->nnn());
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* op2 is a register or memory reference */
|
2008-02-03 00:46:54 +03:00
|
|
|
if (i->modC0())
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2008-02-03 00:46:54 +03:00
|
|
|
/* If the source operand is an XMM register, the high-order
|
2003-05-26 23:30:33 +04:00
|
|
|
96 bits of the destination XMM register are not modified. */
|
2007-11-28 01:12:45 +03:00
|
|
|
op.xmm32u(0) = BX_READ_XMM_REG_LO_DWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* If the source operand is a memory location, the high-order
|
|
|
|
96 bits of the destination XMM register are cleared to 0s */
|
2008-08-08 13:22:49 +04:00
|
|
|
op.xmm32u(0) = read_virtual_dword(i->seg(), eaddr);
|
2007-11-28 01:12:45 +03:00
|
|
|
op.xmm32u(1) = 0;
|
|
|
|
op.xmm64u(1) = 0;
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
2007-11-28 01:12:45 +03:00
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
|
|
|
BX_INFO(("MOVSS_VssWss: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* F3 0F 11 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSS_WssVss(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
Bit32u val32 = BX_READ_XMM_REG_LO_DWORD(i->nnn());
|
|
|
|
|
|
|
|
/* destination is a register or memory reference */
|
2008-02-03 00:46:54 +03:00
|
|
|
if (i->modC0())
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2008-02-03 00:46:54 +03:00
|
|
|
/* If the source operand is an XMM register, the high-order
|
2003-05-26 23:30:33 +04:00
|
|
|
96 bits of the destination XMM register are not modified. */
|
|
|
|
BX_WRITE_XMM_REG_LO_DWORD(i->rm(), val32);
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_dword(i->seg(), eaddr, val32);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVSS_WssVss: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* F2 0F 10 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSD_VsdWsd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
BxPackedXmmRegister op = BX_READ_XMM_REG(i->nnn());
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* op2 is a register or memory reference */
|
2008-02-03 00:46:54 +03:00
|
|
|
if (i->modC0())
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2008-02-03 00:46:54 +03:00
|
|
|
/* If the source operand is an XMM register, the high-order
|
2003-05-26 23:30:33 +04:00
|
|
|
64 bits of the destination XMM register are not modified. */
|
2007-11-28 01:12:45 +03:00
|
|
|
op.xmm64u(0) = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* If the source operand is a memory location, the high-order
|
|
|
|
64 bits of the destination XMM register are cleared to 0s */
|
2008-08-08 13:22:49 +04:00
|
|
|
op.xmm64u(0) = read_virtual_qword(i->seg(), eaddr);
|
2007-11-28 01:12:45 +03:00
|
|
|
op.xmm64u(1) = 0;
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
2007-11-28 01:12:45 +03:00
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
|
|
|
BX_INFO(("MOVSD_VsdWsd: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* F2 0F 11 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSD_WsdVsd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
Bit64u val64 = BX_READ_XMM_REG_LO_QWORD(i->nnn());
|
|
|
|
|
|
|
|
/* destination is a register or memory reference */
|
2008-02-03 00:46:54 +03:00
|
|
|
if (i->modC0())
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2008-02-03 00:46:54 +03:00
|
|
|
/* If the source operand is an XMM register, the high-order
|
2003-05-26 23:30:33 +04:00
|
|
|
64 bits of the destination XMM register are not modified. */
|
|
|
|
BX_WRITE_XMM_REG_LO_QWORD(i->rm(), val64);
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_qword(i->seg(), eaddr, val64);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVSD_WsdVsd: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MOVLPS: 0F 12 */
|
|
|
|
/* MOVLPD: 66 0F 12 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVLPS_VpsMq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
Bit64u val64;
|
|
|
|
|
|
|
|
if (i->modC0()) /* MOVHLPS xmm1, xmm2 opcode */
|
|
|
|
{
|
|
|
|
val64 = BX_READ_XMM_REG_HI_QWORD(i->rm());
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val64 = read_virtual_qword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG_LO_QWORD(i->nnn(), val64);
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVLPS_VpsMq: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2003-08-30 01:20:52 +04:00
|
|
|
/* F2 0F 12 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVDDUP_VpdWq(bxInstruction_c *i)
|
2003-08-30 01:20:52 +04:00
|
|
|
{
|
2006-02-20 22:28:57 +03:00
|
|
|
#if BX_SUPPORT_SSE >= 3
|
2003-08-30 01:20:52 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
Bit64u val64;
|
|
|
|
BxPackedXmmRegister op;
|
|
|
|
|
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val64 = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-08-30 01:20:52 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val64 = read_virtual_qword(i->seg(), eaddr);
|
2003-08-30 01:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
op.xmm64u(0) = val64;
|
|
|
|
op.xmm64u(1) = val64;
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("MOVDDUP_VpdWq: required SSE3, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-08-30 01:20:52 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* F3 0F 12 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSLDUP_VpsWps(bxInstruction_c *i)
|
2003-08-30 01:20:52 +04:00
|
|
|
{
|
2006-02-20 22:28:57 +03:00
|
|
|
#if BX_SUPPORT_SSE >= 3
|
2003-08-30 01:20:52 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
BxPackedXmmRegister op, result;
|
|
|
|
|
|
|
|
/* op is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
op = BX_READ_XMM_REG(i->rm());
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-08-30 01:20:52 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
readVirtualDQwordAligned(i->seg(), eaddr, (Bit8u *) &op);
|
2003-08-30 01:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
result.xmm32u(0) = op.xmm32u(0);
|
|
|
|
result.xmm32u(1) = op.xmm32u(0);
|
|
|
|
result.xmm32u(2) = op.xmm32u(2);
|
|
|
|
result.xmm32u(3) = op.xmm32u(2);
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("MOVSLDUP_VpsWps: required SSE3, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-08-30 01:20:52 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* F3 0F 16 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVSHDUP_VpsWps(bxInstruction_c *i)
|
2003-08-30 01:20:52 +04:00
|
|
|
{
|
2006-02-20 22:28:57 +03:00
|
|
|
#if BX_SUPPORT_SSE >= 3
|
2003-08-30 01:20:52 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
BxPackedXmmRegister op, result;
|
|
|
|
|
|
|
|
/* op is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
op = BX_READ_XMM_REG(i->rm());
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-08-30 01:20:52 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
readVirtualDQwordAligned(i->seg(), eaddr, (Bit8u *) &op);
|
2003-08-30 01:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
result.xmm32u(0) = op.xmm32u(1);
|
|
|
|
result.xmm32u(1) = op.xmm32u(1);
|
|
|
|
result.xmm32u(2) = op.xmm32u(3);
|
|
|
|
result.xmm32u(3) = op.xmm32u(3);
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("MOVHLDUP_VpsWps: required SSE3, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-08-30 01:20:52 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2003-05-26 23:30:33 +04:00
|
|
|
/* MOVLPS: 0F 13 */
|
|
|
|
/* MOVLPD: 66 0F 13 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVLPS_MqVps(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
2007-01-29 00:27:31 +03:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
|
|
|
write_virtual_qword(i->seg(), eaddr, BX_XMM_REG_LO_QWORD(i->nnn()));
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
|
|
|
BX_INFO(("MOVLPS_MqVps: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MOVHPS: 0F 16 */
|
|
|
|
/* MOVHPD: 66 0F 16 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVHPS_VpsMq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
Bit64u val64;
|
|
|
|
|
|
|
|
if (i->modC0()) /* MOVLHPS xmm1, xmm2 opcode */
|
|
|
|
{
|
|
|
|
val64 = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val64 = read_virtual_qword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG_HI_QWORD(i->nnn(), val64);
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVHPS_VpsMq: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MOVHPS: 0F 17 */
|
|
|
|
/* MOVHPD: 66 0F 17 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVHPS_MqVps(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
2007-01-29 00:27:31 +03:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
|
|
|
write_virtual_qword(i->seg(), eaddr, BX_XMM_REG_HI_QWORD(i->nnn()));
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
|
|
|
BX_INFO(("MOVHPS_MqVps: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2003-08-30 01:20:52 +04:00
|
|
|
/* F2 0F F0 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::LDDQU_VdqMdq(bxInstruction_c *i)
|
2003-08-30 01:20:52 +04:00
|
|
|
{
|
2006-02-20 22:28:57 +03:00
|
|
|
#if BX_SUPPORT_SSE >= 3
|
2007-01-29 00:27:31 +03:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
2003-08-30 01:20:52 +04:00
|
|
|
BxPackedXmmRegister op;
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
|
|
|
read_virtual_dqword(i->seg(), eaddr, (Bit8u *) &op);
|
2007-08-01 00:25:52 +04:00
|
|
|
|
2003-08-30 01:20:52 +04:00
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("LDDQU_VdqMdq: required SSE3, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-08-30 01:20:52 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 66 0F F7 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MASKMOVDQU_VdqUdq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
bx_address rdi;
|
2008-02-03 00:46:54 +03:00
|
|
|
BxPackedXmmRegister op = BX_READ_XMM_REG(i->nnn()),
|
2007-12-23 20:39:10 +03:00
|
|
|
mask = BX_READ_XMM_REG(i->rm()), temp;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2005-08-10 22:40:38 +04:00
|
|
|
if (i->as64L()) { /* 64 bit address mode */
|
2003-05-26 23:30:33 +04:00
|
|
|
rdi = RDI;
|
2008-02-03 00:46:54 +03:00
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (i->as32L()) {
|
|
|
|
rdi = EDI;
|
|
|
|
}
|
2005-08-10 22:40:38 +04:00
|
|
|
else { /* 16 bit address mode */
|
2003-05-26 23:30:33 +04:00
|
|
|
rdi = DI;
|
|
|
|
}
|
|
|
|
|
2007-12-23 20:39:10 +03:00
|
|
|
/* no data will be written to memory if mask is all 0s */
|
|
|
|
if ((mask.xmm64u(0) | mask.xmm64u(1)) == 0) return;
|
|
|
|
|
|
|
|
/* implement as read-modify-write for efficiency */
|
|
|
|
read_virtual_dqword(BX_SEG_REG_DS, rdi, (Bit8u *) &temp);
|
|
|
|
|
|
|
|
for(unsigned j=0; j<16; j++) {
|
|
|
|
if(mask.xmmubyte(j) & 0x80) temp.xmmubyte(j) = op.xmmubyte(j);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-12-23 20:39:10 +03:00
|
|
|
/* and write result back to the memory */
|
2008-04-16 09:41:43 +04:00
|
|
|
write_virtual_dqword(i->seg(), rdi, (Bit8u *) &temp);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("MASKMOVDQU_VdqUdq: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 0F 50 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVMSKPS_GdVRps(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 1
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op = BX_READ_XMM_REG(i->nnn());
|
|
|
|
Bit32u val32 = 0;
|
|
|
|
|
|
|
|
if(op.xmm32u(0) & 0x80000000) val32 |= 0x1;
|
|
|
|
if(op.xmm32u(1) & 0x80000000) val32 |= 0x2;
|
|
|
|
if(op.xmm32u(2) & 0x80000000) val32 |= 0x4;
|
|
|
|
if(op.xmm32u(3) & 0x80000000) val32 |= 0x8;
|
|
|
|
|
2005-09-12 22:08:35 +04:00
|
|
|
BX_WRITE_32BIT_REGZ(i->rm(), val32);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
|
|
|
BX_INFO(("MOVMSKPS_GdVRps: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 66 0F 50 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVMSKPD_GdVRpd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op = BX_READ_XMM_REG(i->nnn());
|
|
|
|
Bit32u val32 = 0;
|
|
|
|
|
|
|
|
if(op.xmm32u(1) & 0x80000000) val32 |= 0x1;
|
|
|
|
if(op.xmm32u(3) & 0x80000000) val32 |= 0x2;
|
2008-02-03 00:46:54 +03:00
|
|
|
|
2005-09-12 22:08:35 +04:00
|
|
|
BX_WRITE_32BIT_REGZ(i->rm(), val32);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
2005-09-23 20:45:41 +04:00
|
|
|
BX_INFO(("MOVMSKPD_GdVRpd: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 66 0F 6E */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVD_VdqEd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op1;
|
2007-11-28 01:12:45 +03:00
|
|
|
Bit32u op2;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
/* op2 is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
op2 = BX_READ_32BIT_REG(i->rm());
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2007-11-28 01:12:45 +03:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
op2 = read_virtual_dword(i->seg(), eaddr);
|
2007-11-28 01:12:45 +03:00
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
op1.xmm64u(0) = (Bit64u)(op2);
|
|
|
|
op1.xmm64u(1) = 0;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op1);
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVD_VdqEd: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
2007-11-28 01:12:45 +03:00
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
/* 66 0F 6E */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVQ_VdqEq(bxInstruction_c *i)
|
2007-11-28 01:12:45 +03:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op1;
|
|
|
|
Bit64u op2;
|
|
|
|
|
|
|
|
/* op2 is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
op2 = BX_READ_64BIT_REG(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
2007-11-28 01:12:45 +03:00
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2007-11-28 01:12:45 +03:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
op2 = read_virtual_qword_64(i->seg(), eaddr);
|
2007-11-28 01:12:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
op1.xmm64u(0) = op2;
|
|
|
|
op1.xmm64u(1) = 0;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op1);
|
|
|
|
#else
|
2007-11-28 01:12:45 +03:00
|
|
|
BX_INFO(("MOVQ_VdqEq: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
#endif
|
|
|
|
|
2003-05-26 23:30:33 +04:00
|
|
|
/* 66 0F 7E */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVD_EdVd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
Bit32u op2 = BX_READ_XMM_REG_LO_DWORD(i->nnn());
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
/* destination is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
BX_WRITE_32BIT_REGZ(i->rm(), op2);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
2007-11-28 01:12:45 +03:00
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2007-11-28 01:12:45 +03:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_dword(i->seg(), eaddr, op2);
|
2007-11-28 01:12:45 +03:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVD_EdVd: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
2007-11-28 01:12:45 +03:00
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
|
|
|
|
/* 66 0F 7E */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVQ_EqVq(bxInstruction_c *i)
|
2007-11-28 01:12:45 +03:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
Bit64u op2 = BX_READ_XMM_REG_LO_QWORD(i->nnn());
|
|
|
|
|
|
|
|
/* destination is a register or memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
BX_WRITE_64BIT_REG(i->rm(), op2);
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2007-11-28 01:12:45 +03:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_qword_64(i->seg(), eaddr, op2);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
2006-04-27 10:09:56 +04:00
|
|
|
#else
|
2007-11-28 01:12:45 +03:00
|
|
|
BX_INFO(("MOVQ_EqVq: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-11-28 01:12:45 +03:00
|
|
|
#endif
|
|
|
|
|
2003-05-26 23:30:33 +04:00
|
|
|
/* F3 0F 7E */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVQ_VqWq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op;
|
|
|
|
|
|
|
|
if (i->modC0()) {
|
2007-11-28 01:12:45 +03:00
|
|
|
op.xmm64u(0) = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
op.xmm64u(0) = read_virtual_qword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* zero-extension to 128 bit */
|
|
|
|
op.xmm64u(1) = 0;
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op);
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVQ_VqWq: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 66 0F D6 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVQ_WqVq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op = BX_READ_XMM_REG(i->nnn());
|
|
|
|
|
2008-02-03 00:46:54 +03:00
|
|
|
if (i->modC0())
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
op.xmm64u(1) = 0; /* zero-extension to 128 bits */
|
|
|
|
BX_WRITE_XMM_REG(i->rm(), op);
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2008-01-10 22:37:56 +03:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
write_virtual_qword(i->seg(), eaddr, op.xmm64u(0));
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVQ_WqVq: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* F2 0F D6 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVDQ2Q_PqVRq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2008-10-08 14:51:38 +04:00
|
|
|
BX_CPU_THIS_PTR FPU_check_pending_exceptions(); /* check floating point status word for a pending FPU exceptions */
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareFPU2MMX();
|
|
|
|
|
|
|
|
BxPackedMmxRegister mm;
|
|
|
|
MMXUQ(mm) = BX_READ_XMM_REG_LO_QWORD(i->nnn());
|
|
|
|
|
|
|
|
BX_WRITE_MMX_REG(i->rm(), mm);
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVDQ2Q_PqVRq: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* F3 0F D6 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVQ2DQ_VdqQq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2008-10-08 14:51:38 +04:00
|
|
|
BX_CPU_THIS_PTR FPU_check_pending_exceptions(); /* check floating point status word for a pending FPU exceptions */
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareFPU2MMX();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op;
|
|
|
|
BxPackedMmxRegister mm = BX_READ_MMX_REG(i->nnn());
|
|
|
|
|
|
|
|
op.xmm64u(0) = MMXUQ(mm);
|
|
|
|
op.xmm64u(1) = 0;
|
|
|
|
|
|
|
|
BX_WRITE_XMM_REG(i->rm(), op);
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVQ2DQ_VdqQq: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F D7 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVMSKB_GdUdq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 2
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister op = BX_READ_XMM_REG(i->rm());
|
|
|
|
Bit32u result = 0;
|
|
|
|
|
2008-02-03 00:46:54 +03:00
|
|
|
if(op.xmmubyte(0x0) & 0x80) result |= 0x0001;
|
|
|
|
if(op.xmmubyte(0x1) & 0x80) result |= 0x0002;
|
|
|
|
if(op.xmmubyte(0x2) & 0x80) result |= 0x0004;
|
|
|
|
if(op.xmmubyte(0x3) & 0x80) result |= 0x0008;
|
|
|
|
if(op.xmmubyte(0x4) & 0x80) result |= 0x0010;
|
|
|
|
if(op.xmmubyte(0x5) & 0x80) result |= 0x0020;
|
|
|
|
if(op.xmmubyte(0x6) & 0x80) result |= 0x0040;
|
|
|
|
if(op.xmmubyte(0x7) & 0x80) result |= 0x0080;
|
|
|
|
if(op.xmmubyte(0x8) & 0x80) result |= 0x0100;
|
|
|
|
if(op.xmmubyte(0x9) & 0x80) result |= 0x0200;
|
|
|
|
if(op.xmmubyte(0xA) & 0x80) result |= 0x0400;
|
|
|
|
if(op.xmmubyte(0xB) & 0x80) result |= 0x0800;
|
|
|
|
if(op.xmmubyte(0xC) & 0x80) result |= 0x1000;
|
|
|
|
if(op.xmmubyte(0xD) & 0x80) result |= 0x2000;
|
|
|
|
if(op.xmmubyte(0xE) & 0x80) result |= 0x4000;
|
|
|
|
if(op.xmmubyte(0xF) & 0x80) result |= 0x8000;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_WRITE_32BIT_REGZ(i->nnn(), result);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVMSKB_GdUdq: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* **************************** */
|
|
|
|
/* SSE: STORE DATA NON-TEMPORAL */
|
|
|
|
/* **************************** */
|
|
|
|
|
|
|
|
/* 0F C3 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVNTI_MdGd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
|
|
|
write_virtual_dword(i->seg(), eaddr, BX_READ_32BIT_REG(i->nnn()));
|
2007-11-17 15:44:10 +03:00
|
|
|
#else
|
|
|
|
BX_INFO(("MOVNTI_MdGd: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2007-11-17 15:44:10 +03:00
|
|
|
#endif
|
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2008-02-03 00:46:54 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-11-17 15:44:10 +03:00
|
|
|
/* 0F C3 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVNTI_MqGq(bxInstruction_c *i)
|
2007-11-17 15:44:10 +03:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 2
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
|
|
|
write_virtual_qword_64(i->seg(), eaddr, BX_READ_64BIT_REG(i->nnn()));
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
2007-11-17 15:44:10 +03:00
|
|
|
BX_INFO(("MOVNTI_MqGq: required SSE2, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-11-17 15:44:10 +03:00
|
|
|
#endif
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* MOVNTPS: 0F 2B */
|
|
|
|
/* MOVNTPD: 66 0F 2B */
|
|
|
|
/* MOVNTDQ: 66 0F E7 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVNTPS_MpsVps(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 1
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
|
|
|
write_virtual_dqword_aligned(i->seg(), eaddr, (Bit8u *)(&BX_READ_XMM_REG(i->nnn())));
|
2007-04-19 20:12:21 +04:00
|
|
|
#else
|
2007-08-31 22:09:34 +04:00
|
|
|
BX_INFO(("MOVNTPS_MpsVps: required SSE, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2007-04-19 20:12:21 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************** */
|
|
|
|
/* 3-BYTE-OPCODE INSTRUCTIONS */
|
|
|
|
/* ************************** */
|
|
|
|
|
|
|
|
#if (BX_SUPPORT_SSE >= 4) || (BX_SUPPORT_SSE >= 3 && BX_SUPPORT_SSE_EXTENSION > 0)
|
|
|
|
|
|
|
|
/* 66 0F 38 20 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVSXBW_VdqWq(bxInstruction_c *i)
|
2007-04-19 20:12:21 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 4
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit64u val64;
|
|
|
|
|
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val64 = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val64 = read_virtual_qword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm16u(0) = (Bit8s) (val64 & 0xFF);
|
|
|
|
result.xmm16u(1) = (Bit8s) ((val64 >> 8) & 0xFF);
|
|
|
|
result.xmm16u(2) = (Bit8s) ((val64 >> 16) & 0xFF);
|
|
|
|
result.xmm16u(3) = (Bit8s) ((val64 >> 24) & 0xFF);
|
|
|
|
result.xmm16u(4) = (Bit8s) ((val64 >> 32) & 0xFF);
|
|
|
|
result.xmm16u(5) = (Bit8s) ((val64 >> 40) & 0xFF);
|
|
|
|
result.xmm16u(6) = (Bit8s) ((val64 >> 48) & 0xFF);
|
|
|
|
result.xmm16u(7) = (Bit8s) (val64 >> 56);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVSXBW_VdqWq: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 21 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVSXBD_VdqWd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit32u val32;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val32 = BX_READ_XMM_REG_LO_DWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val32 = read_virtual_dword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm32u(0) = (Bit8s) (val32 & 0xFF);
|
|
|
|
result.xmm32u(1) = (Bit8s) ((val32 >> 8) & 0xFF);
|
|
|
|
result.xmm32u(2) = (Bit8s) ((val32 >> 16) & 0xFF);
|
|
|
|
result.xmm32u(3) = (Bit8s) (val32 >> 24);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVSXBD_VdqWd: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 22 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVSXBQ_VdqWw(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit16u val16;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val16 = BX_READ_XMM_REG_LO_WORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val16 = read_virtual_word(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm64u(0) = (Bit8s) (val16 & 0xFF);
|
|
|
|
result.xmm64u(1) = (Bit8s) (val16 >> 8);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVSXBQ_VdqWw: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 23 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVSXWD_VdqWq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit64u val64;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val64 = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val64 = read_virtual_qword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm32u(0) = (Bit16s) (val64 & 0xFFFF);
|
|
|
|
result.xmm32u(1) = (Bit16s) ((val64 >> 16) & 0xFFFF);
|
|
|
|
result.xmm32u(2) = (Bit16s) ((val64 >> 32) & 0xFFFF);
|
|
|
|
result.xmm32u(3) = (Bit16s) (val64 >> 48);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVSXWD_VdqWq: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 24 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVSXWQ_VdqWd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit32u val32;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val32 = BX_READ_XMM_REG_LO_DWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val32 = read_virtual_dword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm64u(0) = (Bit16s) (val32 & 0xFFFF);
|
|
|
|
result.xmm64u(1) = (Bit16s) (val32 >> 16);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVSXWQ_VdqWd: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 25 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVSXDQ_VdqWq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit64u val64;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val64 = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val64 = read_virtual_qword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm64u(0) = (Bit32s) (val64 & 0xFFFFFFFF);
|
|
|
|
result.xmm64u(1) = (Bit32s) (val64 >> 32);
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVSXDQ_VdqWq: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-10-20 21:03:33 +04:00
|
|
|
/* 66 0F 38 2A */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::MOVNTDQA_VdqMdq(bxInstruction_c *i)
|
2007-10-20 21:03:33 +04:00
|
|
|
{
|
|
|
|
#if BX_SUPPORT_SSE >= 4
|
|
|
|
/* source must be memory reference */
|
|
|
|
if (i->modC0()) {
|
|
|
|
BX_INFO(("MOVNTDQA_VdqMdq: must be memory reference"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2007-10-20 21:03:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op;
|
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2008-01-10 22:37:56 +03:00
|
|
|
|
2008-08-08 13:22:49 +04:00
|
|
|
read_virtual_dqword_aligned(i->seg(), eaddr, (Bit8u *) &op);
|
2007-10-20 21:03:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), op);
|
|
|
|
#else
|
|
|
|
BX_INFO(("MOVNTDQA_VdqMdq: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2007-10-20 21:03:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 30 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVZXBW_VdqWq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit64u val64;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val64 = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val64 = read_virtual_qword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm16u(0) = val64 & 0xFF;
|
|
|
|
result.xmm16u(1) = (val64 >> 8) & 0xFF;
|
|
|
|
result.xmm16u(2) = (val64 >> 16) & 0xFF;
|
|
|
|
result.xmm16u(3) = (val64 >> 24) & 0xFF;
|
|
|
|
result.xmm16u(4) = (val64 >> 32) & 0xFF;
|
|
|
|
result.xmm16u(5) = (val64 >> 40) & 0xFF;
|
|
|
|
result.xmm16u(6) = (val64 >> 48) & 0xFF;
|
|
|
|
result.xmm16u(7) = val64 >> 56;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVZXBW_VdqWq: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 31 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVZXBD_VdqWd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit32u val32;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val32 = BX_READ_XMM_REG_LO_DWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val32 = read_virtual_dword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm32u(0) = val32 & 0xFF;
|
|
|
|
result.xmm32u(1) = (val32 >> 8) & 0xFF;
|
|
|
|
result.xmm32u(2) = (val32 >> 16) & 0xFF;
|
|
|
|
result.xmm32u(3) = val32 >> 24;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVZXBD_VdqWd: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 32 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVZXBQ_VdqWw(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit16u val16;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val16 = BX_READ_XMM_REG_LO_WORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val16 = read_virtual_word(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm64u(0) = val16 & 0xFF;
|
|
|
|
result.xmm64u(1) = val16 >> 8;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVZXBQ_VdqWw: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 33 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVZXWD_VdqWq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit64u val64;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val64 = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val64 = read_virtual_qword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm32u(0) = val64 & 0xFFFF;
|
|
|
|
result.xmm32u(1) = (val64 >> 16) & 0xFFFF;
|
|
|
|
result.xmm32u(2) = (val64 >> 32) & 0xFFFF;
|
|
|
|
result.xmm32u(3) = val64 >> 48;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVZXWD_VdqWq: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 34 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVZXWQ_VdqWd(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
2003-05-26 23:30:33 +04:00
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
2007-04-19 20:12:21 +04:00
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit32u val32;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
|
|
|
{
|
|
|
|
val32 = BX_READ_XMM_REG_LO_DWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2003-05-26 23:30:33 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val32 = read_virtual_dword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm64u(0) = val32 & 0xFFFF;
|
|
|
|
result.xmm64u(1) = val32 >> 16;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVZXWQ_VdqWd: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 38 35 */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PMOVZXDQ_VdqWq(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if BX_SUPPORT_SSE >= 4
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
BxPackedXmmRegister result;
|
|
|
|
Bit64u val64;
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if (i->modC0())
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
val64 = BX_READ_XMM_REG_LO_QWORD(i->rm());
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
2007-04-19 20:12:21 +04:00
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2007-04-19 20:12:21 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
val64 = read_virtual_qword(i->seg(), eaddr);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
result.xmm64u(0) = val64 & 0xFFFFFFFF;
|
|
|
|
result.xmm64u(1) = val64 >> 32;
|
|
|
|
|
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PMOVZXDQ_VdqWq: required SSE4, use --enable-sse option"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* 66 0F 3A 0F */
|
2008-03-23 00:29:41 +03:00
|
|
|
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PALIGNR_VdqWdqIb(bxInstruction_c *i)
|
2003-05-26 23:30:33 +04:00
|
|
|
{
|
2007-04-19 20:12:21 +04:00
|
|
|
#if (BX_SUPPORT_SSE >= 4) || (BX_SUPPORT_SSE >= 3 && BX_SUPPORT_SSE_EXTENSION > 0)
|
|
|
|
BX_CPU_THIS_PTR prepareSSE();
|
|
|
|
|
|
|
|
BxPackedXmmRegister op1 = BX_READ_XMM_REG(i->nnn()), op2, result;
|
|
|
|
|
|
|
|
/* op2 is a register or memory reference */
|
2003-05-26 23:30:33 +04:00
|
|
|
if (i->modC0()) {
|
2007-04-19 20:12:21 +04:00
|
|
|
op2 = BX_READ_XMM_REG(i->rm());
|
|
|
|
}
|
|
|
|
else {
|
2008-08-08 13:22:49 +04:00
|
|
|
bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
|
2007-04-19 20:12:21 +04:00
|
|
|
/* pointer, segment address pair */
|
2008-08-08 13:22:49 +04:00
|
|
|
readVirtualDQwordAligned(i->seg(), eaddr, (Bit8u *) &op2);
|
2003-05-26 23:30:33 +04:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
unsigned shift = i->Ib() * 8;
|
2007-01-29 00:27:31 +03:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
if(shift == 0) {
|
|
|
|
result.xmm64u(0) = op2.xmm64u(0);
|
|
|
|
result.xmm64u(1) = op2.xmm64u(1);
|
|
|
|
}
|
|
|
|
else if(shift < 64) {
|
|
|
|
result.xmm64u(0) = (op2.xmm64u(0) >> shift) | (op2.xmm64u(1) << (64-shift));
|
|
|
|
result.xmm64u(1) = (op2.xmm64u(1) >> shift) | (op1.xmm64u(0) << (64-shift));
|
|
|
|
}
|
|
|
|
else if(shift == 64) {
|
|
|
|
result.xmm64u(0) = op2.xmm64u(1);
|
|
|
|
result.xmm64u(1) = op1.xmm64u(0);
|
|
|
|
}
|
|
|
|
else if(shift < 128) {
|
|
|
|
shift -= 64;
|
|
|
|
result.xmm64u(0) = (op2.xmm64u(1) >> shift) | (op1.xmm64u(0) << (64-shift));
|
|
|
|
result.xmm64u(1) = (op1.xmm64u(0) >> shift) | (op1.xmm64u(1) << (64-shift));
|
|
|
|
}
|
|
|
|
else if(shift == 128) {
|
|
|
|
result.xmm64u(0) = op1.xmm64u(0);
|
|
|
|
result.xmm64u(1) = op1.xmm64u(1);
|
|
|
|
}
|
|
|
|
else if(shift < 192) {
|
|
|
|
shift -= 128;
|
|
|
|
result.xmm64u(0) = (op1.xmm64u(0) >> shift) | (op1.xmm64u(1) << (64-shift));
|
|
|
|
result.xmm64u(1) = (op1.xmm64u(1) >> shift);
|
|
|
|
}
|
|
|
|
else if(shift < 256) {
|
|
|
|
result.xmm64u(0) = op1.xmm64u(1) >> (shift - 192);
|
|
|
|
result.xmm64u(1) = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result.xmm64u(0) = 0;
|
|
|
|
result.xmm64u(1) = 0;
|
|
|
|
}
|
2003-05-26 23:30:33 +04:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
/* now write result back to destination */
|
|
|
|
BX_WRITE_XMM_REG(i->nnn(), result);
|
2003-05-26 23:30:33 +04:00
|
|
|
#else
|
2007-04-19 20:12:21 +04:00
|
|
|
BX_INFO(("PALIGNR_VdqWdqIb: required SSE3E, use --enable-sse and --enable-sse-extension options"));
|
2008-07-13 19:35:10 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0, 0);
|
2003-05-26 23:30:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
2007-04-19 20:12:21 +04:00
|
|
|
|
|
|
|
#endif // BX_SUPPORT_SSE >= 4 || (BX_SUPPORT_SSE >= 3 && BX_SUPPORT_SSE_EXTENSION > 0)
|