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
893893
894894 pc = 0;
895895 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+ }
896905 /* first look for an ea operand */
897906 for(i = 0;i < nb_ops; i++) {
898907 if (op_type[i] & OP_EA)
tests/asmtest.S+7−0
@@ -607,6 +607,13 @@ int $0x10 · 606 unmodified lines
607607 rdmsr
608608 rdpmc
609609 ud2
610+#ifdef __x86_64__
611+ syscall
612+ sysret
613+ lfence
614+ mfence
615+ sfence
616+#endif
610617
611618 emms
612619 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
8888 DEF_ASM_OP0(rdtsc, 0x0f31)
8989 DEF_ASM_OP0(rdmsr, 0x0f32)
9090 DEF_ASM_OP0(rdpmc, 0x0f33)
91+
92+ DEF_ASM_OP0(syscall, 0x0f05)
93+ DEF_ASM_OP0(sysret, 0x0f07)
9194 DEF_ASM_OP0(ud2, 0x0f0b)
9295
9396 /* 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
482485 DEF_ASM_OP2(sqrtps, 0x0f51, 0, OPC_MODRM, OPT_EA | OPT_SSE, OPT_SSE )
483486 DEF_ASM_OP2(subps, 0x0f5c, 0, OPC_MODRM, OPT_EA | OPT_SSE, OPT_SSE )
484487
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)
485491 #undef ALT
486492 #undef DEF_ASM_OP0
487493 #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