From: uz Date: Fri, 19 Aug 2011 20:55:48 +0000 (+0000) Subject: Renamed some stuff. Write out the segment size as var, not 32 bit. X-Git-Tag: V2.13.3~229 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1e20489ee1d09f3b043b7f6b3e8434d3d8a0b27a;p=cc65 Renamed some stuff. Write out the segment size as var, not 32 bit. git-svn-id: svn://svn.cc65.org/cc65/trunk@5233 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ca65/main.c b/src/ca65/main.c index 17aca8efc..7364891bc 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -867,7 +867,7 @@ int main (int argc, char* argv []) InitIncludePaths (); /* Create the predefined segments */ - InitSegments (); + SegInit (); /* Enter the base lexical level. We must do that here, since we may * define symbols using -D. @@ -1013,7 +1013,7 @@ int main (int argc, char* argv []) /* If we didn't have any errors, check and cleanup the unnamed labels */ if (ErrorCount == 0) { - ULabDone (); + ULabDone (); } /* If we didn't have any errors, check the symbol table */ @@ -1028,7 +1028,7 @@ int main (int argc, char* argv []) /* If we didn't have any errors, check and resolve the segment data */ if (ErrorCount == 0) { - SegCheck (); + SegDone (); } /* If we didn't have any errors, check the assertions */ diff --git a/src/ca65/segment.c b/src/ca65/segment.c index a0a7b9662..9a1532b26 100644 --- a/src/ca65/segment.c +++ b/src/ca65/segment.c @@ -52,6 +52,7 @@ #include "objcode.h" #include "objfile.h" #include "segment.h" +#include "span.h" #include "spool.h" #include "studyexpr.h" #include "symtab.h" @@ -325,8 +326,8 @@ unsigned char GetSegAddrSize (unsigned SegNum) -void SegCheck (void) -/* Check the segments for range and other errors */ +void SegDone (void) +/* Check the segments for range and other errors. Do cleanup. */ { static const unsigned long U_Hi[4] = { 0x000000FFUL, 0x0000FFFFUL, 0x00FFFFFFUL, 0xFFFFFFFFUL @@ -453,7 +454,7 @@ void SegDump (void) -void InitSegments (void) +void SegInit (void) /* Initialize segments */ { /* Create the predefined segments. Code segment is active */ @@ -512,7 +513,7 @@ static void WriteOneSeg (Segment* Seg) /* Write the segment data */ ObjWriteVar (GetStringId (Seg->Def->Name)); /* Name of the segment */ - ObjWrite32 (Seg->PC); /* Size */ + ObjWriteVar (Seg->PC); /* Size */ ObjWrite8 (Seg->Align); /* Segment alignment */ ObjWrite8 (Seg->Def->AddrSize); /* Address size of the segment */ ObjWriteVar (Seg->FragCount); /* Number of fragments */ diff --git a/src/ca65/segment.h b/src/ca65/segment.h index 84982236a..c28c86be1 100644 --- a/src/ca65/segment.h +++ b/src/ca65/segment.h @@ -153,13 +153,13 @@ void EnterRelocMode (void); * switch the mode globally or for the current segment. */ -void SegCheck (void); -/* Check the segments for range and other errors */ +void SegDone (void); +/* Check the segments for range and other errors. Do cleanup. */ void SegDump (void); /* Dump the contents of all segments */ -void InitSegments (void); +void SegInit (void); /* Initialize segments */ void SetSegmentSizes (void); diff --git a/src/ca65/span.c b/src/ca65/span.c index e7339e78c..3346eda0a 100644 --- a/src/ca65/span.c +++ b/src/ca65/span.c @@ -151,6 +151,23 @@ void CloseSpans (Collection* Spans) +static void WriteSpan (const Span* S) +/* Write one span to the output file */ +{ + /* Done accept empty spans */ + CHECK (S->End > S->Start); + + /* Write data for the span We will write the size instead of the end + * offset to save some bytes, since most spans are expected to be + * rather small. + */ + ObjWriteVar (S->Seg->Num); + ObjWriteVar (S->Start); + ObjWriteVar (S->End - S->Start); +} + + + void WriteSpans (const Collection* Spans) /* Write a list of spans to the output file */ { @@ -161,22 +178,10 @@ void WriteSpans (const Collection* Spans) /* Write the spans */ for (I = 0; I < CollCount (Spans); ++I) { - - /* Get next range */ - const Span* S = CollConstAt (Spans, I); - - CHECK (S->End > S->Start); - - /* Write data for the span We will write the size instead of the end - * offset to save some bytes, since most spans are expected to be - * rather small. - */ - ObjWriteVar (S->Seg->Num); - ObjWriteVar (S->Start); - ObjWriteVar (S->End - S->Start); + /* Write the next span */ + WriteSpan (CollConstAt (Spans, I)); } } - diff --git a/src/ca65/span.h b/src/ca65/span.h index 407c753d9..04af807a2 100644 --- a/src/ca65/span.h +++ b/src/ca65/span.h @@ -50,10 +50,12 @@ +/* Forwards */ +struct Segment; + /* Span definition */ typedef struct Span Span; struct Span{ - unsigned Id; /* Span id */ struct Segment* Seg; /* Pointer to segment */ unsigned long Start; /* Start of range */ unsigned long End; /* End of range */ @@ -62,7 +64,7 @@ struct Span{ /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/