1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-11 11:30:13 +00:00

Allow access to the global segments. Place ".dbg file" statements into the

global text segments so they will appear before any of the ".dbg line"
statements emitted later.


git-svn-id: svn://svn.cc65.org/cc65/trunk@852 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-08-24 15:03:10 +00:00
parent 229438fbf9
commit b3af17126c
9 changed files with 66 additions and 24 deletions

View File

@ -52,6 +52,7 @@
#include "error.h"
#include "global.h"
#include "segments.h"
#include "textseg.h"
#include "util.h"
#include "codegen.h"
@ -139,8 +140,9 @@ static char* GetLabelName (unsigned flags, unsigned long label, unsigned offs)
void g_preamble (void)
/* Generate the assembler code preamble */
{
/* Create a new segment list */
/* Create a new (global) segment list and remember it */
PushSegments (0);
GS = CS;
/* Identify the compiler version */
AddTextLine (";");
@ -179,7 +181,10 @@ void g_fileinfo (const char* Name, unsigned long Size, unsigned long MTime)
/* If debug info is enabled, place a file info into the source */
{
if (DebugInfo) {
AddTextLine ("\t.dbg\t\tfile, \"%s\", %lu, %lu", Name, Size, MTime);
/* We have to place this into the global text segment, so it will
* appear before all .dbg line statements.
*/
TS_AddLine (GS->Text, "\t.dbg\t\tfile, \"%s\", %lu, %lu", Name, Size, MTime);
}
}
@ -215,17 +220,6 @@ void g_usebss (void)
static void OutputDataLine (DataSeg* S, const char* Format, ...)
/* Add a line to the current data segment */
{
va_list ap;
va_start (ap, Format);
DS_AddLine (S, Format, ap);
va_end (ap);
}
void g_segname (segment_t Seg, const char* Name)
/* Set the name of a segment */
{
@ -242,7 +236,7 @@ void g_segname (segment_t Seg, const char* Name)
default: S = 0; break;
}
if (S) {
OutputDataLine (S, ".segment\t\"%s\"", Name);
DS_AddLine (S, ".segment\t\"%s\"", Name);
}
}

View File

@ -437,7 +437,7 @@ void CS_AddEntry (CodeSeg* S, struct CodeEntry* E)
void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap)
void CS_AddVLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap)
/* Add a line to the given code segment */
{
const char* L;
@ -482,6 +482,17 @@ void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap)
void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, ...)
/* Add a line to the given code segment */
{
va_list ap;
va_start (ap, Format);
CS_AddVLine (S, LI, Format, ap);
va_end (ap);
}
void CS_InsertEntry (CodeSeg* S, struct CodeEntry* E, unsigned Index)
/* Insert the code entry at the index given. Following code entries will be
* moved to slots with higher indices.

View File

@ -97,7 +97,10 @@ CodeSeg* NewCodeSeg (const char* SegName, SymEntry* Func);
void CS_AddEntry (CodeSeg* S, struct CodeEntry* E);
/* Add an entry to the given code segment */
void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap) attribute ((format(printf,3,0)));
void CS_AddVLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap) attribute ((format(printf,3,0)));
/* Add a line to the given code segment */
void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, ...) attribute ((format(printf,3,4)));
/* Add a line to the given code segment */
void CS_InsertEntry (CodeSeg* S, struct CodeEntry* E, unsigned Index);

View File

