#include "check.h"
#include "coll.h"
#include "scanner.h"
+#include "segnames.h"
#include "xmalloc.h"
/* cc65 */
/* 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];
void InitSegNames (void)
/* Initialize the segment names */
{
- SegmentNames [SEG_BSS] = xstrdup ("BSS");
- SegmentNames [SEG_CODE] = xstrdup ("CODE");
- SegmentNames [SEG_DATA] = xstrdup ("DATA");
- SegmentNames [SEG_RODATA] = xstrdup ("RODATA");
+ SegmentNames [SEG_BSS] = xstrdup (SEGNAME_BSS);
+ SegmentNames [SEG_CODE] = xstrdup (SEGNAME_CODE);
+ SegmentNames [SEG_DATA] = xstrdup (SEGNAME_DATA);
+ SegmentNames [SEG_RODATA] = xstrdup (SEGNAME_RODATA);
}
-int ValidSegName (const char* Name)
-/* Return true if the given segment name is valid, return false otherwise */
-{
- /* Must start with '_' or a letter */
- if ((*Name != '_' && !IsAlpha(*Name)) || strlen(Name) > 80) {
- return 0;
- }
-
- /* Can have letters, digits or the underline */
- while (*++Name) {
- if (*Name != '_' && !IsAlNum(*Name)) {
- return 0;
- }
- }
-
- /* Name is ok */
- return 1;
-}
-
-
-
static Segments* NewSegments (SymEntry* Func)
/* Initialize a Segments structure (set all fields to NULL) */
{
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);
}
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);
}
va_list ap;
va_start (ap, Format);
CHECK (CS != 0);
- DS_AddLine (GetDataSeg(), Format, ap);
+ DS_AddVLine (GetDataSeg(), Format, ap);
va_end (ap);
}
-static void PrintFunctionHeader (const SymEntry* Entry, FILE* F)
-{
- /* Print a comment with the function signature */
- fprintf (F,
- "; ---------------------------------------------------------------\n"
- "; ");
- PrintFuncSig (F, Entry->Name, Entry->Type);
- fprintf (F,
- "\n"
- "; ---------------------------------------------------------------\n"
- "\n");
-}
-
-
-
void OutputSegments (const Segments* S, FILE* F)
/* Output the given segments to the file */
{
- /* If the code segment is associated with a function, print a function header */
- if (S->Code->Func) {
- PrintFunctionHeader (S->Code->Func, F);
- }
+ /* Output the function prologue if the segments came from a function */
+ CS_OutputPrologue (S->Code, F);
/* Output the text segment */
TS_Output (S->Text, F);
/* Output the code segment */
CS_Output (S->Code, F);
+
+ /* Output the code segment epiloque */
+ CS_OutputEpilogue (S->Code, F);
}