InitIncludePaths ();
/* Create the predefined segments */
- InitSegments ();
+ SegInit ();
/* Enter the base lexical level. We must do that here, since we may
* define symbols using -D.
/* 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 */
/* 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 */
#include "objcode.h"
#include "objfile.h"
#include "segment.h"
+#include "span.h"
#include "spool.h"
#include "studyexpr.h"
#include "symtab.h"
-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
-void InitSegments (void)
+void SegInit (void)
/* Initialize segments */
{
/* Create the predefined segments. Code segment is active */
/* 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 */
* 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);
+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 */
{
/* 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));
}
}
-
+/* 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 */
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/