]> git.sur5r.net Git - cc65/blobdiff - src/cc65/codegen.c
Working on the new backend
[cc65] / src / cc65 / codegen.c
index 8252d6162e431b6b1992c2fe62712b67df774625..8839430b687c272d52f17baa5a1d2b0d8add1247 100644 (file)
@@ -9,7 +9,7 @@
 /* (C) 1998-2001 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -145,9 +145,9 @@ void g_preamble (void)
 /* Generate the assembler code preamble */
 {
     /* Generate the global segments and push them */
-    PushCodeSeg (NewCodeSeg (""));
+    PushCodeSeg (NewCodeSeg (SegmentNames[SEG_CODE], ""));
     PushDataSeg (NewDataSeg (""));
-                              
+
     /* Identify the compiler version */
     AddDataSegLine (DS, "; File generated by cc65 v %u.%u.%u",
                    VER_MAJOR, VER_MINOR, VER_PATCH);
@@ -198,6 +198,26 @@ static void UseSeg (int NewSeg)
 
 
 
+void g_pushseg (struct CodeSeg** FCS, struct DataSeg** FDS, const char* FuncName)
+/* Push the current segments and generate new ones for the given function */
+{
+    PushCodeSeg (NewCodeSeg (SegmentNames[SEG_CODE], FuncName));
+    *FCS = CS;
+    PushDataSeg (NewDataSeg (FuncName));
+    *FDS = DS;
+}
+
+
+
+void g_popseg (void)
+/* Restore the old segments */
+{
+    PopCodeSeg ();
+    PopDataSeg ();
+}
+
+
+
 void g_usecode (void)
 /* Switch to the code segment */
 {
@@ -3896,7 +3916,7 @@ void g_defbytes (const void* Bytes, unsigned Count)
        } while (Chunk);
 
        /* Output the line */
-       AddCodeSegLine (CS, Buf);
+               AddDataSegLine (DS, Buf);
     }
 }