]> git.sur5r.net Git - cc65/blobdiff - src/cc65/asmcode.c
Fixed a bug
[cc65] / src / cc65 / asmcode.c
index 046043f2b43c6fa8cf9dbb3379e6bd1396d4b056..776e36f674e2b4efcf12693030eeac5bc5488f98 100644 (file)
 
 
 /*****************************************************************************/
-/*                                  Code                                    */
+/*                                  Code                                    */
 /*****************************************************************************/
 
 
 
-void AddCodeHint (const char* Hint)
-/* Add an optimizer hint */
+CodeMark GetCodePos (void)
+/* Get a marker pointing to the current output position */
 {
-    /* ### AddCodeLine ("+%s", Hint); */
+    return CS_GetEntryCount (CS->Code);
 }
 
 
 
-CodeMark GetCodePos (void)
-/* Get a marker pointing to the current output position */
+void RemoveCode (CodeMark M)
+/* Remove all code after the given code marker */
 {
-    return GetCodeSegEntries (CS->Code);
+    CS_DelCodeAfter (CS->Code, M);
 }
 
 
 
-void RemoveCode (CodeMark M)
-/* Remove all code after the given code marker */
+void MoveCode (CodeMark Start, CodeMark End, CodeMark Target)
+/* Move the code between Start (inclusive) and End (exclusive) to
+ * (before) Target.
+ */
 {
-    DelCodeSegAfter (CS->Code, M);
+    CS_MoveEntries (CS->Code, Start, End - Start, Target);
 }
 
 
@@ -83,7 +85,7 @@ void WriteOutput (FILE* F)
     SymEntry* Entry;
 
     /* Output the global data segment */
-    CHECK (GetCodeSegEntries (CS->Code) == 0);
+    CHECK (!HaveGlobalCode ());
     OutputSegments (CS, F);
 
     /* Output all global or referenced functions */
@@ -91,14 +93,14 @@ void WriteOutput (FILE* F)
     Entry  = SymTab->SymHead;
     while (Entry) {
                if (IsTypeFunc (Entry->Type)            &&
-           (Entry->Flags & SC_DEF) != 0        &&
-           (Entry->Flags & (SC_REF | SC_EXTERN)) != 0) {
-           /* Function which is defined and referenced or extern */
-           MergeCodeLabels (Entry->V.F.Seg->Code);
-           RunOpt (Entry->V.F.Seg->Code);
-           OutputSegments (Entry->V.F.Seg, F);
-       }
-       Entry = Entry->NextSym;
+                   SymIsDef (Entry)                    &&
+                   (Entry->Flags & (SC_REF | SC_EXTERN)) != 0) {
+                   /* Function which is defined and referenced or extern */
+                   CS_MergeLabels (Entry->V.F.Seg->Code);
+                   RunOpt (Entry->V.F.Seg->Code);
+                   OutputSegments (Entry->V.F.Seg, F);
+               }
+               Entry = Entry->NextSym;
     }
 }