repeat.o \
scanner.o \
segment.o \
- segrange.o \
sizeof.o \
+ span.o \
spool.o \
struct.o \
studyexpr.o \
repeat.obj \
scanner.obj \
segment.obj \
- segrange.obj \
sizeof.obj \
+ span.obj \
spool.obj \
struct.obj \
studyexpr.obj \
@echo "OPTION QUIET" >> $(LNKCFG)
@echo "OPTION MAP" >> $(LNKCFG)
@echo "OPTION STACK=65536" >> $(LNKCFG)
- @echo "NAME $@" >> $(LNKCFG)
+ @echo "NAME $@" >> $(LNKCFG)
@for i in $(OBJS); do echo "FILE $${i}"; done >> $(LNKCFG)
@for i in $(LIBS); do echo "LIBRARY $${i}"; done >> $(LNKCFG)
@$(LD) system $(SYSTEM) @$(LNKCFG)
+++ /dev/null
-/*****************************************************************************/
-/* */
-/* segrange.c */
-/* */
-/* A segment range */
-/* */
-/* */
-/* */
-/* (C) 2003-2011, Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
-/* */
-/* */
-/* This software is provided 'as-is', without any expressed or implied */
-/* warranty. In no event will the authors be held liable for any damages */
-/* arising from the use of this software. */
-/* */
-/* Permission is granted to anyone to use this software for any purpose, */
-/* including commercial applications, and to alter it and redistribute it */
-/* freely, subject to the following restrictions: */
-/* */
-/* 1. The origin of this software must not be misrepresented; you must not */
-/* claim that you wrote the original software. If you use this software */
-/* in a product, an acknowledgment in the product documentation would be */
-/* appreciated but is not required. */
-/* 2. Altered source versions must be plainly marked as such, and must not */
-/* be misrepresented as being the original software. */
-/* 3. This notice may not be removed or altered from any source */
-/* distribution. */
-/* */
-/*****************************************************************************/
-
-
-
-/* common */
-#include "xmalloc.h"
-
-/* ca65 */
-#include "objfile.h"
-#include "segment.h"
-#include "segrange.h"
-
-
-
-/*****************************************************************************/
-/* Code */
-/*****************************************************************************/
-
-
-
-SegRange* NewSegRange (struct Segment* Seg)
-/* Create a new segment range. The segment is set to Seg, Start and End are
- * set to the current PC of the segment.
- */
-{
- /* Allocate memory */
- SegRange* R = xmalloc (sizeof (SegRange));
-
- /* Initialize the struct */
- R->Seg = Seg;
- R->Start = Seg->PC;
- R->End = Seg->PC;
-
- /* Return the new struct */
- return R;
-}
-
-
-
-void AddSegRanges (Collection* Ranges)
-/* Add a segment range for all existing segments to the given collection of
- * ranges. The currently active segment will be inserted first with all others
- * following.
- */
-{
- Segment* Seg;
-
- /* Add the currently active segment */
- CollAppend (Ranges, NewSegRange (ActiveSeg));
-
- /* Walk through the segment list and add all other segments */
- Seg = SegmentList;
- while (Seg) {
- /* Be sure to skip the active segment, since it was already added */
- if (Seg != ActiveSeg) {
- CollAppend (Ranges, NewSegRange (Seg));
- }
- Seg = Seg->List;
- }
-}
-
-
-
-void CloseSegRanges (Collection* Ranges)
-/* Close all open segment ranges by setting PC to the current PC for the
- * segment.
- */
-{
- unsigned I;
-
- /* Walk over the segment list */
- for (I = 0; I < CollCount (Ranges); ++I) {
-
- /* Get the next segment range */
- SegRange* R = CollAtUnchecked (Ranges, I);
-
- /* Set the end offset */
- R->End = R->Seg->PC;
- }
-}
-
-
-
-void WriteSegRanges (const Collection* Ranges)
-/* Write a list of segment ranges to the output file */
-{
- unsigned I;
- unsigned Count;
-
- /* Determine how many of the segments contain actual data */
- Count = 0;
- for (I = 0; I < CollCount (Ranges); ++I) {
-
- /* Get next range */
- const SegRange* R = CollConstAt (Ranges, I);
-
- /* Is this segment range empty? */
- if (R->Start != R->End) {
- ++Count;
- }
- }
-
- /* Write the number of ranges with data */
- ObjWriteVar (Count);
-
- /* Write the ranges */
- for (I = 0; I < CollCount (Ranges); ++I) {
-
- /* Get next range */
- const SegRange* R = CollConstAt (Ranges, I);
-
- /* Write data for non empty ranges */
- if (R->Start != R->End) {
- ObjWriteVar (R->Seg->Num);
- ObjWriteVar (R->Start);
- ObjWriteVar (R->End);
- }
- }
-}
-
-
-
-
+++ /dev/null
-/*****************************************************************************/
-/* */
-/* segrange.h */
-/* */
-/* A segment range */
-/* */
-/* */
-/* */
-/* (C) 2003-2011, Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
-/* */
-/* */
-/* This software is provided 'as-is', without any expressed or implied */
-/* warranty. In no event will the authors be held liable for any damages */
-/* arising from the use of this software. */
-/* */
-/* Permission is granted to anyone to use this software for any purpose, */
-/* including commercial applications, and to alter it and redistribute it */
-/* freely, subject to the following restrictions: */
-/* */
-/* 1. The origin of this software must not be misrepresented; you must not */
-/* claim that you wrote the original software. If you use this software */
-/* in a product, an acknowledgment in the product documentation would be */
-/* appreciated but is not required. */
-/* 2. Altered source versions must be plainly marked as such, and must not */
-/* be misrepresented as being the original software. */
-/* 3. This notice may not be removed or altered from any source */
-/* distribution. */
-/* */
-/*****************************************************************************/
-
-
-
-#ifndef SEGRANGE_H
-#define SEGRANGE_H
-
-
-
-/* common */
-#include "coll.h"
-#include "inline.h"
-
-
-
-/*****************************************************************************/
-/* Data */
-/*****************************************************************************/
-
-
-
-/* Segment range definition */
-typedef struct SegRange SegRange;
-struct SegRange{
- struct Segment* Seg; /* Pointer to segment */
- unsigned long Start; /* Start of range */
- unsigned long End; /* End of range */
-};
-
-
-
-/*****************************************************************************/
-/* Code */
-/*****************************************************************************/
-
-
-
-SegRange* NewSegRange (struct Segment* Seg);
-/* Create a new segment range. The segment is set to Seg, Start and End are
- * set to the current PC of the segment.
- */
-
-#if defined(HAVE_INLINE)
-INLINE unsigned long GetSegRangeSize (const SegRange* R)
-/* Return the segment range size in bytes */
-{
- return (R->End - R->Start);
-}
-#else
-# define GetSegRangeSize(R) ((R)->End - (R)->Start)
-#endif
-
-void AddSegRanges (Collection* Ranges);
-/* Add a segment range for all existing segments to the given collection of
- * ranges. The currently active segment will be inserted first with all others
- * following.
- */
-
-void CloseSegRanges (Collection* Ranges);
-/* Close all open segment ranges by setting PC to the current PC for the
- * segment.
- */
-
-void WriteSegRanges (const Collection* Ranges);
-/* Write a list of segment ranges to the output file */
-
-
-
-/* End of segrange.h */
-
-#endif
-
-
-
-
--- /dev/null
+/*****************************************************************************/
+/* */
+/* span.c */
+/* */
+/* A span of data within a segment */
+/* */
+/* */
+/* */
+/* (C) 2003-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+/* common */
+#include "xmalloc.h"
+
+/* ca65 */
+#include "objfile.h"
+#include "segment.h"
+#include "span.h"
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+Span* NewSpan (struct Segment* Seg)
+/* Create a new span. The segment is set to Seg, Start and End are set to the
+ * current PC of the segment.
+ */
+{
+ /* Allocate memory */
+ Span* S = xmalloc (sizeof (Span));
+
+ /* Initialize the struct */
+ S->Seg = Seg;
+ S->Start = Seg->PC;
+ S->End = Seg->PC;
+
+ /* Return the new struct */
+ return S;
+}
+
+
+
+void AddSpans (Collection* Spans)
+/* Add a span for all existing segments to the given collection of spans. The
+ * currently active segment will be inserted first with all others following.
+ */
+{
+ Segment* Seg;
+
+ /* Add the currently active segment */
+ CollAppend (Spans, NewSpan (ActiveSeg));
+
+ /* Walk through the segment list and add all other segments */
+ Seg = SegmentList;
+ while (Seg) {
+ /* Be sure to skip the active segment, since it was already added */
+ if (Seg != ActiveSeg) {
+ CollAppend (Spans, NewSpan (Seg));
+ }
+ Seg = Seg->List;
+ }
+}
+
+
+
+void CloseSpans (Collection* Spans)
+/* Close all open spans by setting PC to the current PC for the segment. */
+{
+ unsigned I;
+
+ /* Walk over the segment list */
+ for (I = 0; I < CollCount (Spans); ++I) {
+
+ /* Get the next segment range */
+ Span* S = CollAtUnchecked (Spans, I);
+
+ /* Set the end offset */
+ S->End = S->Seg->PC;
+ }
+}
+
+
+
+void WriteSpans (const Collection* Spans)
+/* Write a list of spans to the output file */
+{
+ unsigned I;
+ unsigned Count;
+
+ /* Determine how many of the segments contain actual data */
+ Count = 0;
+ for (I = 0; I < CollCount (Spans); ++I) {
+
+ /* Get next range */
+ const Span* S = CollConstAt (Spans, I);
+
+ /* Is this segment range empty? */
+ if (S->Start != S->End) {
+ ++Count;
+ }
+ }
+
+ /* Write the number of spans with data */
+ ObjWriteVar (Count);
+
+ /* Write the spans */
+ for (I = 0; I < CollCount (Spans); ++I) {
+
+ /* Get next range */
+ const Span* S = CollConstAt (Spans, I);
+
+ /* Write data for non empty spans. We will write the size instead of
+ * the end offset to save some bytes, since most spans are expected
+ * to be rather small.
+ */
+ if (S->Start != S->End) {
+ ObjWriteVar (S->Seg->Num);
+ ObjWriteVar (S->Start);
+ ObjWriteVar (S->End - S->Start);
+ }
+ }
+}
+
+
+
+
--- /dev/null
+/*****************************************************************************/
+/* */
+/* span.h */
+/* */
+/* A span of data within a segment */
+/* */
+/* */
+/* */
+/* (C) 2003-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef SPAN_H
+#define SPAN_H
+
+
+
+/* common */
+#include "coll.h"
+#include "inline.h"
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Span definition */
+typedef struct Span Span;
+struct Span{
+ struct Segment* Seg; /* Pointer to segment */
+ unsigned long Start; /* Start of range */
+ unsigned long End; /* End of range */
+};
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+Span* NewSpan (struct Segment* Seg);
+/* Create a new span. The segment is set to Seg, Start and End are set to the
+ * current PC of the segment.
+ */
+
+#if defined(HAVE_INLINE)
+INLINE unsigned long GetSpanSize (const Span* R)
+/* Return the span size in bytes */
+{
+ return (R->End - R->Start);
+}
+#else
+# define GetSpanSize(R) ((R)->End - (R)->Start)
+#endif
+
+void AddSpans (Collection* Spans);
+/* Add a span for all existing segments to the given collection of spans. The
+ * currently active segment will be inserted first with all others following.
+ */
+
+void CloseSpans (Collection* Spans);
+/* Close all open spans by setting PC to the current PC for the segment. */
+
+void WriteSpans (const Collection* Spans);
+/* Write a list of spans to the output file */
+
+
+
+/* End of span.h */
+
+#endif
+
+
+
#include "scanner.h"
#include "segment.h"
#include "sizeof.h"
+#include "span.h"
#include "spool.h"
#include "studyexpr.h"
#include "symtab.h"
S->Right = 0;
S->Childs = 0;
S->OwnerSym = 0;
- S->SegRanges = AUTO_COLLECTION_INITIALIZER;
+ S->Spans = AUTO_COLLECTION_INITIALIZER;
S->Id = ScopeCount++;
S->Flags = ST_NONE;
S->AddrSize = ADDR_SIZE_DEFAULT;
CurrentScope->Type = Type;
CurrentScope->OwnerSym = OwnerSym;
- /* If this is a scope that allows to emit data into segments, add segment
- * ranges for all currently existing segments. Doing this for just a few
- * scope types is not really necessary but an optimization, because it
- * does not allocate memory for useless data (unhandled types here don't
- * occupy space in any segment).
+ /* If this is a scope that allows to emit data into segments, add spans
+ * for all currently existing segments. Doing this for just a few scope
+ * types is not really necessary but an optimization, because it does not
+ * allocate memory for useless data (unhandled types here don't occupy
+ * space in any segment).
*/
if (CurrentScope->Type <= SCOPE_HAS_DATA) {
- AddSegRanges (&CurrentScope->SegRanges);
+ AddSpans (&CurrentScope->Spans);
}
}
void SymLeaveLevel (void)
/* Leave the current lexical level */
{
- /* Close the segment ranges. We don't care about the scope type here,
- * since types without segment ranges will just have an empty list.
+ /* Close the spans. We don't care about the scope type here, since types
+ * without spans will just have an empty list.
*/
- CloseSegRanges (&CurrentScope->SegRanges);
+ CloseSpans (&CurrentScope->Spans);
- /* If we have segment ranges, the first one is the segment that was
- * active, when the scope was opened. Set the size of the scope to the
- * number of data bytes emitted into this segment. If we have an owner
- * symbol set the size of this symbol, too.
+ /* If we have spans, the first one is the segment that was active, when the
+ * scope was opened. Set the size of the scope to the number of data bytes
+ * emitted into this segment. If we have an owner symbol set the size of
+ * this symbol, too.
*/
- if (CollCount (&CurrentScope->SegRanges) > 0) {
- const SegRange* R = CollAtUnchecked (&CurrentScope->SegRanges, 0);
- unsigned long Size = GetSegRangeSize (R);
+ if (CollCount (&CurrentScope->Spans) > 0) {
+ const Span* S = CollAtUnchecked (&CurrentScope->Spans, 0);
+ unsigned long Size = GetSpanSize (S);
DefSizeOfScope (CurrentScope, Size);
if (CurrentScope->OwnerSym) {
DefSizeOfSymbol (CurrentScope->OwnerSym, Size);
- }
+ }
}
/* Leave the scope */
ObjWriteVar (Size);
}
- /* Segment ranges for this scope */
- WriteSegRanges (&S->SegRanges);
+ /* Spans for this scope */
+ WriteSpans (&S->Spans);
/* Next scope */
S = S->Next;
#include "inline.h"
/* ca65 */
-#include "segrange.h"
#include "symentry.h"
SymTable* Parent; /* Link to enclosing scope if any */
SymTable* Childs; /* Pointer to child scopes */
SymEntry* OwnerSym; /* Symbol that "owns" the scope */
- Collection SegRanges; /* Segment ranges for this scope */
+ Collection Spans; /* Spans for this scope */
unsigned Id; /* Scope id */
unsigned short Flags; /* Symbol table flags */
unsigned char AddrSize; /* Address size */