/* */
/* */
/* */
-/* (C) 1998-2005, Ullrich von Bassewitz */
-/* Römerstrasse 52 */
+/* (C) 1998-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* common */
#include "addrsize.h"
-#include "assertdefs.h"
#include "attrib.h"
#include "bitops.h"
#include "check.h"
{ "BCC", 0x0020000, 0x90, 0, PutPCRel8 },
{ "BCS", 0x0020000, 0xb0, 0, PutPCRel8 },
{ "BEQ", 0x0020000, 0xf0, 0, PutPCRel8 },
- { "BGE", 0x0020000, 0xb0, 0, PutPCRel8 }, /* == BCS */
{ "BIT", 0x0a0006c, 0x00, 2, PutAll },
- { "BLT", 0x0020000, 0x90, 0, PutPCRel8 }, /* == BCC */
{ "BMI", 0x0020000, 0x30, 0, PutPCRel8 },
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "ST", AMSW16_REG | AMSW16_IND, 0x10, 1, PutSweet16 },
{ "STD", AMSW16_IND, 0x70, 0, PutSweet16 },
{ "STP", AMSW16_IND, 0x90, 0, PutSweet16 },
- { "SUB", AMSW16_IMM, 0xB0, 0, PutSweet16 },
+ { "SUB", AMSW16_REG, 0xB0, 0, PutSweet16 },
}
};
/* Simplify it if possible */
A->Expr = SimplifyExpr (A->Expr, &ED);
- /* If we don't know how big the expression is, assume the default
- * address size for data.
- */
if (ED.AddrSize == ADDR_SIZE_DEFAULT) {
+ /* If we don't know how big the expression is, assume the
+ * default address size for data. If this default address
+ * size is unequal to zero page addressing, but zero page
+ * addressing is allowed by the instruction, mark all symbols
+ * in the expression tree. This mark will be checked at end
+ * of assembly, and a warning is issued, if a zero page symbol
+ * was guessed wrong here.
+ */
ED.AddrSize = DataAddrSize;
+ if (ED.AddrSize > ADDR_SIZE_ZP && (A->AddrModeSet & AM65_SET_ZP)) {
+ ExprGuessedAddrSize (A->Expr, ADDR_SIZE_ZP);
+ }
}
/* Check the size */
EffAddr A;
/* The first argument is always an immediate byte */
- if (Tok != TOK_HASH) {
+ if (CurTok.Tok != TOK_HASH) {
ErrorSkip ("Invalid addressing mode");
return;
}
CHECK (NewCPU < CPU_COUNT);
/* Check if we have support for the new CPU, if so, use it */
- if (InsTabs[NewCPU]) {
+ if (NewCPU != CPU_UNKNOWN && InsTabs[NewCPU]) {
CPU = NewCPU;
InsTab = InsTabs[CPU];
} else {
-int FindInstruction (const char* Ident)
+int FindInstruction (const StrBuf* Ident)
/* Check if Ident is a valid mnemonic. If so, return the index in the
* instruction table. If not, return -1.
*/
/* Make a copy, and uppercase that copy */
I = 0;
- while (Ident[I] != '\0') {
+ while (I < SB_GetLen (Ident)) {
/* If the identifier is longer than the longest mnemonic, it cannot
* be one.
*/
/* Not found, no need for further action */
return -1;
}
- Key[I] = toupper ((unsigned char)Ident[I]);
+ Key[I] = toupper ((unsigned char)SB_AtUnchecked (Ident, I));
++I;
}
Key[I] = '\0';