x86: implements x87 mult/div instructions

This commit is contained in:
Nilay Vaish 2015-04-13 17:33:57 -05:00
parent dea7acdb3e
commit e596e52498
3 changed files with 130 additions and 11 deletions

View file

@ -45,7 +45,10 @@ format WarnUnimpl {
// 32-bit memory operand
default: Inst::FADD1(Md);
}
0x1: fmul();
0x1: decode MODRM_MOD {
0x3: Inst::FMUL1(Eq);
default: Inst::FMUL1(Md);
}
0x2: fcom();
0x3: fcomp();
0x4: decode MODRM_MOD {
@ -53,7 +56,10 @@ format WarnUnimpl {
default: Inst::FSUB1(Md);
}
0x5: fsubr();
0x6: fdiv();
0x6: decode MODRM_MOD {
0x3: Inst::FDIV1(Eq);
default: Inst::FDIV1(Md);
}
0x7: fdivr();
}
0x1: decode MODRM_REG {
@ -210,7 +216,10 @@ format WarnUnimpl {
0x3: Inst::FADD2(Eq);
default: Inst::FADD2(Mq);
}
0x1: fmul();
0x1: decode MODRM_MOD {
0x3: Inst::FMUL2(Eq);
default: Inst::FMUL2(Mq);
}
0x2: decode MODRM_MOD {
0x3: Inst::UD2();
default: fcom();
@ -229,10 +238,10 @@ format WarnUnimpl {
}
0x6: decode MODRM_MOD {
0x3: fdivr();
default: fdiv();
default: Inst::FDIV2(Mq);
}
0x7: decode MODRM_MOD {
0x3: fdiv();
0x3: Inst::FDIV2(Eq);
default: fdivr();
}
}
@ -282,7 +291,7 @@ format WarnUnimpl {
default: fiadd();
}
0x1: decode MODRM_MOD {
0x3: fmulp();
0x3: Inst::FMULP(Eq);
default: fimul();
}
0x2: decode MODRM_MOD {
@ -312,7 +321,7 @@ format WarnUnimpl {
default: fidiv();
}
0x7: decode MODRM_MOD {
0x3: fdivp();
0x3: Inst::FDIVP(Eq);
default: fidivr();
}
}

View file

@ -36,8 +36,63 @@
# Authors: Gabe Black
microcode = '''
# FDIV
# FDIVP
def macroop FDIV1_R
{
divfp st(0), st(0), sti
};
def macroop FDIV1_M
{
ldfp87 ufp1, seg, sib, disp
divfp st(0), st(0), ufp1
};
def macroop FDIV1_P
{
rdip t7
ldfp87 ufp1, seg, riprel, disp
divfp st(0), st(0), ufp1
};
def macroop FDIV2_R
{
divfp sti, sti, st(0)
};
def macroop FDIV2_M
{
ldfp87 ufp1, seg, sib, disp
divfp st(0), st(0), ufp1
};
def macroop FDIV2_P
{
rdip t7
ldfp87 ufp1, seg, riprel, disp
divfp st(0), st(0), ufp1
};
def macroop FDIVP
{
divfp st(1), st(1), st(0), spm=1
};
def macroop FDIVP_R
{
divfp sti, sti, st(0), spm=1
};
def macroop FDIVP_M
{
fault "std::make_shared<UnimpInstFault>()"
};
def macroop FDIVP_P
{
fault "std::make_shared<UnimpInstFault>()"
};
# FIDIV
# FDIVR
# FDIVRP

View file

@ -36,7 +36,62 @@
# Authors: Gabe Black
microcode = '''
# FMUL
# FMULP
def macroop FMUL1_R
{
mulfp st(0), sti, st(0)
};
def macroop FMUL1_M
{
ldfp87 ufp1, seg, sib, disp
mulfp st(0), st(0), ufp1
};
def macroop FMUL1_P
{
rdip t7
ldfp87 ufp1, seg, riprel, disp
mulfp st(0), st(0), ufp1
};
def macroop FMUL2_R
{
mulfp sti, sti, st(0)
};
def macroop FMUL2_M
{
ldfp87 ufp1, seg, sib, disp
mulfp st(0), st(0), ufp1
};
def macroop FMUL2_P
{
rdip t7
ldfp87 ufp1, seg, riprel, disp
mulfp st(0), st(0), ufp1
};
def macroop FMULP
{
mulfp st(1), st(0), st(1), spm=1
};
def macroop FMULP_R
{
mulfp sti, sti, st(0), spm=1
};
def macroop FMULP_M
{
fault "std::make_shared<UnimpInstFault>()"
};
def macroop FMULP_P
{
fault "std::make_shared<UnimpInstFault>()"
};
# FIMUL
'''