History

x86-64-asm: More opcodes

Implement some more opcodes, syscall, sysret, lfence, mfence, sfence.

Michael Matz committed 10 years ago

Commit 92047411 parent 1a5eacb3 files · +22 −0Browse files

Unified · Split

3 files
  1. i386-asm.c +9 −0
  2. tests/asmtest.S +7 −0
  3. x86_64-asm.h +6 −0
i386-asm.c+9−0
@@ -893,6 +893,15 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode) · 892 unmodified lines
893 893
894 pc = 0;894 pc = 0;
895 if (pa->instr_type & OPC_MODRM) {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 /* first look for an ea operand */905 /* first look for an ea operand */
897 for(i = 0;i < nb_ops; i++) {906 for(i = 0;i < nb_ops; i++) {
898 if (op_type[i] & OP_EA)907 if (op_type[i] & OP_EA)
tests/asmtest.S+7−0
@@ -607,6 +607,13 @@ int $0x10 · 606 unmodified lines
607 rdmsr607 rdmsr
608 rdpmc608 rdpmc
609 ud2609 ud2
610#ifdef __x86_64__
611 syscall
612 sysret
613 lfence
614 mfence
615 sfence
616#endif
610 617
611 emms618 emms
612 movd %edx, %mm3619 movd %edx, %mm3
x86_64-asm.h+6−0
@@ -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 DEF_ASM_OP0(rdtsc, 0x0f31)88 DEF_ASM_OP0(rdtsc, 0x0f31)
89 DEF_ASM_OP0(rdmsr, 0x0f32)89 DEF_ASM_OP0(rdmsr, 0x0f32)
90 DEF_ASM_OP0(rdpmc, 0x0f33)90 DEF_ASM_OP0(rdpmc, 0x0f33)
91
92 DEF_ASM_OP0(syscall, 0x0f05)
93 DEF_ASM_OP0(sysret, 0x0f07)
91 DEF_ASM_OP0(ud2, 0x0f0b)94 DEF_ASM_OP0(ud2, 0x0f0b)
92 95
93 /* NOTE: we took the same order as gas opcode definition order */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 DEF_ASM_OP2(sqrtps, 0x0f51, 0, OPC_MODRM, OPT_EA | OPT_SSE, OPT_SSE )485 DEF_ASM_OP2(sqrtps, 0x0f51, 0, OPC_MODRM, OPT_EA | OPT_SSE, OPT_SSE )
483 DEF_ASM_OP2(subps, 0x0f5c, 0, OPC_MODRM, OPT_EA | OPT_SSE, OPT_SSE )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#undef ALT491#undef ALT
486#undef DEF_ASM_OP0492#undef DEF_ASM_OP0
487#undef DEF_ASM_OP0L493#undef DEF_ASM_OP0L

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t