}
}
}
+ //Figure out what segment to use. This won't be entirely accurate since
+ //the presence of a displacement is supposed to make the instruction
+ //default to the data segment.
+ if (base != INTREG_RBP && base != INTREG_RSP ||
+ 0/*Has an immediate offset*/) {
+ seg = SEGMENT_REG_DS;
+ //Handle any segment override that might have been in the instruction
+ int segFromInst = machInst.legacy.seg;
+ if (segFromInst)
+ seg = (SegmentRegIndex)(segFromInst - 1);
+ } else {
+ seg = SEGMENT_REG_SS;
+ }
}
#ifndef __ARCH_X86_EMULENV_HH__
#define __ARCH_X86_EMULENV_HH__
-#include "arch/x86/types.hh"
#include "arch/x86/intregs.hh"
+#include "arch/x86/segmentregs.hh"
+#include "arch/x86/types.hh"
namespace X86ISA
{
{
RegIndex reg;
RegIndex regm;
+ SegmentRegIndex seg;
uint8_t scale;
RegIndex index;
RegIndex base;
EmulEnv(RegIndex _reg, RegIndex _regm,
int _dataSize, int _addressSize, int _stackSize) :
- reg(_reg), regm(_regm),
+ reg(_reg), regm(_regm), seg(SEGMENT_REG_DS),
scale(0), index(NUM_INTREGS),
base(NUM_INTREGS),
dataSize(_dataSize), addressSize(_addressSize),
def macroop ADD_M_I
{
limm t2, imm
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
add t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ADD_P_I
{
rdip t7
limm t2, imm
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
add t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ADD_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
add t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ADD_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
add t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ADD_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
add reg, reg, t1, flags=(OF,SF,ZF,AF,PF,CF)
};
def macroop ADD_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
add reg, reg, t1, flags=(OF,SF,ZF,AF,PF,CF)
};
def macroop SUB_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sub reg, reg, t1, flags=(OF,SF,ZF,AF,PF,CF)
};
def macroop SUB_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sub reg, reg, t1, flags=(OF,SF,ZF,AF,PF,CF)
};
def macroop SUB_M_I
{
limm t2, imm
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sub t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SUB_P_I
{
rdip t7
limm t2, imm
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sub t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SUB_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sub t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SUB_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sub t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ADC_R_R
def macroop ADC_M_I
{
limm t2, imm
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
adc t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ADC_P_I
{
rdip t7
limm t2, imm
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
adc t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ADC_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
adc t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ADC_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
adc t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ADC_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
adc reg, reg, t1, flags=(OF,SF,ZF,AF,PF,CF)
};
def macroop ADC_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
adc reg, reg, t1, flags=(OF,SF,ZF,AF,PF,CF)
};
def macroop SBB_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sbb reg, reg, t1, flags=(OF,SF,ZF,AF,PF,CF)
};
def macroop SBB_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sbb reg, reg, t1, flags=(OF,SF,ZF,AF,PF,CF)
};
def macroop SBB_M_I
{
limm t2, imm
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sbb t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SBB_P_I
{
rdip t7
limm t2, imm
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sbb t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SBB_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sbb t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SBB_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sbb t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop NEG_R
def macroop NEG_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sub t1, t0, t1, flags=(CF,OF,SF,ZF,AF,PF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop NEG_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sub t1, t0, t1, flags=(CF,OF,SF,ZF,AF,PF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
'''
def macroop INC_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
addi t1, t1, 1, flags=(OF, SF, ZF, AF, PF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop INC_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
- addi reg, reg, 1, flags=(OF, SF, ZF, AF, PF)
- st t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
+ addi t1, t1, 1, flags=(OF, SF, ZF, AF, PF)
+ st t1, seg, riprel, disp
};
def macroop DEC_R
def macroop DEC_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
subi t1, t1, 1, flags=(OF, SF, ZF, AF, PF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop DEC_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
- subi reg, reg, 1, flags=(OF, SF, ZF, AF, PF)
- st t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
+ subi t1, t1, 1, flags=(OF, SF, ZF, AF, PF)
+ st t1, seg, riprel, disp
};
'''
def macroop MUL_B_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mul1u rax, rax, t1, dataSize="2"
};
def macroop MUL_B_P
{
rdip t7
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, riprel, disp
mul1u rax, rax, t1, dataSize="2"
};
def macroop MUL_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
muleh rdx, rax, t1
mulel rax, rax, t1
};
def macroop MUL_P
{
rdip t7
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, riprel, disp
muleh rdx, rax, t1
mulel rax, rax, t1
};
def macroop IMUL_B_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mul1s rax, rax, t1, dataSize="2"
};
def macroop IMUL_B_P
{
rdip t7
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, riprel, disp
mul1s rax, rax, t1, dataSize="2"
};
def macroop IMUL_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
muleh rdx, rax, t1
mulel rax, rax, t1
};
def macroop IMUL_P
{
rdip t7
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, riprel, disp
muleh rdx, rax, t1
mulel rax, rax, t1
};
def macroop IMUL_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mulel reg, reg, t1
};
def macroop IMUL_R_P
{
rdip t7
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, riprel, disp
mulel reg, reg, t1
};
def macroop IMUL_R_M_I
{
limm t1, imm
- ld t2, ds, [scale, index, base], disp
+ ld t2, seg, sib, disp
mulel reg, t2, t1
};
{
rdip t7
limm t1, imm
- ld t2, ds, [0, t0, t7]
+ ld t2, seg, riprel
mulel reg, t2, t1
};
def macroop DIV_B_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
div1 rax, rax, t1
};
def macroop DIV_B_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
div1 rax, rax, t1
};
def macroop DIV_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
divr rdx, rax, t1
divq rax, rax, t1
};
def macroop DIV_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
divr rdx, rax, t1
divq rax, rax, t1
};
'''
#let {{
-# class MUL(Inst):
-# "GenFault ${new UnimpInstFault}"
-# class IMUL(Inst):
-# "GenFault ${new UnimpInstFault}"
-# class DIV(Inst):
-# "GenFault ${new UnimpInstFault}"
# class IDIV(Inst):
# "GenFault ${new UnimpInstFault}"
#}};
microcode = '''
def macroop CMP_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sub t0, reg, t1, flags=(OF, SF, ZF, AF, PF, CF)
};
def macroop CMP_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sub t0, reg, t1, flags=(OF, SF, ZF, AF, PF, CF)
};
def macroop CMP_M_I
{
limm t2, imm
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF)
};
{
limm t2, imm
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF)
};
def macroop CMP_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sub t0, t1, reg, flags=(OF, SF, ZF, AF, PF, CF)
};
def macroop CMP_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sub t0, t1, reg, flags=(OF, SF, ZF, AF, PF, CF)
};
{
movi t1, t1, 1, flags=(CZF,)
movi t1, t1, 0, flags=(nCZF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETZ_P
rdip t7
movi t1, t1, 1, flags=(CZF,)
movi t1, t1, 0, flags=(nCZF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETNZ_R
{
movi t1, t1, 1, flags=(nCZF,)
movi t1, t1, 0, flags=(CZF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETNZ_P
rdip t7
movi t1, t1, 1, flags=(nCZF,)
movi t1, t1, 0, flags=(CZF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETB_R
{
movi t1, t1, 1, flags=(CCF,)
movi t1, t1, 0, flags=(nCCF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETB_P
rdip t7
movi t1, t1, 1, flags=(CCF,)
movi t1, t1, 0, flags=(nCCF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETNB_R
{
movi t1, t1, 1, flags=(nCCF,)
movi t1, t1, 0, flags=(CCF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETNB_P
rdip t7
movi t1, t1, 1, flags=(nCCF,)
movi t1, t1, 0, flags=(CCF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETBE_R
{
movi t1, t1, 1, flags=(CCvZF,)
movi t1, t1, 0, flags=(nCCvZF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETBE_P
rdip t7
movi t1, t1, 1, flags=(CCvZF,)
movi t1, t1, 0, flags=(nCCvZF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETNBE_R
{
movi t1, t1, 1, flags=(nCCvZF,)
movi t1, t1, 0, flags=(CCvZF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETNBE_P
rdip t7
movi t1, t1, 1, flags=(nCCvZF,)
movi t1, t1, 0, flags=(CCvZF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETS_R
{
movi t1, t1, 1, flags=(CSF,)
movi t1, t1, 0, flags=(nCSF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETS_P
rdip t7
movi t1, t1, 1, flags=(CSF,)
movi t1, t1, 0, flags=(nCSF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETNS_R
{
movi t1, t1, 1, flags=(nCSF,)
movi t1, t1, 0, flags=(CSF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETNS_P
rdip t7
movi t1, t1, 1, flags=(nCSF,)
movi t1, t1, 0, flags=(CSF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETP_R
{
movi t1, t1, 1, flags=(CPF,)
movi t1, t1, 0, flags=(nCPF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETP_P
rdip t7
movi t1, t1, 1, flags=(CPF,)
movi t1, t1, 0, flags=(nCPF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETNP_R
{
movi t1, t1, 1, flags=(nCPF,)
movi t1, t1, 0, flags=(CPF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETNP_P
rdip t7
movi t1, t1, 1, flags=(nCPF,)
movi t1, t1, 0, flags=(CPF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETL_R
{
movi t1, t1, 1, flags=(CSxOF,)
movi t1, t1, 0, flags=(nCSxOF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETL_P
rdip t7
movi t1, t1, 1, flags=(CSxOF,)
movi t1, t1, 0, flags=(nCSxOF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETNL_R
{
movi t1, t1, 1, flags=(nCSxOF,)
movi t1, t1, 0, flags=(CSxOF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETNL_P
rdip t7
movi t1, t1, 1, flags=(nCSxOF,)
movi t1, t1, 0, flags=(CSxOF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETLE_R
{
movi t1, t1, 1, flags=(CSxOvZF,)
movi t1, t1, 0, flags=(nCSxOvZF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETLE_P
rdip t7
movi t1, t1, 1, flags=(CSxOvZF,)
movi t1, t1, 0, flags=(nCSxOvZF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETNLE_R
{
movi t1, t1, 1, flags=(nCSxOvZF,)
movi t1, t1, 0, flags=(CSxOvZF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETNLE_P
rdip t7
movi t1, t1, 1, flags=(nCSxOvZF,)
movi t1, t1, 0, flags=(CSxOvZF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETO_R
{
movi t1, t1, 1, flags=(COF,)
movi t1, t1, 0, flags=(nCOF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETO_P
rdip t7
movi t1, t1, 1, flags=(COF,)
movi t1, t1, 0, flags=(nCOF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SETNO_R
{
movi t1, t1, 1, flags=(nCOF,)
movi t1, t1, 0, flags=(COF,)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SETNO_P
rdip t7
movi t1, t1, 1, flags=(nCOF,)
movi t1, t1, 0, flags=(COF,)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
'''
microcode = '''
def macroop TEST_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
and t0, t1, reg, flags=(SF, ZF, PF)
};
def macroop TEST_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
and t0, t1, reg, flags=(SF, ZF, PF)
};
def macroop TEST_M_I
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
limm t2, imm
and t0, t1, t2, flags=(SF, ZF, PF)
};
def macroop TEST_P_I
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
limm t2, imm
and t0, t1, t2, flags=(SF, ZF, PF)
};
.adjust_env oszIn64Override
rdip t7
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
subi rsp, rsp, dsz
st t7, ss, [0, t0, rsp]
wripi t1, 0
.adjust_env oszIn64Override
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
subi rsp, rsp, dsz
st t7, ss, [0, t0, rsp]
wripi t1, 0
#
# Authors: Gabe Black
-microcode = ""
-#let {{
-# class JCC(Inst):
-# "GenFault ${new UnimpInstFault}"
-#}};
+microcode = '''
+def macroop JZ_I
+{
+ # Make the defualt data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(CZF,)
+};
+
+def macroop JNZ_I
+{
+ # Make the defualt data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(nCZF,)
+};
+
+def macroop JB_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(CCF,)
+};
+
+def macroop JNB_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(nCCF,)
+};
+
+def macroop JBE_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(CCvZF,)
+};
+
+def macroop JNBE_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(nCCvZF,)
+};
+
+def macroop JS_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(CSF,)
+};
+
+def macroop JNS_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(nCSF,)
+};
+
+def macroop JP_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(CPF,)
+};
+
+def macroop JNP_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(nCPF,)
+};
+
+def macroop JL_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(CSxOF,)
+};
+
+def macroop JNL_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(nCSxOF,)
+};
+
+def macroop JLE_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(CSxOvZF,)
+};
+
+def macroop JNLE_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(nCSxOvZF,)
+};
+
+def macroop JO_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(COF,)
+};
+
+def macroop JNO_I
+{
+ # Make the default data size of jumps 64 bits in 64 bit mode
+ .adjust_env oszIn64Override
+
+ rdip t1
+ limm t2, imm
+ wrip t1, t2, flags=(nCOF,)
+};
+'''
# Authors: Gabe Black
microcode = '''
-def macroop JZ_I
-{
- # Make the defualt data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(CZF,)
-};
-
-def macroop JNZ_I
-{
- # Make the defualt data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(nCZF,)
-};
-
-def macroop JB_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(CCF,)
-};
-
-def macroop JNB_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(nCCF,)
-};
-
-def macroop JBE_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(CCvZF,)
-};
-
-def macroop JNBE_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(nCCvZF,)
-};
-
-def macroop JS_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(CSF,)
-};
-
-def macroop JNS_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(nCSF,)
-};
-
-def macroop JP_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(CPF,)
-};
-
-def macroop JNP_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(nCPF,)
-};
-
-def macroop JL_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(CSxOF,)
-};
-
-def macroop JNL_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(nCSxOF,)
-};
-
-def macroop JLE_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(CSxOvZF,)
-};
-
-def macroop JNLE_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(nCSxOvZF,)
-};
-
-def macroop JO_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(COF,)
-};
-
-def macroop JNO_I
-{
- # Make the default data size of jumps 64 bits in 64 bit mode
- .adjust_env oszIn64Override
-
- rdip t1
- limm t2, imm
- wrip t1, t2, flags=(nCOF,)
-};
-
def macroop JMP_I
{
# Make the default data size of jumps 64 bits in 64 bit mode
# Make the default data size of jumps 64 bits in 64 bit mode
.adjust_env oszIn64Override
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
wripi t1, 0
};
.adjust_env oszIn64Override
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
wripi t1, 0
};
'''
# Make the default data size of rets 64 bits in 64 bit mode
.adjust_env oszIn64Override
- ld t1, ss, [0, t0, rsp]
+ ld t1, ss, [1, t0, rsp]
addi rsp, rsp, dsz
wripi t1, 0
};
.adjust_env oszIn64Override
limm t2, imm
- ld t1, ss, [0, t0, rsp]
+ ld t1, ss, [1, t0, rsp]
addi rsp, rsp, dsz
add rsp, rsp, t2
wripi t1, 0
sra regm, regm, "env.dataSize * 8 - 1"
};
'''
-#let {{
-# class CBW(Inst):
-# "GenFault ${new UnimpInstFault}"
-# class CWDE(Inst):
-# "GenFault ${new UnimpInstFault}"
-# class CDQE(Inst):
-# "GenFault ${new UnimpInstFault}"
-# class CWD(Inst):
-# "GenFault ${new UnimpInstFault}"
-# class CDQ(Inst):
-# "GenFault ${new UnimpInstFault}"
-# class CQO(Inst):
-# "GenFault ${new UnimpInstFault}"
-#}};
def macroop CMOVZ_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(CZF,)
};
def macroop CMOVZ_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(CZF,)
};
def macroop CMOVNZ_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(nCZF,)
};
def macroop CMOVNZ_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(nCZF,)
};
def macroop CMOVB_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(CCF,)
};
def macroop CMOVB_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(CCF,)
};
def macroop CMOVNB_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(nCCF,)
};
def macroop CMOVNB_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(nCCF,)
};
def macroop CMOVBE_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(CCvZF,)
};
def macroop CMOVBE_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(CCvZF,)
};
def macroop CMOVNBE_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(nCCvZF,)
};
def macroop CMOVNBE_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(nCCvZF,)
};
def macroop CMOVS_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(CSF,)
};
def macroop CMOVS_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(CSF,)
};
def macroop CMOVNS_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(nCSF,)
};
def macroop CMOVNS_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(nCSF,)
};
def macroop CMOVP_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(CPF,)
};
def macroop CMOVP_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(CPF,)
};
def macroop CMOVNP_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, regm, flags=(nCPF,)
};
def macroop CMOVNP_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, regm, flags=(nCPF,)
};
def macroop CMOVL_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(CSxOF,)
};
def macroop CMOVL_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(CSxOF,)
};
def macroop CMOVNL_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(nCSxOF,)
};
def macroop CMOVNL_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(nCSxOF,)
};
def macroop CMOVLE_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(CSxOvZF,)
};
def macroop CMOVLE_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(CSxOvZF,)
};
def macroop CMOVNLE_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(nCSxOvZF,)
};
def macroop CMOVNLE_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(nCSxOvZF,)
};
def macroop CMOVO_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(COF,)
};
def macroop CMOVO_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(COF,)
};
def macroop CMOVNO_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
mov reg, reg, t1, flags=(nCOF,)
};
def macroop CMOVNO_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
mov reg, reg, t1, flags=(nCOF,)
};
'''
};
def macroop MOV_M_R {
- st reg, ds, [scale, index, base], disp
+ st reg, seg, sib, disp
};
def macroop MOV_P_R {
rdip t7
- st reg, ds, [0, t0, t7], disp
+ st reg, seg, riprel, disp
};
def macroop MOV_R_M {
- ld reg, ds, [scale, index, base], disp
+ ld reg, seg, sib, disp
};
def macroop MOV_R_P {
rdip t7
- ld reg, ds, [0, t0, t7], disp
+ ld reg, seg, riprel, disp
};
def macroop MOV_R_I {
def macroop MOV_M_I {
limm t1, imm
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop MOV_P_I {
rdip t7
limm t1, imm
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
#
};
def macroop MOVSXD_R_M {
- ld t1, ds, [scale, index, base], disp, dataSize=4
+ ld t1, seg, sib, disp, dataSize=4
sext reg, t1, 32
};
def macroop MOVSXD_R_P {
rdip t7
- ld t1, ds, [0, t0, t7], disp, dataSize=4
+ ld t1, seg, riprel, disp, dataSize=4
sext reg, t1, 32
};
};
def macroop MOVSX_B_R_M {
- ld reg, ds, [scale, index, base], disp, dataSize=1
+ ld reg, seg, sib, disp, dataSize=1
sext reg, reg, 8
};
def macroop MOVSX_B_R_P {
rdip t7
- ld reg, ds, [0, t0, t7], disp, dataSize=1
+ ld reg, seg, riprel, disp, dataSize=1
sext reg, reg, 8
};
};
def macroop MOVSX_W_R_M {
- ld reg, ds, [scale, index, base], disp, dataSize=2
+ ld reg, seg, sib, disp, dataSize=2
sext reg, reg, 16
};
def macroop MOVSX_W_R_P {
rdip t7
- ld reg, ds, [0, t0, t7], disp, dataSize=2
+ ld reg, seg, riprel, disp, dataSize=2
sext reg, reg, 16
};
};
def macroop MOVZX_B_R_M {
- ld t1, ds, [scale, index, base], disp, dataSize=1
+ ld t1, seg, sib, disp, dataSize=1
zext reg, t1, 8
};
def macroop MOVZX_B_R_P {
rdip t7
- ld t1, ds, [0, t0, t7], disp, dataSize=1
+ ld t1, seg, riprel, disp, dataSize=1
zext reg, t1, 8
};
};
def macroop MOVZX_W_R_M {
- ld t1, ds, [scale, index, base], disp, dataSize=2
+ ld t1, seg, sib, disp, dataSize=2
zext reg, t1, 16
};
def macroop MOVZX_W_R_P {
rdip t7
- ld t1, ds, [0, t0, t7], disp, dataSize=2
+ ld t1, seg, riprel, disp, dataSize=2
zext reg, t1, 16
};
'''
#let {{
-# class MOV(Inst):
-# "Mov ^0 ^0 ^1"
-# class MOVSX(Inst):
-# "GenFault ${new UnimpInstFault}"
-# class MOVZX(Inst):
-# "GenFault ${new UnimpInstFault}"
# class MOVD(Inst):
# "GenFault ${new UnimpInstFault}"
# class MOVNTI(Inst):
# Make the default data size of pops 64 bits in 64 bit mode
.adjust_env oszIn64Override
- ld reg, ss, [0, t0, rsp]
+ ld reg, ss, [1, t0, rsp]
addi rsp, rsp, dsz
};
# Make the default data size of pops 64 bits in 64 bit mode
.adjust_env oszIn64Override
- ld t1, ss, [0, t0, rsp]
+ ld t1, ss, [1, t0, rsp]
addi rsp, rsp, dsz
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop POP_P {
.adjust_env oszIn64Override
rdip t7
- ld t1, ss, [0, t0, rsp]
+ ld t1, ss, [1, t0, rsp]
addi rsp, rsp, dsz
- st t1, ds, [0, t0, t7]
+ st t1, seg, riprel, disp
};
def macroop PUSH_R {
# This needs to work slightly differently from the other versions of push
# because the -original- version of the stack pointer is what gets pushed
- st reg, ss, [0, t0, rsp], "-env.dataSize"
+ st reg, ss, [1, t0, rsp], "-env.dataSize"
subi rsp, rsp, dsz
};
limm t1, imm
subi rsp, rsp, dsz
- st t1, ss, [0, t0, rsp]
+ st t1, ss, [1, t0, rsp]
};
def macroop PUSH_M {
# Make the default data size of pops 64 bits in 64 bit mode
.adjust_env oszIn64Override
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
subi rsp, rsp, dsz
- st t1, ss, [0, t0, rsp]
+ st t1, ss, [1, t0, rsp]
};
def macroop PUSH_P {
.adjust_env oszIn64Override
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
subi rsp, rsp, dsz
- st t1, ss, [0, t0, rsp]
+ st t1, ss, [1, t0, rsp]
};
def macroop PUSHA {
- st rax, ss, [0, t0, rsp], "-0 * env.dataSize"
- st rcx, ss, [0, t0, rsp], "-1 * env.dataSize"
- st rdx, ss, [0, t0, rsp], "-2 * env.dataSize"
- st rbx, ss, [0, t0, rsp], "-3 * env.dataSize"
- st rsp, ss, [0, t0, rsp], "-4 * env.dataSize"
- st rbp, ss, [0, t0, rsp], "-5 * env.dataSize"
- st rsi, ss, [0, t0, rsp], "-6 * env.dataSize"
- st rdi, ss, [0, t0, rsp], "-7 * env.dataSize"
+ st rax, ss, [1, t0, rsp], "-0 * env.dataSize"
+ st rcx, ss, [1, t0, rsp], "-1 * env.dataSize"
+ st rdx, ss, [1, t0, rsp], "-2 * env.dataSize"
+ st rbx, ss, [1, t0, rsp], "-3 * env.dataSize"
+ st rsp, ss, [1, t0, rsp], "-4 * env.dataSize"
+ st rbp, ss, [1, t0, rsp], "-5 * env.dataSize"
+ st rsi, ss, [1, t0, rsp], "-6 * env.dataSize"
+ st rdi, ss, [1, t0, rsp], "-7 * env.dataSize"
subi rsp, rsp, "8 * env.dataSize"
};
def macroop POPA {
- ld rdi, ss, [0, t0, rsp], "0 * env.dataSize"
- ld rsi, ss, [0, t0, rsp], "1 * env.dataSize"
- ld rbp, ss, [0, t0, rsp], "2 * env.dataSize"
- ld rbx, ss, [0, t0, rsp], "4 * env.dataSize"
- ld rdx, ss, [0, t0, rsp], "5 * env.dataSize"
- ld rcx, ss, [0, t0, rsp], "6 * env.dataSize"
- ld rax, ss, [0, t0, rsp], "7 * env.dataSize"
+ ld rdi, ss, [1, t0, rsp], "0 * env.dataSize"
+ ld rsi, ss, [1, t0, rsp], "1 * env.dataSize"
+ ld rbp, ss, [1, t0, rsp], "2 * env.dataSize"
+ ld rbx, ss, [1, t0, rsp], "4 * env.dataSize"
+ ld rdx, ss, [1, t0, rsp], "5 * env.dataSize"
+ ld rcx, ss, [1, t0, rsp], "6 * env.dataSize"
+ ld rax, ss, [1, t0, rsp], "7 * env.dataSize"
addi rsp, rsp, "8 * env.dataSize"
};
.adjust_env oszIn64Override
mov rsp, rsp, rbp
- ld rbp, ss, [0, t0, rsp]
+ ld rbp, ss, [1, t0, rsp]
addi rsp, rsp, dsz
};
'''
#let {{
# class ENTER(Inst):
# "GenFault ${new UnimpInstFault}"
-# class LEAVE(Inst):
-# "GenFault ${new UnimpInstFault}"
#}};
def macroop XCHG_R_M
{
- ld t1, ds, [scale, index, base], disp
- st reg, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
+ st reg, seg, sib, disp
mov reg, reg, t1
};
def macroop XCHG_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
- st reg, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
+ st reg, seg, riprel, disp
mov reg, reg, t1
};
def macroop XCHG_M_R
{
- ld t1, ds, [scale, index, base], disp
- st reg, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
+ st reg, seg, sib, disp
mov reg, reg, t1
};
def macroop XCHG_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
- st reg, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
+ st reg, seg, riprel, disp
mov reg, reg, t1
};
'''
microcode = '''
def macroop LEA_R_M {
- lea reg, ds, [scale, index, base], disp
+ lea reg, seg, sib, disp
};
def macroop LEA_R_P {
rdip t7
- lea reg, ds, [0, t0, t7], disp
+ lea reg, seg, riprel, disp
};
'''
def macroop OR_M_I
{
limm t2, imm
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop OR_P_I
{
limm t2, imm
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop OR_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop OR_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop OR_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
};
def macroop OR_R_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
};
def macroop XOR_M_I
{
limm t2, imm
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop XOR_P_I
{
limm t2, imm
rdip t7
- ld t1, ds, [1, t0, t7], disp
+ ld t1, seg, riprel, disp
xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [1, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop XOR_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop XOR_P_R
{
rdip t7
- ld t1, ds, [1, t0, t7], disp
+ ld t1, seg, riprel, disp
xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, riprel, disp
};
def macroop XOR_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
};
def macroop XOR_R_P
{
rdip t7
- ld t1, ds, [1, t0, t7], disp
+ ld t1, seg, riprel, disp
xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
};
def macroop AND_R_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
};
def macroop AND_R_P
{
rdip t7
- ld t1, ds, [1, t0, t7], disp
+ ld t1, seg, riprel, disp
and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
};
def macroop AND_M_I
{
- ld t2, ds, [scale, index, base], disp
+ ld t2, seg, sib, disp
limm t1, imm
and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
- st t2, ds, [scale, index, base], disp
+ st t2, seg, sib, disp
};
def macroop AND_P_I
{
rdip t7
- ld t2, ds, [0, t0, t7], disp
+ ld t2, seg, riprel, disp
limm t1, imm
and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
- st t2, ds, [0, t0, t7], disp
+ st t2, seg, riprel, disp
};
def macroop AND_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop AND_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop NOT_R
def macroop NOT_M
{
limm t1, -1
- ld t2, ds, [scale, index, base], disp
+ ld t2, seg, sib, disp
xor t2, t2, t1
- st t2, ds, [scale, index, base], disp
+ st t2, seg, sib, disp
};
def macroop NOT_P
{
limm t1, -1
rdip t7
- ld t2, ds, [0, t0, t7], disp
+ ld t2, seg, riprel, disp
xor t2, t2, t1
- st t2, ds, [0, t0, t7], disp
+ st t2, seg, riprel, disp
};
'''
limm rcx, 0x444d4163, dataSize=4
};
'''
-#let {{
-# class CPUID(Inst):
-# "GenFault ${new UnimpInstFault}"
-#}};
def macroop ROL_M_I
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
roli t1, t1, imm
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ROL_P_I
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
roli t1, t1, imm
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ROL_1_R
def macroop ROL_1_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
roli t1, t1, 1
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ROL_1_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
roli t1, t1, 1
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ROL_R_R
def macroop ROL_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
rol t1, t1, reg
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ROL_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
rol t1, t1, reg
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ROR_R_I
def macroop ROR_M_I
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
rori t1, t1, imm
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ROR_P_I
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
rori t1, t1, imm
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ROR_1_R
def macroop ROR_1_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
rori t1, t1, 1
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ROR_1_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
rori t1, t1, 1
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop ROR_R_R
def macroop ROR_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
ror t1, t1, reg
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop ROR_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
ror t1, t1, reg
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop RCL_R_I
def macroop RCL_M_I
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
rcli t1, t1, imm
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop RCL_P_I
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
rcli t1, t1, imm
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop RCL_1_R
def macroop RCL_1_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
rcli t1, t1, 1
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop RCL_1_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
rcli t1, t1, 1
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop RCL_R_R
def macroop RCL_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
rcl t1, t1, reg
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop RCL_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
rcl t1, t1, reg
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop RCR_R_I
def macroop RCR_M_I
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
rcri t1, t1, imm
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop RCR_P_I
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
rcri t1, t1, imm
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop RCR_1_R
def macroop RCR_1_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
rcri t1, t1, 1
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop RCR_1_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
rcri t1, t1, 1
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop RCR_R_R
def macroop RCR_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
rcr t1, t1, reg
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop RCR_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
rcr t1, t1, reg
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
'''
def macroop SAL_M_I
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
slli t1, t1, imm
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SAL_P_I
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
slli t1, t1, imm
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SAL_1_R
def macroop SAL_1_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
slli t1, t1, 1
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SAL_1_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
slli t1, t1, 1
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SAL_R_R
def macroop SAL_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sll t1, t1, reg
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SAL_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sll t1, t1, reg
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SHR_R_I
def macroop SHR_M_I
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
srli t1, t1, imm
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SHR_P_I
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
srli t1, t1, imm
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SHR_1_R
def macroop SHR_1_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
srli t1, t1, 1
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SHR_1_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
srli t1, t1, 1
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SHR_R_R
def macroop SHR_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
srl t1, t1, reg
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SHR_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
srl t1, t1, reg
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SAR_R_I
def macroop SAR_M_I
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
srai t1, t1, imm
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SAR_P_I
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
srai t1, t1, imm
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SAR_1_R
def macroop SAR_1_M
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
srai t1, t1, 1
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SAR_1_P
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
srai t1, t1, 1
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
def macroop SAR_R_R
def macroop SAR_M_R
{
- ld t1, ds, [scale, index, base], disp
+ ld t1, seg, sib, disp
sra t1, t1, reg
- st t1, ds, [scale, index, base], disp
+ st t1, seg, sib, disp
};
def macroop SAR_P_R
{
rdip t7
- ld t1, ds, [0, t0, t7], disp
+ ld t1, seg, riprel, disp
sra t1, t1, reg
- st t1, ds, [0, t0, t7], disp
+ st t1, seg, riprel, disp
};
'''
self.regUsed = False
self.regm = "0"
self.regmUsed = False
+ self.seg = "SEGMENT_REG_DS"
self.size = None
self.addressSize = "ADDRSIZE"
self.dataSize = "OPSIZE"
"regm" : "env.regm",
"imm" : "IMMEDIATE",
"disp" : "DISPLACEMENT",
+ "seg" : "env.seg",
"scale" : "env.scale",
"index" : "env.index",
"base" : "env.base",
"osz" : "env.operandSize",
"ssz" : "env.stackSize"
}
+ assembler.symbols.update(symbols)
+
+ # Short hand for common scale-index-base combinations.
+ assembler.symbols["sib"] = \
+ [symbols["scale"], symbols["index"], symbols["base"]]
+ assembler.symbols["riprel"] = \
+ ["1", assembler.symbols["t0"], assembler.symbols["t7"]]
for reg in ('ax', 'bx', 'cx', 'dx', 'sp', 'bp', 'si', 'di'):
assembler.symbols["r%s" % reg] = "INTREG_R%s" % reg.upper()
- assembler.symbols.update(symbols)
for flag in ('CF', 'PF', 'ECF', 'AF', 'EZF', 'ZF', 'SF', 'OF'):
assembler.symbols[flag] = flag + "Bit"
decoder_output = ""
exec_output = ""
- calculateEA = "EA = scale * Index + Base + disp;"
+ calculateEA = "EA = SegBase + scale * Index + Base + disp;"
def defineMicroLoadOp(mnemonic, code):
global header_output
'rax': ('IntReg', 'uqw', '(INTREG_RAX)', 'IsInteger', 7),
'RIP': ('NPC', 'uqw', None, (None, None, 'IsControl'), 10),
'ccFlagBits': ('IntReg', 'uqw', 'NUM_INTREGS + NumMicroIntRegs', None, 20),
+ 'SegBase': ('ControlReg', 'uqw', 'MISCREG_SEG_BASE_BASE + segment', (None, None, ['IsSerializeAfter','IsSerializing','IsNonSpeculative']), 50),
'Mem': ('Mem', 'uqw', None, ('IsMemRef', 'IsLoad', 'IsStore'), 100)
}};
MiscReg MiscRegFile::readReg(int miscReg, ThreadContext * tc)
{
- warn("No miscreg effects implemented yet!\n");
return readRegNoEffect(miscReg);
}
void MiscRegFile::setReg(int miscReg,
const MiscReg &val, ThreadContext * tc)
{
- warn("No miscreg effects implemented yet!\n");
setRegNoEffect(miscReg, val);
}
#include "arch/x86/isa_traits.hh"
#include "arch/x86/process.hh"
+#include "arch/x86/segmentregs.hh"
#include "arch/x86/types.hh"
#include "base/loader/object_file.hh"
#include "base/loader/elf_object.hh"
X86LiveProcess::startup()
{
argsInit(sizeof(IntReg), VMPageSize);
-
- //The AMD64 abi says that only rsp and rdx are defined at process
- //startup. rsp will be set by argsInit, and I don't understand what
- //rdx should be set to. The other floating point and integer registers
- //will be zeroed by the register file constructors, but control registers
- //should be initialized here. Since none of those are implemented, there
- //isn't anything here.
+ for(int i = 0; i < NUM_SEGMENTREGS; i++)
+ threadContexts[0]->setMiscRegNoEffect(MISCREG_ES_BASE + i, 0);
}
void
enum Prefixes {
NoOverride,
+ ESOverride,
CSOverride,
+ SSOverride,
DSOverride,
- ESOverride,
FSOverride,
GSOverride,
- SSOverride,
RexPrefix,
OperandSizeOverride,
AddressSizeOverride,