]> git.sur5r.net Git - cc65/blobdiff - src/cc65/asmcode.c
Renamed ExprDesc.Val to ExprDesc.IVal. Added an FVal field for a floating
[cc65] / src / cc65 / asmcode.c
index 3522ce1694424fa58bb9195bc744d1eee397e1f9..776e36f674e2b4efcf12693030eeac5bc5488f98 100644 (file)
 #include "codeopt.h"
 #include "codeseg.h"
 #include "dataseg.h"
+#include "segments.h"
 #include "symtab.h"
 #include "asmcode.h"
 
 
 
 /*****************************************************************************/
-/*                                  Code                                    */
+/*                                  Code                                    */
 /*****************************************************************************/
 
 
 
-void AddCodeHint (const char* Hint)
-/* Add an optimizer hint */
-{
-    /* ### AddCodeLine ("+%s", Hint); */
-}
-
-
-
 CodeMark GetCodePos (void)
 /* Get a marker pointing to the current output position */
 {
-    return GetCodeSegEntries (CS);
+    return CS_GetEntryCount (CS->Code);
 }
 
 
@@ -70,22 +63,17 @@ CodeMark GetCodePos (void)
 void RemoveCode (CodeMark M)
 /* Remove all code after the given code marker */
 {
-    DelCodeSegAfter (CS, M);
+    CS_DelCodeAfter (CS->Code, M);
 }
 
 
 
-static void PrintFunctionHeader (FILE* F, SymEntry* Entry)
+void MoveCode (CodeMark Start, CodeMark End, CodeMark Target)
+/* Move the code between Start (inclusive) and End (exclusive) to
+ * (before) Target.
+ */
 {
-    /* Print a comment with the function signature */
-    fprintf (F,
-            "; ---------------------------------------------------------------\n"
-            "; ");
-    PrintFuncSig (F, Entry->Name, Entry->Type);
-    fprintf (F,
-                    "\n"
-            "; ---------------------------------------------------------------\n"
-            "\n");
+    CS_MoveEntries (CS->Code, Start, End - Start, Target);
 }
 
 
@@ -96,27 +84,23 @@ void WriteOutput (FILE* F)
     SymTable* SymTab;
     SymEntry* Entry;
 
-    /* Output the data segment (the global code segment should be empty) */
-    OutputDataSeg (F, DS);
-    CHECK (GetCodeSegEntries (CS) == 0);
+    /* Output the global data segment */
+    CHECK (!HaveGlobalCode ());
+    OutputSegments (CS, F);
 
     /* Output all global or referenced functions */
     SymTab = GetGlobalSymTab ();
     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 */
-           PrintFunctionHeader (F, Entry);
-           MergeCodeLabels (Entry->V.F.CS);
-           RunOpt (Entry->V.F.CS);
-           fprintf (F, "; Data segment for function %s:\n", Entry->Name);
-           OutputDataSeg (F, Entry->V.F.DS);
-           fprintf (F, "; Code segment for function %s:\n", Entry->Name);
-           OutputCodeSeg (F, Entry->V.F.CS);
-       }
-       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;
     }
 }