x86: implement fabs, fchs instructions
This commit is contained in:
parent
7fdcfdf08b
commit
91b00d98a5
5 changed files with 41 additions and 4 deletions
|
@ -68,8 +68,8 @@ format WarnUnimpl {
|
|||
}
|
||||
0x4: decode MODRM_MOD {
|
||||
0x3: decode MODRM_RM {
|
||||
0x0: fchs();
|
||||
0x1: fabs();
|
||||
0x0: Inst::FCHS();
|
||||
0x1: Inst::FABS();
|
||||
0x4: ftst();
|
||||
0x5: fxam();
|
||||
default: Inst::UD2();
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
# Authors: Gabe Black
|
||||
|
||||
microcode = '''
|
||||
# FABS
|
||||
# FCHS
|
||||
|
||||
def macroop FABS {
|
||||
absfp st(0), st(0)
|
||||
};
|
||||
|
||||
def macroop FCHS {
|
||||
chsfp st(0), st(0)
|
||||
};
|
||||
'''
|
||||
|
|
|
@ -331,4 +331,12 @@ let {{
|
|||
else if(FpSrcReg1 == FpSrcReg2)
|
||||
ccFlagBits = ccFlagBits | ZFBit;
|
||||
'''
|
||||
|
||||
class absfp(FpUnaryOp):
|
||||
code = 'FpDestReg = fabs(FpSrcReg1);'
|
||||
flag_code = 'FSW &= (~CC1Bit);'
|
||||
|
||||
class chsfp(FpUnaryOp):
|
||||
code = 'FpDestReg = (-1) * (FpSrcReg1);'
|
||||
flag_code = 'FSW &= (~CC1Bit);'
|
||||
}};
|
||||
|
|
|
@ -158,7 +158,11 @@ def operands {{
|
|||
# These register should needs to be more protected so that later
|
||||
# instructions don't map their indexes with an old value.
|
||||
'nccFlagBits': controlReg('MISCREG_RFLAGS', 65),
|
||||
|
||||
# Registers related to the state of x87 floating point unit.
|
||||
'TOP': controlReg('MISCREG_X87_TOP', 66, ctype='ub'),
|
||||
'FSW': controlReg('MISCREG_FSW', 67, ctype='uw'),
|
||||
|
||||
# The segment base as used by memory instructions.
|
||||
'SegBase': controlReg('MISCREG_SEG_EFF_BASE(segment)', 70),
|
||||
|
||||
|
|
|
@ -79,6 +79,25 @@ namespace X86ISA
|
|||
IDBit = 1 << 21
|
||||
};
|
||||
|
||||
enum X87StatusBit {
|
||||
// Exception Flags
|
||||
IEBit = 1 << 0,
|
||||
DEBit = 1 << 1,
|
||||
ZEBit = 1 << 2,
|
||||
OEBit = 1 << 3,
|
||||
UEBit = 1 << 4,
|
||||
PEBit = 1 << 5,
|
||||
|
||||
// !Exception Flags
|
||||
StackFaultBit = 1 << 6,
|
||||
ErrSummaryBit = 1 << 7,
|
||||
CC0Bit = 1 << 8,
|
||||
CC1Bit = 1 << 9,
|
||||
CC2Bit = 1 << 10,
|
||||
CC3Bit = 1 << 14,
|
||||
BusyBit = 1 << 15,
|
||||
};
|
||||
|
||||
enum MiscRegIndex
|
||||
{
|
||||
// Control registers
|
||||
|
|
Loading…
Reference in a new issue