From: uz Date: Fri, 4 Dec 2009 13:04:40 +0000 (+0000) Subject: Move global segment creation to a better place in source. X-Git-Tag: V2.13.1~31 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1f90ec93a0f3f97788eaf6c3ef10e761e5215245;p=cc65 Move global segment creation to a better place in source. git-svn-id: svn://svn.cc65.org/cc65/trunk@4498 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index 323a2b5b1..8287ca84e 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -145,10 +145,6 @@ static const char* GetLabelName (unsigned Flags, unsigned long Label, long Offs) void g_preamble (void) /* Generate the assembler code preamble */ { - /* Create a new (global) segment list and remember it */ - PushSegments (0); - GS = CS; - /* Identify the compiler version */ AddTextLine (";"); AddTextLine ("; File generated by cc65 v %s", GetVersionAsString ()); diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 3dd7bffa4..9d92b4ace 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -343,12 +343,15 @@ void Compile (const char* FileName) /* DefineNumericMacro ("__STDC__", 1); <- not now */ DefineNumericMacro ("__STDC_HOSTED__", 1); - /* Initialize the literal pool */ - InitLiteralPool (); - /* Create the base lexical level */ EnterGlobalLevel (); + /* Create the global code and data segments */ + CreateGlobalSegments (); + + /* Initialize the literal pool */ + InitLiteralPool (); + /* Generate the code generator preamble */ g_preamble (); diff --git a/src/cc65/segments.c b/src/cc65/segments.c index 97fa98cea..7fbaa34a6 100644 --- a/src/cc65/segments.c +++ b/src/cc65/segments.c @@ -183,6 +183,14 @@ void PopSegments (void) +void CreateGlobalSegments (void) +/* Create the global segments and remember them in GS */ +{ + GS = PushSegments (0); +} + + + void UseDataSeg (segment_t DSeg) /* For the current segment list, use the data segment DSeg */ { diff --git a/src/cc65/segments.h b/src/cc65/segments.h index fd4d2d5f3..11c8fb2bc 100644 --- a/src/cc65/segments.h +++ b/src/cc65/segments.h @@ -123,6 +123,9 @@ Segments* PushSegments (struct SymEntry* Func); void PopSegments (void); /* Pop the old segment list (make it current) */ +void CreateGlobalSegments (void); +/* Create the global segments and remember them in GS */ + void UseDataSeg (segment_t DSeg); /* For the current segment list, use the data segment DSeg */