本文整理汇总了C++中emitModRM函数的典型用法代码示例。如果您正苦于以下问题:C++ emitModRM函数的具体用法?C++ emitModRM怎么用?C++ emitModRM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了emitModRM函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void Assembler::cmp(Indirect mem, Immediate imm) {
int64_t val = imm.val;
assert((-1L << 31) <= val && val < (1L << 31) - 1);
int src_idx = mem.base.regnum;
int rex = REX_W;
if (src_idx >= 8) {
rex |= REX_B;
src_idx -= 8;
}
assert(src_idx >= 0 && src_idx < 8);
emitRex(rex);
emitByte(0x81);
assert(-0x80 <= mem.offset && mem.offset < 0x80);
if (mem.offset == 0) {
emitModRM(0b00, 7, src_idx);
} else {
emitModRM(0b01, 7, src_idx);
emitByte(mem.offset);
}
emitInt(val, 4);
}
示例2: RELEASE_ASSERT
void Assembler::emitArith(Immediate imm, Register r, int opcode, MovType type) {
// assert(r != RSP && "This breaks unwinding, please don't use.");
int64_t amount = imm.val;
RELEASE_ASSERT(fitsInto<int32_t>(amount), "");
assert(0 <= opcode && opcode < 8);
assert(type == MovType::Q || type == MovType::L);
int rex = type == MovType::Q ? REX_W : 0;
int reg_idx = r.regnum;
if (reg_idx >= 8) {
rex |= REX_B;
reg_idx -= 8;
}
if (rex)
emitRex(rex);
if (-0x80 <= amount && amount < 0x80) {
emitByte(0x83);
emitModRM(0b11, opcode, reg_idx);
emitByte(amount);
} else {
emitByte(0x81);
emitModRM(0b11, opcode, reg_idx);
emitInt(amount, 4);
}
}
示例3: assert
void Assembler::incq(Indirect mem) {
int src_idx = mem.base.regnum;
int rex = REX_W;
if (src_idx >= 8) {
rex |= REX_B;
src_idx -= 8;
}
assert(src_idx >= 0 && src_idx < 8);
bool needssib = (src_idx == 0b100);
if (rex)
emitRex(rex);
emitByte(0xff);
assert(-0x80 <= mem.offset && mem.offset < 0x80);
if (mem.offset == 0) {
emitModRM(0b00, 0, src_idx);
if (needssib)
emitSIB(0b00, 0b100, src_idx);
} else {
emitModRM(0b01, 0, src_idx);
if (needssib)
emitSIB(0b00, 0b100, src_idx);
emitByte(mem.offset);
}
}
示例4: RELEASE_ASSERT
void Assembler::emitArith(Immediate imm, Register r, int opcode) {
// assert(r != RSP && "This breaks unwinding, please don't use.");
int64_t amount = imm.val;
RELEASE_ASSERT((-1L << 31) <= amount && amount < (1L << 31) - 1, "");
assert(0 <= opcode && opcode < 8);
int rex = REX_W;
int reg_idx = r.regnum;
if (reg_idx >= 8) {
rex |= REX_B;
reg_idx -= 8;
}
emitRex(rex);
if (-0x80 <= amount && amount < 0x80) {
emitByte(0x83);
emitModRM(0b11, opcode, reg_idx);
emitByte(amount);
} else {
emitByte(0x81);
emitModRM(0b11, opcode, reg_idx);
emitInt(amount, 4);
}
}
示例5: assert
void Assembler::mov(Register src, Indirect dest) {
int rex = REX_W;
int src_idx = src.regnum;
int dest_idx = dest.base.regnum;
assert(src_idx != dest_idx && "while valid this is almost certainly a register allocator bug");
if (src_idx >= 8) {
rex |= REX_R;
src_idx -= 8;
}
if (dest_idx >= 8) {
rex |= REX_B;
dest_idx -= 8;
}
emitRex(rex);
emitByte(0x89);
bool needssib = (dest_idx == 0b100);
int mode = getModeFromOffset(dest.offset);
emitModRM(mode, src_idx, dest_idx);
if (needssib)
emitSIB(0b00, 0b100, dest_idx);
if (mode == 0b01) {
emitByte(dest.offset);
} else if (mode == 0b10) {
emitInt(dest.offset, 4);
}
}
示例6: trap
void Assembler::movsd(XMMRegister src, Indirect dest) {
int rex = 0;
int src_idx = src.regnum;
int dest_idx = dest.base.regnum;
if (src_idx >= 8) {
rex |= REX_R;
src_idx -= 8;
}
if (dest_idx >= 8) {
trap();
rex |= REX_B;
dest_idx -= 8;
}
emitByte(0xf2);
if (rex)
emitRex(rex);
emitByte(0x0f);
emitByte(0x11);
bool needssib = (dest_idx == 0b100);
int mode = getModeFromOffset(dest.offset);
emitModRM(mode, src_idx, dest_idx);
if (needssib)
emitSIB(0b00, 0b100, dest_idx);
if (mode == 0b01) {
emitByte(dest.offset);
} else if (mode == 0b10) {
emitInt(dest.offset, 4);
}
}
示例7: emitRex
void Assembler::clear_reg(Register reg) {
int reg_idx = reg.regnum;
// we don't need to generate a REX_W because 32bit instructions will clear the upper 32bits.
if (reg_idx >= 8) {
emitRex(REX_R | REX_B);
reg_idx -= 8;
}
emitByte(0x31);
emitModRM(0b11, reg_idx, reg_idx);
}
示例8: emitRex
void Assembler::jmpq(Register dest) {
int reg_idx = dest.regnum;
if (reg_idx >= 8) {
emitRex(REX_B);
reg_idx -= 8;
}
assert(0 <= reg_idx && reg_idx < 8);
emitByte(0xff);
emitModRM(0b11, 0b100, reg_idx);
}
示例9: trap
void Assembler::movsd(Indirect src, XMMRegister dest) {
int rex = 0;
int src_idx = src.base.regnum;
int dest_idx = dest.regnum;
if (src_idx >= 8) {
trap();
rex |= REX_R;
src_idx -= 8;
}
if (dest_idx >= 8) {
trap();
rex |= REX_B;
dest_idx -= 8;
}
emitByte(0xf2);
if (rex)
emitRex(rex);
emitByte(0x0f);
emitByte(0x10);
bool needssib = (src_idx == 0b100);
int mode;
if (src.offset == 0)
mode = 0b00;
else if (-0x80 <= src.offset && src.offset < 0x80)
mode = 0b01;
else
mode = 0b10;
emitModRM(mode, dest_idx, src_idx);
if (needssib)
emitSIB(0b00, 0b100, src_idx);
if (mode == 0b01) {
emitByte(src.offset);
} else if (mode == 0b10) {
emitInt(src.offset, 4);
}
}
示例10: ASSERT
void Assembler::mov(Register src, Register dest) {
ASSERT(src != dest, "probably better to avoid calling this?");
int src_idx = src.regnum;
int dest_idx = dest.regnum;
uint8_t rex = REX_W;
if (dest_idx >= 8) {
rex |= REX_B;
dest_idx -= 8;
}
if (src_idx >= 8) {
rex |= REX_R;
src_idx -= 8;
}
assert(0 <= src_idx && src_idx < 8);
assert(0 <= dest_idx && dest_idx < 8);
emitRex(rex);
emitByte(0x89);
emitModRM(0b11, src_idx, dest_idx);
}
示例11: switch
void Assembler::mov_generic(Indirect src, Register dest, MovType type) {
int rex;
switch (type) {
case MovType::Q:
case MovType::ZBQ:
case MovType::SBQ:
case MovType::ZWQ:
case MovType::SWQ:
case MovType::SLQ:
rex = REX_W;
break;
case MovType::L:
case MovType::B:
case MovType::ZBL:
case MovType::SBL:
case MovType::ZWL:
case MovType::SWL:
rex = 0;
break;
default:
RELEASE_ASSERT(false, "unrecognized MovType");
}
int src_idx = src.base.regnum;
int dest_idx = dest.regnum;
if (src_idx >= 8) {
rex |= REX_B;
src_idx -= 8;
}
if (dest_idx >= 8) {
rex |= REX_R;
dest_idx -= 8;
}
if (rex)
emitRex(rex);
// opcode
switch (type) {
case MovType::Q:
case MovType::L:
emitByte(0x8b);
break;
case MovType::B:
emitByte(0x8a);
break;
case MovType::ZBQ:
case MovType::ZBL:
emitByte(0x0f);
emitByte(0xb6);
break;
case MovType::SBQ:
case MovType::SBL:
emitByte(0x0f);
emitByte(0xbe);
break;
case MovType::ZWQ:
case MovType::ZWL:
emitByte(0x0f);
emitByte(0xb7);
break;
case MovType::SWQ:
case MovType::SWL:
emitByte(0x0f);
emitByte(0xbf);
break;
case MovType::SLQ:
emitByte(0x63);
break;
default:
RELEASE_ASSERT(false, "unrecognized MovType");
}
bool needssib = (src_idx == 0b100);
int mode;
if (src.offset == 0)
mode = 0b00;
else if (-0x80 <= src.offset && src.offset < 0x80)
mode = 0b01;
else
mode = 0b10;
emitModRM(mode, dest_idx, src_idx);
if (needssib)
emitSIB(0b00, 0b100, src_idx);
if (mode == 0b01) {
emitByte(src.offset);
} else if (mode == 0b10) {
emitInt(src.offset, 4);
}
}