struct FuncInfo {
const char* Name; /* Function name */
unsigned short Use; /* Register usage */
- unsigned short Chg; /* Changed/destroyed registers */
+ unsigned short Chg; /* Changed/destroyed registers */
};
static const FuncInfo FuncInfoTable[] = {
- { "addysp", REG_Y, REG_NONE },
- { "aslax1", REG_AX, REG_AX },
- { "aslax2", REG_AX, REG_AX },
- { "aslax3", REG_AX, REG_AX },
- { "aslax4", REG_AX, REG_AX },
- { "bnega", REG_A, REG_AX },
- { "bnegax", REG_AX, REG_AX },
- { "bnegeax", REG_AX, REG_AX },
- { "booleq", REG_NONE, REG_AX },
- { "boolge", REG_NONE, REG_AX },
- { "boolgt", REG_NONE, REG_AX },
- { "boolle", REG_NONE, REG_AX },
- { "boollt", REG_NONE, REG_AX },
- { "boolne", REG_NONE, REG_AX },
- { "booluge", REG_NONE, REG_AX },
- { "boolugt", REG_NONE, REG_AX },
- { "boolule", REG_NONE, REG_AX },
- { "boolult", REG_NONE, REG_AX },
- { "complax", REG_AX, REG_AX },
- { "decax1", REG_AX, REG_AX },
- { "decax2", REG_AX, REG_AX },
- { "decax3", REG_AX, REG_AX },
- { "decax4", REG_AX, REG_AX },
- { "decax5", REG_AX, REG_AX },
- { "decax6", REG_AX, REG_AX },
- { "decax7", REG_AX, REG_AX },
- { "decax8", REG_AX, REG_AX },
- { "decaxy", REG_AXY, REG_AX },
- { "decsp1", REG_NONE, REG_Y },
- { "decsp2", REG_NONE, REG_A },
- { "decsp3", REG_NONE, REG_A },
- { "decsp4", REG_NONE, REG_A },
- { "decsp5", REG_NONE, REG_A },
- { "decsp6", REG_NONE, REG_A },
- { "decsp7", REG_NONE, REG_A },
- { "decsp8", REG_NONE, REG_A },
- { "incax1", REG_AX, REG_AX },
- { "incax2", REG_AX, REG_AX },
- { "incsp1", REG_NONE, REG_NONE },
- { "incsp2", REG_NONE, REG_Y },
- { "incsp3", REG_NONE, REG_Y },
- { "incsp4", REG_NONE, REG_Y },
- { "incsp5", REG_NONE, REG_Y },
- { "incsp6", REG_NONE, REG_Y },
- { "incsp7", REG_NONE, REG_Y },
- { "incsp8", REG_NONE, REG_Y },
- { "ldaidx", REG_AXY, REG_AX },
- { "ldauidx", REG_AXY, REG_AX },
- { "ldax0sp", REG_Y, REG_AX },
- { "ldaxi", REG_AX, REG_AXY },
- { "ldaxidx", REG_AXY, REG_AX },
- { "ldaxysp", REG_Y, REG_AX },
- { "leaasp", REG_A, REG_AX },
- { "negax", REG_AX, REG_AX },
- { "pusha", REG_A, REG_Y },
- { "pusha0", REG_A, REG_XY },
- { "pushax", REG_AX, REG_Y },
- { "pusheax", REG_AX, REG_Y },
- { "pushw0sp", REG_NONE, REG_AXY },
- { "pushwysp", REG_Y, REG_AXY },
- { "shlax1", REG_AX, REG_AX },
- { "shlax2", REG_AX, REG_AX },
- { "shlax3", REG_AX, REG_AX },
- { "shlax4", REG_AX, REG_AX },
- { "shrax1", REG_AX, REG_AX },
- { "shrax2", REG_AX, REG_AX },
- { "shrax3", REG_AX, REG_AX },
- { "shrax4", REG_AX, REG_AX },
- { "shreax1", REG_AX, REG_AX },
- { "shreax2", REG_AX, REG_AX },
- { "shreax3", REG_AX, REG_AX },
- { "shreax4", REG_AX, REG_AX },
- { "staspidx", REG_A | REG_Y, REG_Y },
- { "stax0sp", REG_AX, REG_Y },
- { "tosicmp", REG_AX, REG_AXY },
- { "tosdiva0", REG_AX, REG_AXY },
- { "tosdivax", REG_AX, REG_AXY },
- { "tosdiveax", REG_AX, REG_AXY },
- { "tosmula0", REG_AX, REG_AXY },
- { "tosmulax", REG_AX, REG_AXY },
- { "tosmuleax", REG_AX, REG_AXY },
- { "tosshreax", REG_AX, REG_AXY },
- { "tosumula0", REG_AX, REG_AXY },
- { "tosumulax", REG_AX, REG_AXY },
- { "tosumuleax", REG_AX, REG_AXY },
+ { "addysp", REG_Y, REG_NONE },
+ { "aslax1", REG_AX, REG_AX | REG_TMP1 },
+ { "aslax2", REG_AX, REG_AX | REG_TMP1 },
+ { "aslax3", REG_AX, REG_AX | REG_TMP1 },
+ { "aslax4", REG_AX, REG_AX | REG_TMP1 },
+ { "bnega", REG_A, REG_AX },
+ { "bnegax", REG_AX, REG_AX },
+ { "bnegeax", REG_EAX, REG_EAX },
+ { "booleq", REG_NONE, REG_AX },
+ { "boolge", REG_NONE, REG_AX },
+ { "boolgt", REG_NONE, REG_AX },
+ { "boolle", REG_NONE, REG_AX },
+ { "boollt", REG_NONE, REG_AX },
+ { "boolne", REG_NONE, REG_AX },
+ { "booluge", REG_NONE, REG_AX },
+ { "boolugt", REG_NONE, REG_AX },
+ { "boolule", REG_NONE, REG_AX },
+ { "boolult", REG_NONE, REG_AX },
+ { "complax", REG_AX, REG_AX },
+ { "decax1", REG_AX, REG_AX },
+ { "decax2", REG_AX, REG_AX },
+ { "decax3", REG_AX, REG_AX },
+ { "decax4", REG_AX, REG_AX },
+ { "decax5", REG_AX, REG_AX },
+ { "decax6", REG_AX, REG_AX },
+ { "decax7", REG_AX, REG_AX },
+ { "decax8", REG_AX, REG_AX },
+ { "decaxy", REG_AXY, REG_AX | REG_TMP1 },
+ { "decsp1", REG_NONE, REG_Y },
+ { "decsp2", REG_NONE, REG_A },
+ { "decsp3", REG_NONE, REG_A },
+ { "decsp4", REG_NONE, REG_A },
+ { "decsp5", REG_NONE, REG_A },
+ { "decsp6", REG_NONE, REG_A },
+ { "decsp7", REG_NONE, REG_A },
+ { "decsp8", REG_NONE, REG_A },
+ { "incax1", REG_AX, REG_AX },
+ { "incax2", REG_AX, REG_AX },
+ { "incsp1", REG_NONE, REG_NONE },
+ { "incsp2", REG_NONE, REG_Y },
+ { "incsp3", REG_NONE, REG_Y },
+ { "incsp4", REG_NONE, REG_Y },
+ { "incsp5", REG_NONE, REG_Y },
+ { "incsp6", REG_NONE, REG_Y },
+ { "incsp7", REG_NONE, REG_Y },
+ { "incsp8", REG_NONE, REG_Y },
+ { "ldaidx", REG_AXY, REG_AX | REG_PTR1 },
+ { "ldauidx", REG_AXY, REG_AX | REG_PTR1 },
+ { "ldax0sp", REG_Y, REG_AX },
+ { "ldaxi", REG_AX, REG_AXY | REG_PTR1 },
+ { "ldaxidx", REG_AXY, REG_AX | REG_PTR1 },
+ { "ldaxysp", REG_Y, REG_AX },
+ { "leaasp", REG_A, REG_AX },
+ { "negax", REG_AX, REG_AX },
+ { "pusha", REG_A, REG_Y },
+ { "pusha0", REG_A, REG_XY },
+ { "pushax", REG_AX, REG_Y },
+ { "pusheax", REG_EAX, REG_Y },
+ { "pushw0sp", REG_NONE, REG_AXY },
+ { "pushwysp", REG_Y, REG_AXY },
+ { "shlax1", REG_AX, REG_AX | REG_TMP1 },
+ { "shlax2", REG_AX, REG_AX | REG_TMP1 },
+ { "shlax3", REG_AX, REG_AX | REG_TMP1 },
+ { "shlax4", REG_AX, REG_AX | REG_TMP1 },
+ { "shrax1", REG_AX, REG_AX | REG_TMP1 },
+ { "shrax2", REG_AX, REG_AX | REG_TMP1 },
+ { "shrax3", REG_AX, REG_AX | REG_TMP1 },
+ { "shrax4", REG_AX, REG_AX | REG_TMP1 },
+ { "shreax1", REG_EAX, REG_AX | REG_TMP1 },
+ { "shreax2", REG_EAX, REG_AX | REG_TMP1 },
+ { "shreax3", REG_EAX, REG_AX | REG_TMP1 },
+ { "shreax4", REG_EAX, REG_AX | REG_TMP1 },
+ { "staspidx", REG_A | REG_Y, REG_Y | REG_TMP1 | REG_PTR1 },
+ { "stax0sp", REG_AX, REG_Y },
+ { "tosicmp", REG_AX, REG_AXY | REG_SREG },
+ { "tosdiva0", REG_AX, REG_ALL },
+ { "tosdivax", REG_AX, REG_ALL },
+ { "tosdiveax", REG_EAX, REG_ALL },
+ { "tosmula0", REG_AX, REG_ALL },
+ { "tosmulax", REG_AX, REG_ALL },
+ { "tosmuleax", REG_EAX, REG_ALL },
+ { "tosshreax", REG_EAX, REG_EAXY | REG_PTR1 | REG_PTR2 },
+ { "tosumula0", REG_AX, REG_ALL },
+ { "tosumulax", REG_AX, REG_ALL },
+ { "tosumuleax", REG_EAX, REG_ALL },
};
#define FuncInfoCount (sizeof(FuncInfoTable) / sizeof(FuncInfoTable[0]))
/* Table with names of zero page locations used by the compiler */
typedef struct ZPInfo ZPInfo;
struct ZPInfo {
- unsigned char Len; /* Length of the following string */
- char Name[11]; /* Name of zero page symbol */
+ unsigned char Len; /* Length of the following string */
+ char Name[11]; /* Name of zero page symbol */
+ unsigned short RegInfo; /* Register info for this symbol */
};
static const ZPInfo ZPInfoTable[] = {
- { 4, "ptr1" },
- { 7, "regbank" },
- { 7, "regsave" },
- { 2, "sp" },
- { 4, "sreg" },
- { 4, "tmp1" },
+ { 4, "ptr1", REG_PTR1 },
+ { 4, "ptr2", REG_PTR2 },
+ { 4, "ptr3", REG_PTR3 },
+ { 4, "ptr4", REG_PTR4 },
+ { 7, "regbank", REG_NONE },
+ { 7, "regsave", REG_NONE },
+ { 2, "sp", REG_NONE },
+ { 4, "sreg", REG_SREG },
+ { 4, "tmp1", REG_TMP1 },
+ { 4, "tmp2", REG_TMP2 },
+ { 4, "tmp3", REG_TMP3 },
};
#define ZPInfoCount (sizeof(ZPInfoTable) / sizeof(ZPInfoTable[0]))
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
}
/* Will destroy all registers */
- *Chg = REG_AXY;
+ *Chg = REG_ALL;
/* Done */
return;
}
}
- /* Function not found - assume all registers used */
+ /* Function not found - assume all CPU registers are input, and all
+ * registers are changed
+ */
*Use = REG_AXY;
- *Chg = REG_AXY;
+ *Chg = REG_ALL;
}
-int IsZPName (const char* Name)
-/* Return true if the given name is a zero page symbol */
+int IsZPName (const char* Name, unsigned short* RegInfo)
+/* Return true if the given name is a zero page symbol. If the RegInfo
+ * pointer is not NULL, it is filled with the register info for the
+ * zero page location found.
+ */
{
unsigned I;
const ZPInfo* Info;
/* Because of the low number of symbols, we do a linear search here */
for (I = 0, Info = ZPInfoTable; I < ZPInfoCount; ++I, ++Info) {
if (strncmp (Name, Info->Name, Info->Len) == 0 &&
- (Name[Info->Len] == '\0' || Name[Info->Len] == '+')) {
- /* Found */
- return 1;
- }
+ (Name[Info->Len] == '\0' || Name[Info->Len] == '+')) {
+ /* Found */
+ if (RegInfo) {
+ *RegInfo = Info->RegInfo;
+ }
+ return 1;
+ }
}
/* Not found */
static unsigned GetRegInfo1 (CodeSeg* S,
- CodeEntry* E,
- int Index,
- Collection* Visited,
+ CodeEntry* E,
+ int Index,
+ Collection* Visited,
unsigned Used,
unsigned Unused);
/* Recursively called subfunction for GetRegInfo. */