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 */