]> git.sur5r.net Git - cc65/blobdiff - src/cc65/codeent.h
Fixed a bug
[cc65] / src / cc65 / codeent.h
index 278e471bd3528506d6aa4941cc0a5c0ef88df19e..a78d77e8107f949fad7250add5835feddceeccf4 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2001     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 2001-2002 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -39,6 +39,7 @@
 
 
 #include <stdio.h>
+#include <string.h>
 
 /* common */
 #include "coll.h"
@@ -48,6 +49,7 @@
 #include "codelab.h"
 #include "lineinfo.h"
 #include "opcodes.h"
+#include "reginfo.h"
 
 
 
@@ -70,12 +72,13 @@ struct CodeEntry {
     unsigned long      Num;            /* Numeric argument */
     unsigned short     Flags;          /* Flags */
     unsigned short      Info;          /* Additional code info */
+    unsigned short      Use;           /* Registers used */
+    unsigned short      Chg;           /* Registers changed/destroyed */
     unsigned char      Size;           /* Estimated size */
-    unsigned char      Use;            /* Registers used */
-    unsigned char      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 */
 };
 
 
@@ -86,8 +89,16 @@ struct CodeEntry {
 
 
 
+const char* MakeHexArg (unsigned Num);
+/* Convert Num into a string in the form $XY, suitable for passing it as an
+ * argument to NewCodeEntry, and return a pointer to the string.
+ * BEWARE: The function returns a pointer to a static buffer, so the value is
+ * gone if you call it twice (and apart from that it's not thread and signal
+ * safe).
+ */
+
 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);
@@ -167,8 +178,36 @@ INLINE void CE_ResetMark (CodeEntry* E)
 #  define CE_ResetMark(E)      ((E)->Flags &= ~CEF_USERMARK)
 #endif
 
-void CE_SetArg (CodeEntry* E, const char* Arg);
-/* Set a new argument for the given code entry. An old string is deleted. */
+void CE_SetNumArg (CodeEntry* E, long Num);
+/* Set a new numeric argument for the given code entry that must already
+ * have a numeric argument.
+ */
+
+int CE_KnownImm (const CodeEntry* E);
+/* Return true if the argument of E is a known immediate value */
+
+#if defined(HAVE_INLINE)
+INLINE int CE_IsCall (const CodeEntry* E, const char* Name)
+/* Check if this is a call to the given function */
+{
+    return (E->OPC == OP65_JSR && strcmp (E->Arg, Name) == 0);
+}
+#else
+#  define CE_IsCall(E, Name) ((E)->OPC == OP65_JSR && strcmp ((E)->Arg, (Name)) == 0)
+#endif
+
+int CE_UseLoadFlags (const CodeEntry* E);
+/* Return true if the instruction uses any flags that are set by a load of
+ * a register (N and Z).
+ */
+
+void CE_FreeRegInfo (CodeEntry* E);
+/* Free an existing register info struct */
+
+void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs);
+/* Generate register info for this instruction. If an old info exists, it is
+ * overwritten.
+ */
 
 void CE_Output (const CodeEntry* E, FILE* F);
 /* Output the code entry to a file */
@@ -180,4 +219,4 @@ void CE_Output (const CodeEntry* E, FILE* F);
 
 
 
-        
+