2006-11-26 11:13:41 -07:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* Realmode X86 Emulator Library
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996-1999 SciTech Software, Inc.
|
|
|
|
* Copyright (C) David Mosberger-Tang
|
|
|
|
* Copyright (C) 1999 Egbert Eich
|
|
|
|
*
|
|
|
|
* ========================================================================
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and
|
|
|
|
* its documentation for any purpose is hereby granted without fee,
|
|
|
|
* provided that the above copyright notice appear in all copies and that
|
|
|
|
* both that copyright notice and this permission notice appear in
|
|
|
|
* supporting documentation, and that the name of the authors not be used
|
|
|
|
* in advertising or publicity pertaining to distribution of the software
|
|
|
|
* without specific, written prior permission. The authors makes no
|
|
|
|
* representations about the suitability of this software for any purpose.
|
|
|
|
* It is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
|
|
|
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* ========================================================================
|
|
|
|
*
|
|
|
|
* Language: ANSI C
|
|
|
|
* Environment: Any
|
|
|
|
* Developer: Kendall Bennett
|
|
|
|
*
|
|
|
|
* Description: This file contains the code to implement the decoding and
|
|
|
|
* emulation of the FPU instructions.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "x86emu/x86emui.h"
|
|
|
|
|
|
|
|
/*----------------------------- Implementation ----------------------------*/
|
|
|
|
|
|
|
|
/* opcode=0xd8 */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
x86emuOp_esc_coprocess_d8(u8 X86EMU_UNUSED(op1))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
START_OF_INSTR();
|
|
|
|
DECODE_PRINTF("ESC D8\n");
|
|
|
|
DECODE_CLEAR_SEGOVR();
|
|
|
|
END_OF_INSTR_NO_TRACE();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *x86emu_fpu_op_d9_tab[] = {
|
2006-11-26 11:13:41 -07:00
|
|
|
"FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ",
|
|
|
|
"FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t",
|
|
|
|
|
|
|
|
"FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ",
|
|
|
|
"FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t",
|
|
|
|
|
|
|
|
"FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ",
|
|
|
|
"FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t",
|
|
|
|
};
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *x86emu_fpu_op_d9_tab1[] = {
|
2006-11-26 11:13:41 -07:00
|
|
|
"FLD\t", "FLD\t", "FLD\t", "FLD\t",
|
|
|
|
"FLD\t", "FLD\t", "FLD\t", "FLD\t",
|
|
|
|
|
|
|
|
"FXCH\t", "FXCH\t", "FXCH\t", "FXCH\t",
|
|
|
|
"FXCH\t", "FXCH\t", "FXCH\t", "FXCH\t",
|
|
|
|
|
|
|
|
"FNOP", "ESC_D9", "ESC_D9", "ESC_D9",
|
|
|
|
"ESC_D9", "ESC_D9", "ESC_D9", "ESC_D9",
|
|
|
|
|
|
|
|
"FSTP\t", "FSTP\t", "FSTP\t", "FSTP\t",
|
|
|
|
"FSTP\t", "FSTP\t", "FSTP\t", "FSTP\t",
|
|
|
|
|
|
|
|
"FCHS", "FABS", "ESC_D9", "ESC_D9",
|
|
|
|
"FTST", "FXAM", "ESC_D9", "ESC_D9",
|
|
|
|
|
|
|
|
"FLD1", "FLDL2T", "FLDL2E", "FLDPI",
|
|
|
|
"FLDLG2", "FLDLN2", "FLDZ", "ESC_D9",
|
|
|
|
|
|
|
|
"F2XM1", "FYL2X", "FPTAN", "FPATAN",
|
|
|
|
"FXTRACT", "ESC_D9", "FDECSTP", "FINCSTP",
|
|
|
|
|
|
|
|
"FPREM", "FYL2XP1", "FSQRT", "ESC_D9",
|
|
|
|
"FRNDINT", "FSCALE", "ESC_D9", "ESC_D9",
|
|
|
|
};
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* DEBUG */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* opcode=0xd9 */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
x86emuOp_esc_coprocess_d9(u8 X86EMU_UNUSED(op1))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int mod, rl, rh;
|
|
|
|
uint destoffset = 0;
|
|
|
|
u8 stkelem = 0;
|
|
|
|
|
|
|
|
START_OF_INSTR();
|
|
|
|
FETCH_DECODE_MODRM(mod, rh, rl);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (mod != 3) {
|
|
|
|
DECODE_PRINTINSTR32(x86emu_fpu_op_d9_tab, mod, rh, rl);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF(x86emu_fpu_op_d9_tab1[(rh << 3) + rl]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm00_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm01_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm10_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3: /* register to register */
|
|
|
|
stkelem = (u8) rl;
|
|
|
|
if (rh < 4) {
|
|
|
|
DECODE_PRINTF2("ST(%d)\n", stkelem);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef X86EMU_FPU_PRESENT
|
|
|
|
/* execute */
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fld(X86EMU_FPU_STKTOP, stkelem);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fxch(X86EMU_FPU_STKTOP, stkelem);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rl) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_nop();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fstp(X86EMU_FPU_STKTOP, stkelem);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rl) {
|
|
|
|
case 0:
|
|
|
|
x86emu_fpu_R_fchs(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
x86emu_fpu_R_fabs(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
x86emu_fpu_R_ftst(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
x86emu_fpu_R_fxam(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* 2,3,6,7 */
|
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rl) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fld1(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fldl2t(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fldl2e(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fldpi(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fldlg2(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fldln2(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fldz(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
/* 7 */
|
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rl) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_f2xm1(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fyl2x(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fptan(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fpatan(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fxtract(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_decstp();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_incstp();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rl) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fprem(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fyl2xp1(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fsqrt(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_frndint(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fscale(X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fld(X86EMU_FPU_FLOAT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fst(X86EMU_FPU_FLOAT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fstp(X86EMU_FPU_FLOAT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fldenv(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fldcw(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fstenv(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fstcw(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) destoffset;
|
|
|
|
(void) stkelem;
|
|
|
|
#endif /* X86EMU_FPU_PRESENT */
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_CLEAR_SEGOVR();
|
|
|
|
END_OF_INSTR_NO_TRACE();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *x86emu_fpu_op_da_tab[] = {
|
2006-11-26 11:13:41 -07:00
|
|
|
"FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ",
|
|
|
|
"FICOMP\tDWORD PTR ",
|
|
|
|
"FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ",
|
|
|
|
"FIDIVR\tDWORD PTR ",
|
|
|
|
|
|
|
|
"FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ",
|
|
|
|
"FICOMP\tDWORD PTR ",
|
|
|
|
"FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ",
|
|
|
|
"FIDIVR\tDWORD PTR ",
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
"FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ",
|
|
|
|
"FICOMP\tDWORD PTR ",
|
|
|
|
"FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ",
|
|
|
|
"FIDIVR\tDWORD PTR ",
|
|
|
|
|
|
|
|
"ESC_DA ", "ESC_DA ", "ESC_DA ", "ESC_DA ",
|
|
|
|
"ESC_DA ", "ESC_DA ", "ESC_DA ", "ESC_DA ",
|
|
|
|
};
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* DEBUG */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* opcode=0xda */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
x86emuOp_esc_coprocess_da(u8 X86EMU_UNUSED(op1))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int mod, rl, rh;
|
|
|
|
uint destoffset = 0;
|
|
|
|
u8 stkelem = 0;
|
|
|
|
|
|
|
|
START_OF_INSTR();
|
|
|
|
FETCH_DECODE_MODRM(mod, rh, rl);
|
|
|
|
DECODE_PRINTINSTR32(x86emu_fpu_op_da_tab, mod, rh, rl);
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm00_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm01_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm10_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3: /* register to register */
|
|
|
|
stkelem = (u8) rl;
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef X86EMU_FPU_PRESENT
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_iadd(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_imul(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_icom(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_icomp(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_isub(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_isubr(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_idiv(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_idivr(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) destoffset;
|
|
|
|
(void) stkelem;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
DECODE_CLEAR_SEGOVR();
|
|
|
|
END_OF_INSTR_NO_TRACE();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *x86emu_fpu_op_db_tab[] = {
|
2006-11-26 11:13:41 -07:00
|
|
|
"FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ",
|
|
|
|
"ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ",
|
|
|
|
|
|
|
|
"FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ",
|
|
|
|
"ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ",
|
|
|
|
|
|
|
|
"FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ",
|
|
|
|
"ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ",
|
|
|
|
};
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* DEBUG */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* opcode=0xdb */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
x86emuOp_esc_coprocess_db(u8 X86EMU_UNUSED(op1))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int mod, rl, rh;
|
|
|
|
uint destoffset = 0;
|
|
|
|
|
|
|
|
START_OF_INSTR();
|
|
|
|
FETCH_DECODE_MODRM(mod, rh, rl);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (mod != 3) {
|
|
|
|
DECODE_PRINTINSTR32(x86emu_fpu_op_db_tab, mod, rh, rl);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else if (rh == 4) { /* === 11 10 0 nnn */
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rl) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF("FENI\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF("FDISI\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF("FCLEX\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF("FINIT\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF2("ESC_DB %0x\n", (mod << 6) + (rh << 3) + (rl));
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* DEBUG */
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm00_address(rl);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm01_address(rl);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm10_address(rl);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3: /* register to register */
|
2006-11-26 11:13:41 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef X86EMU_FPU_PRESENT
|
|
|
|
/* execute */
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rl) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_feni();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fdisi();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fclex();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_finit();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fild(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fist(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fistp(X86EMU_FPU_SHORT, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fld(X86EMU_FPU_LDBL, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fstp(X86EMU_FPU_LDBL, destoffset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) destoffset;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
DECODE_CLEAR_SEGOVR();
|
|
|
|
END_OF_INSTR_NO_TRACE();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *x86emu_fpu_op_dc_tab[] = {
|
2006-11-26 11:13:41 -07:00
|
|
|
"FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ",
|
|
|
|
"FCOMP\tQWORD PTR ",
|
|
|
|
"FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ",
|
|
|
|
"FDIVR\tQWORD PTR ",
|
|
|
|
|
|
|
|
"FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ",
|
|
|
|
"FCOMP\tQWORD PTR ",
|
|
|
|
"FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ",
|
|
|
|
"FDIVR\tQWORD PTR ",
|
|
|
|
|
|
|
|
"FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ",
|
|
|
|
"FCOMP\tQWORD PTR ",
|
|
|
|
"FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ",
|
|
|
|
"FDIVR\tQWORD PTR ",
|
|
|
|
|
|
|
|
"FADD\t", "FMUL\t", "FCOM\t", "FCOMP\t",
|
|
|
|
"FSUBR\t", "FSUB\t", "FDIVR\t", "FDIV\t",
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* DEBUG */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* opcode=0xdc */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
x86emuOp_esc_coprocess_dc(u8 X86EMU_UNUSED(op1))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int mod, rl, rh;
|
|
|
|
uint destoffset = 0;
|
|
|
|
u8 stkelem = 0;
|
|
|
|
|
|
|
|
START_OF_INSTR();
|
|
|
|
FETCH_DECODE_MODRM(mod, rh, rl);
|
|
|
|
DECODE_PRINTINSTR32(x86emu_fpu_op_dc_tab, mod, rh, rl);
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm00_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm01_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm10_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3: /* register to register */
|
|
|
|
stkelem = (u8) rl;
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef X86EMU_FPU_PRESENT
|
|
|
|
/* execute */
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fadd(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fmul(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fcom(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fcomp(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fsubr(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fsub(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fdivr(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fdiv(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fadd(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fmul(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fcom(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fcomp(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fsub(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fsubr(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fdiv(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fdivr(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) destoffset;
|
|
|
|
(void) stkelem;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
DECODE_CLEAR_SEGOVR();
|
|
|
|
END_OF_INSTR_NO_TRACE();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *x86emu_fpu_op_dd_tab[] = {
|
2006-11-26 11:13:41 -07:00
|
|
|
"FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ",
|
|
|
|
"FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t",
|
|
|
|
|
|
|
|
"FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ",
|
|
|
|
"FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t",
|
|
|
|
|
|
|
|
"FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ",
|
|
|
|
"FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t",
|
|
|
|
|
|
|
|
"FFREE\t", "FXCH\t", "FST\t", "FSTP\t",
|
|
|
|
"ESC_DD\t2C,", "ESC_DD\t2D,", "ESC_DD\t2E,", "ESC_DD\t2F,",
|
|
|
|
};
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* DEBUG */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* opcode=0xdd */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int mod, rl, rh;
|
|
|
|
uint destoffset = 0;
|
|
|
|
u8 stkelem = 0;
|
|
|
|
|
|
|
|
START_OF_INSTR();
|
|
|
|
FETCH_DECODE_MODRM(mod, rh, rl);
|
|
|
|
DECODE_PRINTINSTR32(x86emu_fpu_op_dd_tab, mod, rh, rl);
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm00_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm01_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm10_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3: /* register to register */
|
|
|
|
stkelem = (u8) rl;
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef X86EMU_FPU_PRESENT
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_ffree(stkelem);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fxch(stkelem);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fst(stkelem); /* register version */
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fstp(stkelem); /* register version */
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fld(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fst(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fstp(X86EMU_FPU_DOUBLE, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_frstor(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fsave(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fstsw(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) destoffset;
|
|
|
|
(void) stkelem;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
DECODE_CLEAR_SEGOVR();
|
|
|
|
END_OF_INSTR_NO_TRACE();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *x86emu_fpu_op_de_tab[] = {
|
2006-11-26 11:13:41 -07:00
|
|
|
"FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ",
|
|
|
|
"FICOMP\tWORD PTR ",
|
|
|
|
"FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ",
|
|
|
|
"FIDIVR\tWORD PTR ",
|
|
|
|
|
|
|
|
"FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ",
|
|
|
|
"FICOMP\tWORD PTR ",
|
|
|
|
"FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ",
|
|
|
|
"FIDIVR\tWORD PTR ",
|
|
|
|
|
|
|
|
"FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ",
|
|
|
|
"FICOMP\tWORD PTR ",
|
|
|
|
"FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ",
|
|
|
|
"FIDIVR\tWORD PTR ",
|
|
|
|
|
|
|
|
"FADDP\t", "FMULP\t", "FCOMP\t", "FCOMPP\t",
|
|
|
|
"FSUBRP\t", "FSUBP\t", "FDIVRP\t", "FDIVP\t",
|
|
|
|
};
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* DEBUG */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* opcode=0xde */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
x86emuOp_esc_coprocess_de(u8 X86EMU_UNUSED(op1))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int mod, rl, rh;
|
|
|
|
uint destoffset = 0;
|
|
|
|
u8 stkelem = 0;
|
|
|
|
|
|
|
|
START_OF_INSTR();
|
|
|
|
FETCH_DECODE_MODRM(mod, rh, rl);
|
|
|
|
DECODE_PRINTINSTR32(x86emu_fpu_op_de_tab, mod, rh, rl);
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm00_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm01_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm10_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3: /* register to register */
|
|
|
|
stkelem = (u8) rl;
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef X86EMU_FPU_PRESENT
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_faddp(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fmulp(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fcomp(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
if (stkelem == 1)
|
2012-06-10 07:21:05 -06:00
|
|
|
x86emu_fpu_R_fcompp(stkelem, X86EMU_FPU_STKTOP);
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
x86emu_fpu_illegal();
|
2006-11-26 11:13:41 -07:00
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fsubrp(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fsubp(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fdivrp(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fdivp(stkelem, X86EMU_FPU_STKTOP);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fiadd(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fimul(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_ficom(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_ficomp(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fisub(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fisubr(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fidiv(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fidivr(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) destoffset;
|
|
|
|
(void) stkelem;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
DECODE_CLEAR_SEGOVR();
|
|
|
|
END_OF_INSTR_NO_TRACE();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *x86emu_fpu_op_df_tab[] = {
|
2006-11-26 11:13:41 -07:00
|
|
|
/* mod == 00 */
|
|
|
|
"FILD\tWORD PTR ", "ESC_DF\t39\n", "FIST\tWORD PTR ", "FISTP\tWORD PTR ",
|
|
|
|
"FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ",
|
|
|
|
"FISTP\tQWORD PTR ",
|
|
|
|
|
|
|
|
/* mod == 01 */
|
|
|
|
"FILD\tWORD PTR ", "ESC_DF\t39 ", "FIST\tWORD PTR ", "FISTP\tWORD PTR ",
|
|
|
|
"FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ",
|
|
|
|
"FISTP\tQWORD PTR ",
|
|
|
|
|
|
|
|
/* mod == 10 */
|
|
|
|
"FILD\tWORD PTR ", "ESC_DF\t39 ", "FIST\tWORD PTR ", "FISTP\tWORD PTR ",
|
|
|
|
"FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ",
|
|
|
|
"FISTP\tQWORD PTR ",
|
|
|
|
|
|
|
|
/* mod == 11 */
|
|
|
|
"FFREE\t", "FXCH\t", "FST\t", "FSTP\t",
|
|
|
|
"ESC_DF\t3C,", "ESC_DF\t3D,", "ESC_DF\t3E,", "ESC_DF\t3F,"
|
|
|
|
};
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* DEBUG */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* opcode=0xdf */
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
x86emuOp_esc_coprocess_df(u8 X86EMU_UNUSED(op1))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int mod, rl, rh;
|
|
|
|
uint destoffset = 0;
|
|
|
|
u8 stkelem = 0;
|
|
|
|
|
|
|
|
START_OF_INSTR();
|
|
|
|
FETCH_DECODE_MODRM(mod, rh, rl);
|
|
|
|
DECODE_PRINTINSTR32(x86emu_fpu_op_df_tab, mod, rh, rl);
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm00_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm01_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
destoffset = decode_rm10_address(rl);
|
|
|
|
DECODE_PRINTF("\n");
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3: /* register to register */
|
|
|
|
stkelem = (u8) rl;
|
2006-11-26 11:13:41 -07:00
|
|
|
DECODE_PRINTF2("\tST(%d)\n", stkelem);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef X86EMU_FPU_PRESENT
|
|
|
|
switch (mod) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_ffree(stkelem);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fxch(stkelem);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fst(stkelem); /* register version */
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_R_fstp(stkelem); /* register version */
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (rh) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 0:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fild(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 1:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_illegal();
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 2:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fist(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 3:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fistp(X86EMU_FPU_WORD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 4:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fbld(X86EMU_FPU_BSD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 5:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fild(X86EMU_FPU_LONG, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 6:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fbstp(X86EMU_FPU_BSD, destoffset);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
case 7:
|
2006-11-26 11:13:41 -07:00
|
|
|
x86emu_fpu_M_fistp(X86EMU_FPU_LONG, destoffset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) destoffset;
|
|
|
|
(void) stkelem;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
DECODE_CLEAR_SEGOVR();
|
|
|
|
END_OF_INSTR_NO_TRACE();
|
|
|
|
}
|