@ -81,7 +81,7 @@ void DS_Append (DataSeg* Target, const DataSeg* Source)
void DS_AddLine (DataSeg* S, const char* Format, va_list ap)
void DS_AddVLine (DataSeg* S, const char* Format, va_list ap)
/* Add a line to the given data segment */
{
/* Format the line */
@ -94,6 +94,17 @@ void DS_AddLine (DataSeg* S, const char* Format, va_list ap)
void DS_AddLine (DataSeg* S, const char* Format, ...)
/* Add a line to the given data segment */
{
va_list ap;
va_start (ap, Format);
DS_AddVLine (S, Format, ap);
va_end (ap);
}
void DS_Output (const DataSeg* S, FILE* F)
/* Output the data segment data to a file */
{

View File

@ -77,7 +77,10 @@ DataSeg* NewDataSeg (const char* SegName, SymEntry* Func);
void DS_Append (DataSeg* Target, const DataSeg* Source);
/* Append the data from Source to Target. */
void DS_AddLine (DataSeg* S, const char* Format, va_list ap) attribute ((format(printf,2,0)));
void DS_AddVLine (DataSeg* S, const char* Format, va_list ap) attribute ((format(printf,2,0)));
/* Add a line to the given data segment */
void DS_AddLine (DataSeg* S, const char* Format, ...) attribute ((format(printf,2,3)));
/* Add a line to the given data segment */
void DS_Output (const DataSeg* S, FILE* F);

View File

@ -61,6 +61,9 @@
/* Pointer to the current segment list. Output goes here. */
Segments* CS = 0;
/* Pointer to the global segment list */
Segments* GS = 0;
/* Actual names for the segments */
static char* SegmentNames[SEG_COUNT];
@ -202,7 +205,7 @@ void AddTextLine (const char* Format, ...)
va_list ap;
va_start (ap, Format);
CHECK (CS != 0);
TS_AddLine (CS->Text, Format, ap);
TS_AddVLine (CS->Text, Format, ap);
va_end (ap);
}
@ -214,7 +217,7 @@ void AddCodeLine (const char* Format, ...)
va_list ap;
va_start (ap, Format);
CHECK (CS != 0);
CS_AddLine (CS->Code, CurTok.LI, Format, ap);
CS_AddVLine (CS->Code, CurTok.LI, Format, ap);
va_end (ap);
}
@ -235,7 +238,7 @@ void AddDataLine (const char* Format, ...)
va_list ap;
va_start (ap, Format);
CHECK (CS != 0);
DS_AddLine (GetDataSeg(), Format, ap);
DS_AddVLine (GetDataSeg(), Format, ap);
va_end (ap);
}

View File

@ -91,6 +91,9 @@ struct Segments {
/* Pointer to the current segment list. Output goes here. */
extern Segments* CS;
/* Pointer to the global segment list */
extern Segments* GS;
/*****************************************************************************/
@ -121,7 +124,7 @@ struct DataSeg* GetDataSeg (void);
/* Return the current data segment */
void AddTextLine (const char* Format, ...) attribute ((format (printf, 1, 2)));
/* Add a line of code to the current text segment */
/* Add a line to the current text segment */
void AddCodeLine (const char* Format, ...) attribute ((format (printf, 1, 2)));
/* Add a line of code to the current code segment */

View File

@ -70,7 +70,7 @@ TextSeg* NewTextSeg (SymEntry* Func)
void TS_AddLine (TextSeg* S, const char* Format, va_list ap)
void TS_AddVLine (TextSeg* S, const char* Format, va_list ap)
/* Add a line to the given text segment */
{
/* Format the line */
@ -83,6 +83,17 @@ void TS_AddLine (TextSeg* S, const char* Format, va_list ap)
void TS_AddLine (TextSeg* S, const char* Format, ...)
/* Add a line to the given text segment */
{
va_list ap;
va_start (ap, Format);
TS_AddVLine (S, Format, ap);
va_end (ap);
}
void TS_Output (const TextSeg* S, FILE* F)
/* Output the text segment data to a file */
{

View File

@ -79,7 +79,10 @@ struct TextSeg {
TextSeg* NewTextSeg (SymEntry* Func);
/* Create a new text segment, initialize and return it */
void TS_AddLine (TextSeg* S, const char* Format, va_list ap) attribute ((format(printf,2,0)));
void TS_AddVLine (TextSeg* S, const char* Format, va_list ap) attribute ((format(printf,2,0)));
/* Add a line to the given text segment */
void TS_AddLine (TextSeg* S, const char* Format, ...) attribute ((format(printf,2,3)));
/* Add a line to the given text segment */
void TS_Output (const TextSeg* S, FILE* F);