aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2013-09-24 15:32:52 +0200
committerThomas Preud'homme <robotux@celest.fr>2013-09-24 15:37:11 +0200
commita1a691a030d065bf234f8a476e3b958e43b1b7c5 (patch)
tree6c6eb3082e03cd6247e3c036a18d0c4b9fd233f5
parent45b35a3d66ee95e2526bf609cc88c4b4b21ac175 (diff)
downloadtinycc-a1a691a030d065bf234f8a476e3b958e43b1b7c5.tar.gz
tinycc-a1a691a030d065bf234f8a476e3b958e43b1b7c5.tar.bz2
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.
-rw-r--r--i386-asm.c4
-rw-r--r--i386-asm.h2
-rw-r--r--x86_64-asm.h2
3 files changed, 6 insertions, 2 deletions
diff --git a/i386-asm.c b/i386-asm.c
index f9c0fa7..8473d06 100644
--- a/i386-asm.c
+++ b/i386-asm.c
@@ -27,6 +27,7 @@
#define TOK_ASM_first TOK_ASM_clc
#define TOK_ASM_last TOK_ASM_emms
+#define TOK_ASM_alllast TOK_ASM_pxor
#define OPC_JMP 0x01 /* jmp operand */
#define OPC_B 0x02 /* only used with OPC_WL */
@@ -715,6 +716,9 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
g(b >> 8);
g(b);
return;
+ } else if (opcode <= TOK_ASM_alllast) {
+ tcc_error("bad operand with opcode '%s'",
+ get_tok_str(opcode, NULL));
} else {
tcc_error("unknown opcode '%s'",
get_tok_str(opcode, NULL));
diff --git a/i386-asm.h b/i386-asm.h
index 760c06d..a954afb 100644
--- a/i386-asm.h
+++ b/i386-asm.h
@@ -463,7 +463,7 @@ ALT(DEF_ASM_OP2(psrlq, 0x0f73, 2, OPC_MODRM, OPT_IM8, OPT_MMX ))
DEF_ASM_OP2(punpcklbw, 0x0f60, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
DEF_ASM_OP2(punpcklwd, 0x0f61, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
DEF_ASM_OP2(punpckldq, 0x0f62, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
- DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX ) /* must be last !OP0 */
#undef ALT
#undef DEF_ASM_OP0
diff --git a/x86_64-asm.h b/x86_64-asm.h
index 69cd77c..31a7b38 100644
--- a/x86_64-asm.h
+++ b/x86_64-asm.h
@@ -438,7 +438,7 @@ ALT(DEF_ASM_OP2(psrlq, 0x0f73, 2, OPC_MODRM, OPT_IM8, OPT_MMX ))
DEF_ASM_OP2(punpcklbw, 0x0f60, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
DEF_ASM_OP2(punpcklwd, 0x0f61, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
DEF_ASM_OP2(punpckldq, 0x0f62, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
- DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX ) /* must be last !OP0 */
#undef ALT
#undef DEF_ASM_OP0