diff lwasm/pass1.c @ 329:9f7889139b06

Fix 6809 mode to count 6309 instructions as non-existent Allow 6309 instructions to be shadowed by macros when assembling in 6809 mode. After all, 6309 instructions are NOT instructions in 6809 mode so why shouldn't they be shadowable by macros?
author William Astle <lost@l-w.ca>
date Sun, 13 Apr 2014 16:03:59 -0600
parents 1409debcb1a0
children 507f442dc71e
line wrap: on
line diff
--- a/lwasm/pass1.c	Fri Apr 11 21:54:07 2014 -0600
+++ b/lwasm/pass1.c	Sun Apr 13 16:03:59 2014 -0600
@@ -274,8 +274,6 @@
 				if (!strcasecmp(instab[opnum].opcode, sym))
 					break;
 			}
-			if ((as -> target != TARGET_6309) && (instab[opnum].flags & lwasm_insn_is6309))
-				lwasm_register_error(as, cl, "Illegal use of 6309 instruction in 6809 mode (%s)", sym);
 			
 			// have to go to linedone here in case there was a symbol
 			// to register on this line
@@ -298,7 +296,7 @@
 			if (as -> skipcond && !(instab[opnum].flags & lwasm_insn_cond))
 				goto linedone;
         	
-        	if (!nomacro && (as -> pragmas & PRAGMA_SHADOW))
+        	if (!nomacro && ((as -> pragmas & PRAGMA_SHADOW) || ((as -> target != TARGET_6309) && (instab[opnum].flags & lwasm_insn_is6309))))
         	{
         		// check for macros even if they shadow real operations
         		// NOTE: "ENDM" cannot be shadowed
@@ -332,13 +330,16 @@
 				// no parse func means operand doesn't matter
 				if (instab[opnum].parse)
 				{
+					if ((as -> target != TARGET_6309) && (instab[opnum].flags & lwasm_insn_is6309))
+						lwasm_register_error(as, cl, "Illegal use of 6309 instruction in 6809 mode (%s)", sym);
+			
 					if (as -> instruct == 0 || instab[opnum].flags & lwasm_insn_struct)
 					{
 						struct line_expr_s *le;
 
 						cl -> len = -1;
 						// call parse function
-					debug_message(as, 100, "len = %d, dlen = %d", cl -> len, cl -> dlen);
+						debug_message(as, 100, "len = %d, dlen = %d", cl -> len, cl -> dlen);
 						(instab[opnum].parse)(as, cl, &p1);
 						if ((cl -> inmod == 0) && cl -> len >= 0 && cl -> dlen >= 0)
 						{