⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 translate-copy.c

📁 qemu虚拟机代码
💻 C
📖 第 1 页 / 共 3 页
字号:
            break;        case 5: /* imul */            break;        case 6: /* div */            break;        case 7: /* idiv */            break;        default:            goto illegal_op;        }        break;    case 0xfe: /* GRP4 */    case 0xff: /* GRP5 */        if ((b & 1) == 0)            ot = OT_BYTE;        else            ot = dflag ? OT_LONG : OT_WORD;        modrm = ldub_code(s->pc++);        mod = (modrm >> 6) & 3;        op = (modrm >> 3) & 7;        if (op >= 2 && b == 0xfe) {            goto illegal_op;        }        pc_tmp = s->pc;        parse_modrm(s, modrm);        switch(op) {        case 0: /* inc Ev */            break;        case 1: /* dec Ev */            break;        case 2: /* call Ev */            /* XXX: optimize and handle MEM exceptions specifically               fs movl %eax, regs[0]                movl Ev, %eax                pushl next_eip               fs movl %eax, eip            */            goto unsupported_op;        case 3: /* lcall Ev */            goto unsupported_op;        case 4: /* jmp Ev */            /* XXX: optimize and handle MEM exceptions specifically               fs movl %eax, regs[0]                movl Ev, %eax                fs movl %eax, eip            */            goto unsupported_op;        case 5: /* ljmp Ev */            goto unsupported_op;        case 6: /* push Ev */            break;        default:            goto illegal_op;        }        break;    case 0xa8: /* test eAX, Iv */    case 0xa9:        if ((b & 1) == 0)            ot = OT_BYTE;        else            ot = dflag ? OT_LONG : OT_WORD;        insn_get(s, ot);        break;            case 0x98: /* CWDE/CBW */        break;    case 0x99: /* CDQ/CWD */        break;    case 0x1af: /* imul Gv, Ev */    case 0x69: /* imul Gv, Ev, I */    case 0x6b:        ot = dflag ? OT_LONG : OT_WORD;        modrm = ldub_code(s->pc++);        parse_modrm(s, modrm);        if (b == 0x69) {            insn_get(s, ot);        } else if (b == 0x6b) {            insn_get(s, OT_BYTE);        } else {        }        break;    case 0x84: /* test Ev, Gv */    case 0x85:             case 0x1c0:    case 0x1c1: /* xadd Ev, Gv */    case 0x1b0:    case 0x1b1: /* cmpxchg Ev, Gv */    case 0x8f: /* pop Ev */    case 0x88:    case 0x89: /* mov Gv, Ev */    case 0x8a:    case 0x8b: /* mov Ev, Gv */    case 0x1b6: /* movzbS Gv, Eb */    case 0x1b7: /* movzwS Gv, Eb */    case 0x1be: /* movsbS Gv, Eb */    case 0x1bf: /* movswS Gv, Eb */    case 0x86:    case 0x87: /* xchg Ev, Gv */    case 0xd0:    case 0xd1: /* shift Ev,1 */    case 0xd2:    case 0xd3: /* shift Ev,cl */    case 0x1a5: /* shld cl */    case 0x1ad: /* shrd cl */    case 0x190 ... 0x19f: /* setcc Gv */    /* XXX: emulate cmov if not available ? */    case 0x140 ... 0x14f: /* cmov Gv, Ev */    case 0x1a3: /* bt Gv, Ev */    case 0x1ab: /* bts */    case 0x1b3: /* btr */    case 0x1bb: /* btc */    case 0x1bc: /* bsf */    case 0x1bd: /* bsr */        modrm = ldub_code(s->pc++);        parse_modrm(s, modrm);        break;    case 0x1c7: /* cmpxchg8b */        modrm = ldub_code(s->pc++);        mod = (modrm >> 6) & 3;        if (mod == 3)            goto illegal_op;        parse_modrm(s, modrm);        break;                /**************************/        /* push/pop */    case 0x50 ... 0x57: /* push */    case 0x58 ... 0x5f: /* pop */    case 0x60: /* pusha */    case 0x61: /* popa */        break;    case 0x68: /* push Iv */    case 0x6a:        ot = dflag ? OT_LONG : OT_WORD;        if (b == 0x68)            insn_get(s, ot);        else            insn_get(s, OT_BYTE);        break;    case 0xc8: /* enter */        lduw_code(s->pc);        s->pc += 2;        ldub_code(s->pc++);        break;    case 0xc9: /* leave */        break;    case 0x06: /* push es */    case 0x0e: /* push cs */    case 0x16: /* push ss */    case 0x1e: /* push ds */        /* XXX: optimize:         push segs[n].selector        */        goto unsupported_op;    case 0x1a0: /* push fs */    case 0x1a8: /* push gs */        goto unsupported_op;    case 0x07: /* pop es */    case 0x17: /* pop ss */    case 0x1f: /* pop ds */        goto unsupported_op;    case 0x1a1: /* pop fs */    case 0x1a9: /* pop gs */        goto unsupported_op;    case 0x8e: /* mov seg, Gv */        /* XXX: optimize:           fs movl r, regs[]           movl segs[].selector, r           mov r, Gv           fs movl regs[], r        */        goto unsupported_op;    case 0x8c: /* mov Gv, seg */        goto unsupported_op;    case 0xc4: /* les Gv */        op = R_ES;        goto do_lxx;    case 0xc5: /* lds Gv */        op = R_DS;        goto do_lxx;    case 0x1b2: /* lss Gv */        op = R_SS;        goto do_lxx;    case 0x1b4: /* lfs Gv */        op = R_FS;        goto do_lxx;    case 0x1b5: /* lgs Gv */        op = R_GS;    do_lxx:        goto unsupported_op;        /************************/        /* floats */    case 0xd8 ... 0xdf: #if 1        /* currently not stable enough */        goto unsupported_op;#else        if (s->flags & (HF_EM_MASK | HF_TS_MASK))            goto unsupported_op;#endif#if 0        /* for testing FPU context switch */        {            static int count;            count = (count + 1) % 3;            if (count != 0)                goto unsupported_op;        }#endif        modrm = ldub_code(s->pc++);        mod = (modrm >> 6) & 3;        rm = modrm & 7;        op = ((b & 7) << 3) | ((modrm >> 3) & 7);        if (mod != 3) {            /* memory op */            parse_modrm(s, modrm);            switch(op) {            case 0x00 ... 0x07: /* fxxxs */            case 0x10 ... 0x17: /* fixxxl */            case 0x20 ... 0x27: /* fxxxl */            case 0x30 ... 0x37: /* fixxx */                break;            case 0x08: /* flds */            case 0x0a: /* fsts */            case 0x0b: /* fstps */            case 0x18: /* fildl */            case 0x1a: /* fistl */            case 0x1b: /* fistpl */            case 0x28: /* fldl */            case 0x2a: /* fstl */            case 0x2b: /* fstpl */            case 0x38: /* filds */            case 0x3a: /* fists */            case 0x3b: /* fistps */            case 0x0c: /* fldenv mem */            case 0x0d: /* fldcw mem */            case 0x0e: /* fnstenv mem */            case 0x0f: /* fnstcw mem */            case 0x1d: /* fldt mem */            case 0x1f: /* fstpt mem */            case 0x2c: /* frstor mem */            case 0x2e: /* fnsave mem */            case 0x2f: /* fnstsw mem */            case 0x3c: /* fbld */            case 0x3e: /* fbstp */            case 0x3d: /* fildll */            case 0x3f: /* fistpll */                break;            default:                goto illegal_op;            }        } else {            /* register float ops */            switch(op) {            case 0x08: /* fld sti */            case 0x09: /* fxchg sti */                break;            case 0x0a: /* grp d9/2 */                switch(rm) {                case 0: /* fnop */                    break;                default:                    goto illegal_op;                }                break;            case 0x0c: /* grp d9/4 */                switch(rm) {                case 0: /* fchs */                case 1: /* fabs */                case 4: /* ftst */                case 5: /* fxam */                    break;                default:                    goto illegal_op;                }                break;            case 0x0d: /* grp d9/5 */                switch(rm) {                case 0:                case 1:                case 2:                case 3:                case 4:                case 5:                case 6:                    break;                default:                    goto illegal_op;                }                break;            case 0x0e: /* grp d9/6 */                break;            case 0x0f: /* grp d9/7 */                break;            case 0x00: case 0x01: case 0x04 ... 0x07: /* fxxx st, sti */            case 0x20: case 0x21: case 0x24 ... 0x27: /* fxxx sti, st */            case 0x30: case 0x31: case 0x34 ... 0x37: /* fxxxp sti, st */                break;            case 0x02: /* fcom */                break;            case 0x03: /* fcomp */                break;            case 0x15: /* da/5 */                switch(rm) {                case 1: /* fucompp */                    break;                default:                    goto illegal_op;                }                break;            case 0x1c:                switch(rm) {                case 0: /* feni (287 only, just do nop here) */                case 1: /* fdisi (287 only, just do nop here) */                    goto unsupported_op;                case 2: /* fclex */                case 3: /* fninit */                case 4: /* fsetpm (287 only, just do nop here) */                    break;                default:                    goto illegal_op;                }                break;            case 0x1d: /* fucomi */                break;            case 0x1e: /* fcomi */                break;            case 0x28: /* ffree sti */                break;            case 0x2a: /* fst sti */                break;            case 0x2b: /* fstp sti */                break;            case 0x2c: /* fucom st(i) */                break;            case 0x2d: /* fucomp st(i) */                break;            case 0x33: /* de/3 */                switch(rm) {                case 1: /* fcompp */                    break;                default:                    goto illegal_op;                }                break;            case 0x3c: /* df/4 */                switch(rm) {                case 0:                    break;                default:                    goto illegal_op;                }                break;            case 0x3d: /* fucomip */                break;            case 0x3e: /* fcomip */                break;            case 0x10 ... 0x13: /* fcmovxx */            case 0x18 ... 0x1b:                break;            default:                goto illegal_op;            }        }        s->tb->cflags |= CF_TB_FP_USED;        break;        /**************************/        /* mov */    case 0xc6:    case 0xc7: /* mov Ev, Iv */        if ((b & 1) == 0)            ot = OT_BYTE;        else            ot = dflag ? OT_LONG : OT_WORD;        modrm = ldub_code(s->pc++);        parse_modrm(s, modrm);        insn_get(s, ot);        break;    case 0x8d: /* lea */        ot = dflag ? OT_LONG : OT_WORD;        modrm = ldub_code(s->pc++);        mod = (modrm >> 6) & 3;        if (mod == 3)            goto illegal_op;        parse_modrm(s, modrm);        break;            case 0xa0: /* mov EAX, Ov */    case 0xa1:    case 0xa2: /* mov Ov, EAX */    case 0xa3:        if ((b & 1) == 0)            ot = OT_BYTE;        else            ot = dflag ? OT_LONG : OT_WORD;        if (s->aflag)            insn_get(s, OT_LONG);        else            insn_get(s, OT_WORD);        break;    case 0xd7: /* xlat */        break;    case 0xb0 ... 0xb7: /* mov R, Ib */        insn_get(s, OT_BYTE);        break;    case 0xb8 ... 0xbf: /* mov R, Iv */        ot = dflag ? OT_LONG : OT_WORD;        insn_get(s, ot);        break;    case 0x91 ... 0x97: /* xchg R, EAX */        break;        /************************/        /* shifts */    case 0xc0:    case 0xc1: /* shift Ev,imm */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -