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
This commit is contained in:
uz 2011-08-19 20:55:48 +00:00
parent 607aa871e6
commit 1e20489ee1
5 changed files with 34 additions and 26 deletions

View file

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

View file

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

View file

@ -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);

View file

@ -151,20 +151,10 @@ void CloseSpans (Collection* Spans)
void WriteSpans (const Collection* Spans)
/* Write a list of spans to the output file */
static void WriteSpan (const Span* S)
/* Write one span to the output file */
{
unsigned I;
/* Write the number of spans */
ObjWriteVar (CollCount (Spans));
/* Write the spans */
for (I = 0; I < CollCount (Spans); ++I) {
/* Get next range */
const Span* S = CollConstAt (Spans, I);
/* Done accept empty spans */
CHECK (S->End > S->Start);
/* Write data for the span We will write the size instead of the end
@ -175,8 +165,23 @@ void WriteSpans (const Collection* Spans)
ObjWriteVar (S->Start);
ObjWriteVar (S->End - S->Start);
}
void WriteSpans (const Collection* Spans)
/* Write a list of spans to the output file */
{
unsigned I;
/* Write the number of spans */
ObjWriteVar (CollCount (Spans));
/* Write the spans */
for (I = 0; I < CollCount (Spans); ++I) {
/* Write the next span */
WriteSpan (CollConstAt (Spans, I));
}
}

View file

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