Implement some more opcodes, syscall, sysret, lfence, mfence, sfence.
Unified · Split
| @@ -893,6 +893,15 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode) · 892 unmodified lines | ||
| 893 | 893 | |
| 894 | 894 | pc = 0; |
| 895 | 895 | if (pa->instr_type & OPC_MODRM) { |
| 896 | + if (!nb_ops) { | |
| 897 | + /* A modrm opcode without operands is a special case (e.g. mfence). | |
| 898 | + It has a group and acts as if there's an register operand 0 | |
| 899 | + (ax). */ | |
| 900 | + i = 0; | |
| 901 | + ops[i].type = OP_REG; | |
| 902 | + ops[i].reg = 0; | |
| 903 | + goto modrm_found; | |
| 904 | + } | |
| 896 | 905 | /* first look for an ea operand */ |
| 897 | 906 | for(i = 0;i < nb_ops; i++) { |
| 898 | 907 | if (op_type[i] & OP_EA) |
| @@ -607,6 +607,13 @@ int $0x10 · 606 unmodified lines | ||
| 607 | 607 | rdmsr |
| 608 | 608 | rdpmc |
| 609 | 609 | ud2 |
| 610 | +#ifdef __x86_64__ | |
| 611 | + syscall | |
| 612 | + sysret | |
| 613 | + lfence | |
| 614 | + mfence | |
| 615 | + sfence | |
| 616 | +#endif | |
| 610 | 617 | |
| 611 | 618 | emms |
| 612 | 619 | movd %edx, %mm3 |
| @@ -88,6 +88,9 @@ ALT(DEF_ASM_OP2(btcw, 0x0fba, 7, OPC_MODRM | OPC_WLX, OPT_IM8, OPT_REGW | OPT_EA · 87 unmodified lines | ||
| 88 | 88 | DEF_ASM_OP0(rdtsc, 0x0f31) |
| 89 | 89 | DEF_ASM_OP0(rdmsr, 0x0f32) |
| 90 | 90 | DEF_ASM_OP0(rdpmc, 0x0f33) |
| 91 | + | |
| 92 | + DEF_ASM_OP0(syscall, 0x0f05) | |
| 93 | + DEF_ASM_OP0(sysret, 0x0f07) | |
| 91 | 94 | DEF_ASM_OP0(ud2, 0x0f0b) |
| 92 | 95 | |
| 93 | 96 | /* NOTE: we took the same order as gas opcode definition order */ |
| @@ -482,6 +485,9 @@ ALT(DEF_ASM_OP2(movhps, 0x0f17, 0, OPC_MODRM, OPT_SSE, OPT_EA | OPT_REG32 )) · 388 unmodified lines | ||
| 482 | 485 | DEF_ASM_OP2(sqrtps, 0x0f51, 0, OPC_MODRM, OPT_EA | OPT_SSE, OPT_SSE ) |
| 483 | 486 | DEF_ASM_OP2(subps, 0x0f5c, 0, OPC_MODRM, OPT_EA | OPT_SSE, OPT_SSE ) |
| 484 | 487 | |
| 488 | + DEF_ASM_OP0L(lfence, 0x0fae, 5, OPC_MODRM) | |
| 489 | + DEF_ASM_OP0L(mfence, 0x0fae, 6, OPC_MODRM) | |
| 490 | + DEF_ASM_OP0L(sfence, 0x0fae, 7, OPC_MODRM) | |
| 485 | 491 | #undef ALT |
| 486 | 492 | #undef DEF_ASM_OP0 |
| 487 | 493 | #undef DEF_ASM_OP0L |