• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ emitModRM函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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);
}
开发者ID:kod3r,项目名称:pyston,代码行数:27,代码来源:assembler.cpp


示例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);
    }
}
开发者ID:c-rhodes,项目名称:pyston,代码行数:28,代码来源:assembler.cpp


示例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);
    }
}
开发者ID:c-rhodes,项目名称:pyston,代码行数:28,代码来源:assembler.cpp


示例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);
    }
}
开发者ID:kod3r,项目名称:pyston,代码行数:26,代码来源:assembler.cpp


示例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);
    }
}
开发者ID:jmgc,项目名称:pyston,代码行数:33,代码来源:assembler.cpp


示例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);
    }
}
开发者ID:jmgc,项目名称:pyston,代码行数:34,代码来源:assembler.cpp


示例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);
}
开发者ID:c-rhodes,项目名称:pyston,代码行数:10,代码来源:assembler.cpp


示例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);
}
开发者ID:jmgc,项目名称:pyston,代码行数:13,代码来源:assembler.cpp


示例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);
    }
}
开发者ID:kod3r,项目名称:pyston,代码行数:43,代码来源:assembler.cpp


示例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);
}
开发者ID:kod3r,项目名称:pyston,代码行数:23,代码来源:assembler.cpp


示例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);
    }
}
开发者ID:jmgc,项目名称:pyston,代码行数:95,代码来源:assembler.cpp



注:本文中的emitModRM函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ emitNakedCall函数代码示例发布时间:2022-05-30
下一篇:
C++ emitLoad函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap