Skip to content

Commit

Permalink
Merge branch 'mob'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Oct 28, 2024
2 parents 4b4c806 + a21b5f1 commit f6e86d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions i386-asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,15 +1002,21 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
modrm_index = -1;
modreg_index = -1;
if (pa->instr_type & OPC_MODRM) {
#ifdef TCC_TARGET_X86_64
if (!nb_ops) {
/* A modrm opcode without operands is a special case (e.g. mfence).
It has a group and acts as if there's an register operand 0
(ax). */
It has a group and acts as if there's an register operand 0 */
i = 0;
ops[i].type = OP_REG;
ops[i].reg = 0;
if (pa->sym == TOK_ASM_endbr64)
ops[i].reg = 2; // dx
else if (pa->sym >= TOK_ASM_lfence && pa->sym <= TOK_ASM_sfence)
ops[i].reg = 0; // ax
else
tcc_error("bad MODR/M opcode without operands");
goto modrm_found;
}
#endif
/* first look for an ea operand */
for(i = 0;i < nb_ops; i++) {
if (op_type[i] & OP_EA)
Expand Down
5 changes: 5 additions & 0 deletions x86_64-asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ ALT(DEF_ASM_OP2(shrdw, 0x0fad, 0, OPC_MODRM | OPC_WLX, OPT_REGW, OPT_EA | OPT_RE

ALT(DEF_ASM_OP1(call, 0xff, 2, OPC_MODRM, OPT_INDIR))
ALT(DEF_ASM_OP1(call, 0xe8, 0, 0, OPT_DISP))
DEF_ASM_OP1(callq, 0xff, 2, OPC_MODRM, OPT_INDIR)
ALT(DEF_ASM_OP1(callq, 0xe8, 0, 0, OPT_DISP))
ALT(DEF_ASM_OP1(jmp, 0xff, 4, OPC_MODRM, OPT_INDIR))
ALT(DEF_ASM_OP1(jmp, 0xeb, 0, 0, OPT_DISP8))

Expand Down Expand Up @@ -536,6 +538,9 @@ ALT(DEF_ASM_OP2(movhps, 0x0f17, 0, OPC_MODRM, OPT_SSE, OPT_EA | OPT_REG32 ))
DEF_ASM_OP0L(mfence, 0x0fae, 6, OPC_MODRM)
DEF_ASM_OP0L(sfence, 0x0fae, 7, OPC_MODRM)
DEF_ASM_OP1(clflush, 0x0fae, 7, OPC_MODRM, OPT_EA)

/* Control-Flow Enforcement */
DEF_ASM_OP0L(endbr64, 0xf30f1e, 7, OPC_MODRM)
#undef ALT
#undef DEF_ASM_OP0
#undef DEF_ASM_OP0L
Expand Down

0 comments on commit f6e86d9

Please sign in to comment.