X86: Implement the PUSHF, POPF, SAHF, and LAHF instructions.
--HG-- extra : convert_revision : 37c63b1133022fa3432888592f8c84785fb95091
This commit is contained in:
parent
35a8bc56cd
commit
d8494325f0
3 changed files with 53 additions and 30 deletions
|
@ -313,17 +313,18 @@
|
||||||
default: WarnUnimpl::call_far_Ap();
|
default: WarnUnimpl::call_far_Ap();
|
||||||
}
|
}
|
||||||
0x3: WarnUnimpl::fwait(); //aka wait
|
0x3: WarnUnimpl::fwait(); //aka wait
|
||||||
0x4: WarnUnimpl::pushf_Fv();
|
0x4: PUSHF();
|
||||||
0x5: WarnUnimpl::popf_Fv();
|
0x5: POPF();
|
||||||
//Both of these should be illegal only if CPUID.AHF64=0,
|
//The 64 bit versions of both of these should be illegal only
|
||||||
//according to sandpile.org
|
//if CPUID says it isn't supported. For now, we'll just assume
|
||||||
|
//that it's supported.
|
||||||
0x6: decode MODE_SUBMODE {
|
0x6: decode MODE_SUBMODE {
|
||||||
0x0: UD2();
|
0x0: SAHF_64();
|
||||||
default: WarnUnimpl::sahf();
|
default: SAHF();
|
||||||
}
|
}
|
||||||
0x7: decode MODE_SUBMODE {
|
0x7: decode MODE_SUBMODE {
|
||||||
0x0: UD2();
|
0x0: LAHF_64();
|
||||||
default: WarnUnimpl::lahf();
|
default: LAHF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0x14: decode OPCODE_OP_BOTTOM3 {
|
0x14: decode OPCODE_OP_BOTTOM3 {
|
||||||
|
|
|
@ -53,10 +53,28 @@
|
||||||
#
|
#
|
||||||
# Authors: Gabe Black
|
# Authors: Gabe Black
|
||||||
|
|
||||||
microcode = ""
|
microcode = '''
|
||||||
#let {{
|
def macroop SAHF {
|
||||||
# class LAHF(Inst):
|
# This will fold to ah since this never executes in 64 bit mode.
|
||||||
# "GenFault ${new UnimpInstFault}"
|
ruflags rsp, dataSize=1
|
||||||
# class SAHF(Inst):
|
};
|
||||||
# "GenFault ${new UnimpInstFault}"
|
|
||||||
#}};
|
# This is allows the instruction to write to ah in 64 bit mode.
|
||||||
|
def macroop SAHF_64 {
|
||||||
|
ruflags t1
|
||||||
|
slli t1, t1, 8
|
||||||
|
mov t1, t1, rax, dataSize=1
|
||||||
|
mov rax, rax, t1, dataSize=2
|
||||||
|
};
|
||||||
|
|
||||||
|
def macroop LAHF {
|
||||||
|
# This will fold to ah since this never executes in 64 bit mode.
|
||||||
|
wruflags rsp, t0, dataSize=1
|
||||||
|
};
|
||||||
|
|
||||||
|
# This is allows the instruction to read from ah in 64 bit mode.
|
||||||
|
def macroop LAHF_64 {
|
||||||
|
srli t1, rax, 8, dataSize=2
|
||||||
|
wruflags t1, t0, dataSize=1
|
||||||
|
};
|
||||||
|
'''
|
||||||
|
|
|
@ -53,18 +53,22 @@
|
||||||
#
|
#
|
||||||
# Authors: Gabe Black
|
# Authors: Gabe Black
|
||||||
|
|
||||||
microcode = ""
|
microcode = '''
|
||||||
#let {{
|
def macroop PUSHF {
|
||||||
# class POPF(Inst):
|
.adjust_env oszIn64Override
|
||||||
# "GenFault ${new UnimpInstFault}"
|
|
||||||
# class POPFD(Inst):
|
# This should really read the whole flags register, not just user flags.
|
||||||
# "GenFault ${new UnimpInstFault}"
|
ruflags t1
|
||||||
# class POPFQ(Inst):
|
st t1, ss, [1, t0, rsp], "-env.dataSize"
|
||||||
# "GenFault ${new UnimpInstFault}"
|
subi rsp, rsp, dsz
|
||||||
# class PUSHF(Inst):
|
};
|
||||||
# "GenFault ${new UnimpInstFault}"
|
|
||||||
# class PUSHFD(Inst):
|
def macroop POPF {
|
||||||
# "GenFault ${new UnimpInstFault}"
|
.adjust_env oszIn64Override
|
||||||
# class pushfq(Inst):
|
|
||||||
# "GenFault ${new UnimpInstFault}"
|
ld t1, ss, [1, t0, rsp]
|
||||||
#}};
|
addi rsp, rsp, dsz
|
||||||
|
# This should really write the whole flags register, not just user flags.
|
||||||
|
wruflags t1, t0
|
||||||
|
};
|
||||||
|
'''
|
||||||
|
|
Loading…
Reference in a new issue