Le dimanche 22 septembre 2013 19:55:11 Thomas Preud'homme a écrit : > Le dimanche 22 septembre 2013 18:16:06 grischka a écrit : > > > Beyond that > > > > error: unknown opcode 'jmp' > > > > is just a rather bad message. Maybe it could say something like > > > > error: bad operand '%eax' with opcode 'jmp' > > A test could be added with a TOK_ASM_allfirst and TOK_ASM_alllast to > distinguish between incorrect operand and incorrect opcode.
Would a patch like the one attach be ok? I didn't named the operand because when several alternatives exist for an opcode it's difficult to know which operand is at fault (which of the alternative didn't match but was intended to?). Best regards, Thomas
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
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
