/*****************************************************************************/
/* */
-/* codeent.h */
+/* codeent.h */
/* */
-/* Code segment entry */
+/* Code segment entry */
/* */
/* */
/* */
-/* (C) 2001-2002 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 2001-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
-#include <stdio.h>
#include <string.h>
/* common */
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
/* Flags used */
-#define CEF_USERMARK 0x0001U /* Generic mark by user functions */
-#define CEF_NUMARG 0x0002U /* Insn has numerical argument */
+#define CEF_USERMARK 0x0001U /* Generic mark by user functions */
+#define CEF_NUMARG 0x0002U /* Insn has numerical argument */
/* Code entry structure */
typedef struct CodeEntry CodeEntry;
struct CodeEntry {
- unsigned char OPC; /* Opcode */
- unsigned char AM; /* Adressing mode */
- unsigned char Size; /* Estimated size */
- unsigned char Flags; /* Flags */
- char* Arg; /* Argument as string */
- unsigned long Num; /* Numeric argument */
- unsigned short Info; /* Additional code info */
- unsigned short Use; /* Registers used */
- unsigned short Chg; /* Registers changed/destroyed */
- CodeLabel* JumpTo; /* Jump label */
- Collection Labels; /* Labels for this instruction */
+ unsigned char OPC; /* Opcode */
+ unsigned char AM; /* Adressing mode */
+ unsigned char Size; /* Estimated size */
+ unsigned char Flags; /* Flags */
+ char* Arg; /* Argument as string */
+ unsigned long Num; /* Numeric argument */
+ unsigned short Info; /* Additional code info */
+ unsigned short Use; /* Registers used */
+ unsigned short Chg; /* Registers changed/destroyed */
+ CodeLabel* JumpTo; /* Jump label */
+ Collection Labels; /* Labels for this instruction */
LineInfo* LI; /* Source line info for this insn */
RegInfo* RI; /* Register info for this insn */
};
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
*/
CodeEntry* NewCodeEntry (opc_t OPC, am_t AM, const char* Arg,
- CodeLabel* JumpTo, LineInfo* LI);
+ CodeLabel* JumpTo, LineInfo* LI);
/* Create a new code entry, initialize and return it */
void FreeCodeEntry (CodeEntry* E);
return (CollCount (&E->Labels) > 0);
}
#else
-# define CE_HasLabel(E) (CollCount (&(E)->Labels) > 0)
+# define CE_HasLabel(E) (CollCount (&(E)->Labels) > 0)
#endif
#if defined(HAVE_INLINE)
return CollCount (&E->Labels);
}
#else
-# define CE_GetLabelCount(E) CollCount (&(E)->Labels)
+# define CE_GetLabelCount(E) CollCount (&(E)->Labels)
#endif
#if defined(HAVE_INLINE)
return CollAt (&E->Labels, Index);
}
#else
-# define CE_GetLabel(E, Index) CollAt (&(E)->Labels, (Index))
+# define CE_GetLabel(E, Index) CollAt (&(E)->Labels, (Index))
#endif
void CE_MoveLabel (CodeLabel* L, CodeEntry* E);
return (E->Flags & CEF_USERMARK) != 0;
}
#else
-# define CE_HasMark(E) (((E)->Flags & CEF_USERMARK) != 0)
+# define CE_HasMark(E) (((E)->Flags & CEF_USERMARK) != 0)
#endif
#if defined(HAVE_INLINE)
E->Flags |= CEF_USERMARK;
}
#else
-# define CE_SetMark(E) ((E)->Flags |= CEF_USERMARK)
+# define CE_SetMark(E) ((E)->Flags |= CEF_USERMARK)
#endif
#if defined(HAVE_INLINE)
E->Flags &= ~CEF_USERMARK;
}
#else
-# define CE_ResetMark(E) ((E)->Flags &= ~CEF_USERMARK)
+# define CE_ResetMark(E) ((E)->Flags &= ~CEF_USERMARK)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE int CE_HasNumArg (const CodeEntry* E)
+/* Return true if the instruction has a numeric argument */
+{
+ return (E->Flags & CEF_NUMARG) != 0;
+}
+#else
+# define CE_HasNumArg(E) (((E)->Flags & CEF_NUMARG) != 0)
#endif
void CE_SetArg (CodeEntry* E, const char* Arg);
* have a numeric argument.
*/
-int CE_KnownImm (const CodeEntry* E);
-/* Return true if the argument of E is a known immediate value */
+int CE_IsConstImm (const CodeEntry* E);
+/* Return true if the argument of E is a constant immediate value */
+
+int CE_IsKnownImm (const CodeEntry* E, unsigned long Num);
+/* Return true if the argument of E is a constant immediate value that is
+ * equal to Num.
+ */
#if defined(HAVE_INLINE)
INLINE int CE_IsCallTo (const CodeEntry* E, const char* Name)
# define CE_IsCallTo(E, Name) ((E)->OPC == OP65_JSR && strcmp ((E)->Arg, (Name)) == 0)
#endif
-int CE_UseLoadFlags (const CodeEntry* E);
+int CE_UseLoadFlags (CodeEntry* E);
/* Return true if the instruction uses any flags that are set by a load of
* a register (N and Z).
*/
* overwritten.
*/
-void CE_Output (const CodeEntry* E, FILE* F);
-/* Output the code entry to a file */
+void CE_Output (const CodeEntry* E);
+/* Output the code entry to the output file */
/* End of codeent.h */
-#endif
-
-
-
+#endif