History

Detect correct instruction with incorrect operands

Display a different warning when an instruction is recognized by tcc but the operands found do not correspond to the constraints of the instruction.

Thomas Preud'homme committed 13 years ago

Commit a1a691a1 parent 45b35a33 files · +6 −2Browse files

Unified · Split

3 files
  1. i386-asm.c +4 −0
  2. i386-asm.h +1 −1
  3. x86_64-asm.h +1 −1
i386-asm.c+4−0
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727
2828 #define TOK_ASM_first TOK_ASM_clc
2929 #define TOK_ASM_last TOK_ASM_emms
30+#define TOK_ASM_alllast TOK_ASM_pxor
3031
3132 #define OPC_JMP 0x01 /* jmp operand */
3233 #define OPC_B 0x02 /* only used with OPC_WL */
@@ -715,6 +716,9 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode) · 682 unmodified lines
715716 g(b >> 8);
716717 g(b);
717718 return;
719+ } else if (opcode <= TOK_ASM_alllast) {
720+ tcc_error("bad operand with opcode '%s'",
721+ get_tok_str(opcode, NULL));
718722 } else {
719723 tcc_error("unknown opcode '%s'",
720724 get_tok_str(opcode, NULL));
i386-asm.h+1−1
@@ -463,7 +463,7 @@ ALT(DEF_ASM_OP2(psrlq, 0x0f73, 2, OPC_MODRM, OPT_IM8, OPT_MMX )) · 462 unmodified lines
463463 DEF_ASM_OP2(punpcklbw, 0x0f60, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
464464 DEF_ASM_OP2(punpcklwd, 0x0f61, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
465465 DEF_ASM_OP2(punpckldq, 0x0f62, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
466− DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
466+ DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX ) /* must be last !OP0 */
467467
468468 #undef ALT
469469 #undef DEF_ASM_OP0
x86_64-asm.h+1−1
@@ -438,7 +438,7 @@ ALT(DEF_ASM_OP2(psrlq, 0x0f73, 2, OPC_MODRM, OPT_IM8, OPT_MMX )) · 437 unmodified lines
438438 DEF_ASM_OP2(punpcklbw, 0x0f60, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
439439 DEF_ASM_OP2(punpcklwd, 0x0f61, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
440440 DEF_ASM_OP2(punpckldq, 0x0f62, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
441− DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
441+ DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX ) /* must be last !OP0 */
442442
443443 #undef ALT
444444 #undef DEF_ASM_OP0

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